aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/math
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sword25/math')
-rw-r--r--engines/sword25/math/geometry.cpp6
-rw-r--r--engines/sword25/math/geometry.h6
-rw-r--r--engines/sword25/math/geometry_script.cpp112
-rw-r--r--engines/sword25/math/line.h22
-rw-r--r--engines/sword25/math/polygon.cpp126
-rw-r--r--engines/sword25/math/polygon.h38
-rw-r--r--engines/sword25/math/rect.h2
-rw-r--r--engines/sword25/math/region.cpp116
-rw-r--r--engines/sword25/math/region.h32
-rw-r--r--engines/sword25/math/regionregistry.cpp12
-rw-r--r--engines/sword25/math/regionregistry.h10
-rw-r--r--engines/sword25/math/vertex.cpp14
-rw-r--r--engines/sword25/math/vertex.h46
-rw-r--r--engines/sword25/math/walkregion.cpp56
-rw-r--r--engines/sword25/math/walkregion.h26
15 files changed, 312 insertions, 312 deletions
diff --git a/engines/sword25/math/geometry.cpp b/engines/sword25/math/geometry.cpp
index de65017c32..e2816e8a52 100644
--- a/engines/sword25/math/geometry.cpp
+++ b/engines/sword25/math/geometry.cpp
@@ -38,7 +38,7 @@ namespace Sword25 {
#define BS_LOG_PREFIX "GEOMETRY"
-BS_Geometry::BS_Geometry(BS_Kernel *pKernel) : BS_Service(pKernel) {
+Geometry::Geometry(BS_Kernel *pKernel) : BS_Service(pKernel) {
if (!_RegisterScriptBindings())
BS_LOG_ERRORLN("Script bindings could not be registered.");
else
@@ -46,8 +46,8 @@ BS_Geometry::BS_Geometry(BS_Kernel *pKernel) : BS_Service(pKernel) {
}
-BS_Service *BS_Geometry_CreateObject(BS_Kernel *pKernel) {
- return new BS_Geometry(pKernel);
+BS_Service *Geometry_CreateObject(BS_Kernel *pKernel) {
+ return new Geometry(pKernel);
}
} // End of namespace Sword25
diff --git a/engines/sword25/math/geometry.h b/engines/sword25/math/geometry.h
index 4fee262f2e..bab8183e35 100644
--- a/engines/sword25/math/geometry.h
+++ b/engines/sword25/math/geometry.h
@@ -42,10 +42,10 @@ namespace Sword25 {
class BS_Kernel;
-class BS_Geometry : public BS_Service {
+class Geometry : public BS_Service {
public:
- BS_Geometry(BS_Kernel *pKernel);
- virtual ~BS_Geometry() {}
+ Geometry(BS_Kernel *pKernel);
+ virtual ~Geometry() {}
private:
bool _RegisterScriptBindings();
diff --git a/engines/sword25/math/geometry_script.cpp b/engines/sword25/math/geometry_script.cpp
index 736e3f3d24..2e24c6e446 100644
--- a/engines/sword25/math/geometry_script.cpp
+++ b/engines/sword25/math/geometry_script.cpp
@@ -71,7 +71,7 @@ static void *my_checkudata(lua_State *L, int ud, const char *tname) {
if (p != NULL) { /* value is a userdata? */
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
// lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
- BS_LuaBindhelper::GetMetatable(L, tname);
+ LuaBindhelper::GetMetatable(L, tname);
/* does it have the correct mt? */
if (lua_rawequal(L, -1, -2)) {
lua_settop(L, top);
@@ -138,7 +138,7 @@ static bool IsValidPolygonDefinition(lua_State *L) {
// -----------------------------------------------------------------------------
-static void TablePolygonToPolygon(lua_State *L, BS_Polygon &Polygon) {
+static void TablePolygonToPolygon(lua_State *L, Polygon &Polygon) {
#ifdef DEBUG
int __startStackDepth = lua_gettop(L);
#endif
@@ -151,7 +151,7 @@ static void TablePolygonToPolygon(lua_State *L, BS_Polygon &Polygon) {
int VertexCount = luaL_getn(L, -1) / 2;
// Memory is reserved for Vertecies
- Common::Array<BS_Vertex> Vertecies;
+ Common::Array<Vertex> Vertecies;
Vertecies.reserve(VertexCount);
// Create Vertecies
@@ -167,7 +167,7 @@ static void TablePolygonToPolygon(lua_State *L, BS_Polygon &Polygon) {
lua_pop(L, 1);
// Vertex
- Vertecies.push_back(BS_Vertex(X, Y));
+ Vertecies.push_back(Vertex(X, Y));
}
BS_ASSERT((int)Vertecies.size() == VertexCount);
@@ -201,9 +201,9 @@ static unsigned int TableRegionToRegion(lua_State *L, const char *ClassName) {
unsigned int RegionHandle = 0;
if (!strcmp(ClassName, REGION_CLASS_NAME)) {
- RegionHandle = BS_Region::Create(BS_Region::RT_REGION);
+ RegionHandle = Region::Create(Region::RT_REGION);
} else if (!strcmp(ClassName, WALKREGION_CLASS_NAME)) {
- RegionHandle = BS_WalkRegion::Create(BS_Region::RT_WALKREGION);
+ RegionHandle = WalkRegion::Create(Region::RT_WALKREGION);
} else {
BS_ASSERT(false);
}
@@ -219,23 +219,23 @@ static unsigned int TableRegionToRegion(lua_State *L, const char *ClassName) {
switch (FirstElementType) {
case LUA_TNUMBER: {
- BS_Polygon Polygon;
- TablePolygonToPolygon(L, Polygon);
- BS_RegionRegistry::GetInstance().ResolveHandle(RegionHandle)->Init(Polygon);
+ Polygon polygon;
+ TablePolygonToPolygon(L, polygon);
+ RegionRegistry::GetInstance().ResolveHandle(RegionHandle)->Init(polygon);
}
break;
case LUA_TTABLE: {
lua_rawgeti(L, -1, 1);
- BS_Polygon Polygon;
- TablePolygonToPolygon(L, Polygon);
+ Polygon polygon;
+ TablePolygonToPolygon(L, polygon);
lua_pop(L, 1);
int PolygonCount = luaL_getn(L, -1);
if (PolygonCount == 1)
- BS_RegionRegistry::GetInstance().ResolveHandle(RegionHandle)->Init(Polygon);
+ RegionRegistry::GetInstance().ResolveHandle(RegionHandle)->Init(polygon);
else {
- Common::Array<BS_Polygon> Holes;
+ Common::Array<Polygon> Holes;
Holes.reserve(PolygonCount - 1);
for (int i = 2; i <= PolygonCount; i++) {
@@ -246,7 +246,7 @@ static unsigned int TableRegionToRegion(lua_State *L, const char *ClassName) {
}
BS_ASSERT((int)Holes.size() == PolygonCount - 1);
- BS_RegionRegistry::GetInstance().ResolveHandle(RegionHandle)->Init(Polygon, &Holes);
+ RegionRegistry::GetInstance().ResolveHandle(RegionHandle)->Init(polygon, &Holes);
}
}
break;
@@ -273,7 +273,7 @@ static void NewUserdataRegion(lua_State *L, const char *ClassName) {
NewUintUserData(L, RegionHandle);
// luaL_getmetatable(L, ClassName);
- BS_LuaBindhelper::GetMetatable(L, ClassName);
+ LuaBindhelper::GetMetatable(L, ClassName);
BS_ASSERT(!lua_isnil(L, -1));
lua_setmetatable(L, -2);
}
@@ -304,12 +304,12 @@ static const luaL_reg GEO_FUNCTIONS[] = {
// -----------------------------------------------------------------------------
-static BS_Region *CheckRegion(lua_State *L) {
+static Region *CheckRegion(lua_State *L) {
// The first parameter must be of type 'userdata', and the Metatable class Geo.Region or Geo.WalkRegion
unsigned int *RegionHandlePtr;
if ((RegionHandlePtr = reinterpret_cast<unsigned int *>(my_checkudata(L, 1, REGION_CLASS_NAME))) != 0 ||
(RegionHandlePtr = reinterpret_cast<unsigned int *>(my_checkudata(L, 1, WALKREGION_CLASS_NAME))) != 0) {
- return BS_RegionRegistry::GetInstance().ResolveHandle(*RegionHandlePtr);
+ return RegionRegistry::GetInstance().ResolveHandle(*RegionHandlePtr);
} else {
luaL_argcheck(L, 0, 1, "'" REGION_CLASS_NAME "' expected");
}
@@ -321,7 +321,7 @@ static BS_Region *CheckRegion(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_IsValid(lua_State *L) {
- BS_Region *pR = CheckRegion(L);
+ Region *pR = CheckRegion(L);
BS_ASSERT(pR);
lua_pushbooleancpp(L, pR->IsValid());
@@ -331,7 +331,7 @@ static int R_IsValid(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_GetX(lua_State *L) {
- BS_Region *pR = CheckRegion(L);
+ Region *pR = CheckRegion(L);
BS_ASSERT(pR);
lua_pushnumber(L, pR->GetPosX());
@@ -341,7 +341,7 @@ static int R_GetX(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_GetY(lua_State *L) {
- BS_Region *pR = CheckRegion(L);
+ Region *pR = CheckRegion(L);
BS_ASSERT(pR);
lua_pushnumber(L, pR->GetPosY());
@@ -351,21 +351,21 @@ static int R_GetY(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_GetPos(lua_State *L) {
- BS_Region *pR = CheckRegion(L);
+ Region *pR = CheckRegion(L);
BS_ASSERT(pR);
- BS_Vertex::VertexToLuaVertex(L, pR->GetPosition());
+ Vertex::VertexToLuaVertex(L, pR->GetPosition());
return 1;
}
// -----------------------------------------------------------------------------
static int R_IsPointInRegion(lua_State *L) {
- BS_Region *pR = CheckRegion(L);
+ Region *pR = CheckRegion(L);
BS_ASSERT(pR);
- BS_Vertex Vertex;
- BS_Vertex::LuaVertexToVertex(L, 2, Vertex);
+ Vertex Vertex;
+ Vertex::LuaVertexToVertex(L, 2, Vertex);
lua_pushbooleancpp(L, pR->IsPointInRegion(Vertex));
return 1;
}
@@ -373,11 +373,11 @@ static int R_IsPointInRegion(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_SetPos(lua_State *L) {
- BS_Region *pR = CheckRegion(L);
+ Region *pR = CheckRegion(L);
BS_ASSERT(pR);
- BS_Vertex Vertex;
- BS_Vertex::LuaVertexToVertex(L, 2, Vertex);
+ Vertex Vertex;
+ Vertex::LuaVertexToVertex(L, 2, Vertex);
pR->SetPos(Vertex.X, Vertex.Y);
return 0;
@@ -386,7 +386,7 @@ static int R_SetPos(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_SetX(lua_State *L) {
- BS_Region *pR = CheckRegion(L);
+ Region *pR = CheckRegion(L);
BS_ASSERT(pR);
pR->SetPosX(static_cast<int>(luaL_checknumber(L, 2)));
@@ -397,7 +397,7 @@ static int R_SetX(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_SetY(lua_State *L) {
- BS_Region *pR = CheckRegion(L);
+ Region *pR = CheckRegion(L);
BS_ASSERT(pR);
pR->SetPosY(static_cast<int>(luaL_checknumber(L, 2)));
@@ -407,7 +407,7 @@ static int R_SetY(lua_State *L) {
// -----------------------------------------------------------------------------
-static void DrawPolygon(const BS_Polygon &Polygon, unsigned int Color, const BS_Vertex &Offset) {
+static void DrawPolygon(const Polygon &Polygon, unsigned int Color, const Vertex &Offset) {
GraphicEngine *pGE = static_cast<GraphicEngine *>(BS_Kernel::GetInstance()->GetService("gfx"));
BS_ASSERT(pGE);
@@ -419,7 +419,7 @@ static void DrawPolygon(const BS_Polygon &Polygon, unsigned int Color, const BS_
// -----------------------------------------------------------------------------
-static void DrawRegion(const BS_Region &Region, unsigned int Color, const BS_Vertex &Offset) {
+static void DrawRegion(const Region &Region, unsigned int Color, const Vertex &Offset) {
DrawPolygon(Region.GetContour(), Color, Offset);
for (int i = 0; i < Region.GetHoleCount(); i++)
DrawPolygon(Region.GetHole(i), Color, Offset);
@@ -428,23 +428,23 @@ static void DrawRegion(const BS_Region &Region, unsigned int Color, const BS_Ver
// -----------------------------------------------------------------------------
static int R_Draw(lua_State *L) {
- BS_Region *pR = CheckRegion(L);
+ Region *pR = CheckRegion(L);
BS_ASSERT(pR);
switch (lua_gettop(L)) {
case 3: {
- BS_Vertex Offset;
- BS_Vertex::LuaVertexToVertex(L, 3, Offset);
+ Vertex Offset;
+ Vertex::LuaVertexToVertex(L, 3, Offset);
DrawRegion(*pR, GraphicEngine::LuaColorToARGBColor(L, 2), Offset);
}
break;
case 2:
- DrawRegion(*pR, GraphicEngine::LuaColorToARGBColor(L, 2), BS_Vertex(0, 0));
+ DrawRegion(*pR, GraphicEngine::LuaColorToARGBColor(L, 2), Vertex(0, 0));
break;
default:
- DrawRegion(*pR, BS_RGB(255, 255, 255), BS_Vertex(0, 0));
+ DrawRegion(*pR, BS_RGB(255, 255, 255), Vertex(0, 0));
}
return 0;
@@ -453,10 +453,10 @@ static int R_Draw(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_GetCentroid(lua_State *L) {
- BS_Region *RPtr = CheckRegion(L);
+ Region *RPtr = CheckRegion(L);
BS_ASSERT(RPtr);
- BS_Vertex::VertexToLuaVertex(L, RPtr->GetCentroid());
+ Vertex::VertexToLuaVertex(L, RPtr->GetCentroid());
return 1;
}
@@ -464,7 +464,7 @@ static int R_GetCentroid(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_Delete(lua_State *L) {
- BS_Region *pR = CheckRegion(L);
+ Region *pR = CheckRegion(L);
BS_ASSERT(pR);
delete pR;
return 0;
@@ -488,11 +488,11 @@ static const luaL_reg REGION_METHODS[] = {
// -----------------------------------------------------------------------------
-static BS_WalkRegion *CheckWalkRegion(lua_State *L) {
+static WalkRegion *CheckWalkRegion(lua_State *L) {
// The first parameter must be of type 'userdate', and the Metatable class Geo.WalkRegion
unsigned int RegionHandle;
if ((RegionHandle = *reinterpret_cast<unsigned int *>(my_checkudata(L, 1, WALKREGION_CLASS_NAME))) != 0) {
- return reinterpret_cast<BS_WalkRegion *>(BS_RegionRegistry::GetInstance().ResolveHandle(RegionHandle));
+ return reinterpret_cast<WalkRegion *>(RegionRegistry::GetInstance().ResolveHandle(RegionHandle));
} else {
luaL_argcheck(L, 0, 1, "'" WALKREGION_CLASS_NAME "' expected");
}
@@ -504,20 +504,20 @@ static BS_WalkRegion *CheckWalkRegion(lua_State *L) {
// -----------------------------------------------------------------------------
static int WR_GetPath(lua_State *L) {
- BS_WalkRegion *pWR = CheckWalkRegion(L);
+ WalkRegion *pWR = CheckWalkRegion(L);
BS_ASSERT(pWR);
- BS_Vertex Start;
- BS_Vertex::LuaVertexToVertex(L, 2, Start);
- BS_Vertex End;
- BS_Vertex::LuaVertexToVertex(L, 3, End);
+ Vertex Start;
+ Vertex::LuaVertexToVertex(L, 2, Start);
+ Vertex End;
+ Vertex::LuaVertexToVertex(L, 3, End);
BS_Path Path;
if (pWR->QueryPath(Start, End, Path)) {
lua_newtable(L);
BS_Path::const_iterator it = Path.begin();
for (; it != Path.end(); it++) {
lua_pushnumber(L, (it - Path.begin()) + 1);
- BS_Vertex::VertexToLuaVertex(L, *it);
+ Vertex::VertexToLuaVertex(L, *it);
lua_settable(L, -3);
}
} else
@@ -535,22 +535,22 @@ static const luaL_reg WALKREGION_METHODS[] = {
// -----------------------------------------------------------------------------
-bool BS_Geometry::_RegisterScriptBindings() {
+bool Geometry::_RegisterScriptBindings() {
BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
+ ScriptEngine *pScript = static_cast<ScriptEngine *>(pKernel->GetService("script"));
BS_ASSERT(pScript);
lua_State *L = static_cast< lua_State *>(pScript->GetScriptObject());
BS_ASSERT(L);
- if (!BS_LuaBindhelper::AddMethodsToClass(L, REGION_CLASS_NAME, REGION_METHODS)) return false;
- if (!BS_LuaBindhelper::AddMethodsToClass(L, WALKREGION_CLASS_NAME, REGION_METHODS)) return false;
- if (!BS_LuaBindhelper::AddMethodsToClass(L, WALKREGION_CLASS_NAME, WALKREGION_METHODS)) return false;
+ if (!LuaBindhelper::AddMethodsToClass(L, REGION_CLASS_NAME, REGION_METHODS)) return false;
+ if (!LuaBindhelper::AddMethodsToClass(L, WALKREGION_CLASS_NAME, REGION_METHODS)) return false;
+ if (!LuaBindhelper::AddMethodsToClass(L, WALKREGION_CLASS_NAME, WALKREGION_METHODS)) return false;
- if (!BS_LuaBindhelper::SetClassGCHandler(L, REGION_CLASS_NAME, R_Delete)) return false;
- if (!BS_LuaBindhelper::SetClassGCHandler(L, WALKREGION_CLASS_NAME, R_Delete)) return false;
+ if (!LuaBindhelper::SetClassGCHandler(L, REGION_CLASS_NAME, R_Delete)) return false;
+ if (!LuaBindhelper::SetClassGCHandler(L, WALKREGION_CLASS_NAME, R_Delete)) return false;
- if (!BS_LuaBindhelper::AddFunctionsToLib(L, GEO_LIBRARY_NAME, GEO_FUNCTIONS)) return false;
+ if (!LuaBindhelper::AddFunctionsToLib(L, GEO_LIBRARY_NAME, GEO_FUNCTIONS)) return false;
return true;
}
diff --git a/engines/sword25/math/line.h b/engines/sword25/math/line.h
index 5e442045f1..f2f0607251 100644
--- a/engines/sword25/math/line.h
+++ b/engines/sword25/math/line.h
@@ -57,7 +57,7 @@
namespace Sword25 {
-class BS_Line {
+class Line {
public:
/**
* Determines whether a piont is left of a line
@@ -67,11 +67,11 @@ public:
* @return Returns true if the point is to the left of the line.
* If the point is to the right of the line or on the line, false is returned.
*/
- static bool IsVertexLeft(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
+ static bool IsVertexLeft(const Vertex &a, const Vertex &b, const Vertex &c) {
return _TriangleArea2(a, b, c) > 0;
}
- static bool IsVertexLeftOn(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
+ static bool IsVertexLeftOn(const Vertex &a, const Vertex &b, const Vertex &c) {
return _TriangleArea2(a, b, c) >= 0;
}
@@ -83,11 +83,11 @@ public:
* @return Returns true if the point is to the right of the line.
* If the point is to the right of the line or on the line, false is returned.
*/
- static bool IsVertexRight(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
+ static bool IsVertexRight(const Vertex &a, const Vertex &b, const Vertex &c) {
return _TriangleArea2(a, b, c) < 0;
}
- static bool IsVertexRightOn(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
+ static bool IsVertexRightOn(const Vertex &a, const Vertex &b, const Vertex &c) {
return _TriangleArea2(a, b, c) <= 0;
}
@@ -98,7 +98,7 @@ public:
* @param c The test point
* @return Returns true if the point is on the line, false otherwise.
*/
- static bool IsVertexOn(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
+ static bool IsVertexOn(const Vertex &a, const Vertex &b, const Vertex &c) {
return _TriangleArea2(a, b, c) == 0;
}
@@ -117,7 +117,7 @@ public:
* RIGHT is returned if the point is to the right of the line.
* ON is returned if the point is on the line.
*/
- static VERTEX_CLASSIFICATION ClassifyVertexToLine(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
+ static VERTEX_CLASSIFICATION ClassifyVertexToLine(const Vertex &a, const Vertex &b, const Vertex &c) {
int Area = _TriangleArea2(a, b, c);
if (Area > 0) return LEFT;
if (Area < 0) return RIGHT;
@@ -132,7 +132,7 @@ public:
* @param d The end point of the second line
* @remark In cases where a line only touches the other, false is returned (improper intersection)
*/
- static bool DoesIntersectProperly(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c, const BS_Vertex &d) {
+ static bool DoesIntersectProperly(const Vertex &a, const Vertex &b, const Vertex &c, const Vertex &d) {
VERTEX_CLASSIFICATION Class1 = ClassifyVertexToLine(a, b, c);
VERTEX_CLASSIFICATION Class2 = ClassifyVertexToLine(a, b, d);
VERTEX_CLASSIFICATION Class3 = ClassifyVertexToLine(c, d, a);
@@ -149,7 +149,7 @@ public:
* @param b The end point of a line
* @param c The test point
*/
- static bool IsOnLine(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
+ static bool IsOnLine(const Vertex &a, const Vertex &b, const Vertex &c) {
// The items must all be Collinear, otherwise don't bothering testing the point
if (_TriangleArea2(a, b, c) != 0) return false;
@@ -167,7 +167,7 @@ public:
}
}
- static bool IsOnLineStrict(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
+ static bool IsOnLineStrict(const Vertex &a, const Vertex &b, const Vertex &c) {
// The items must all be Collinear, otherwise don't bothering testing the point
if (_TriangleArea2(a, b, c) != 0) return false;
@@ -192,7 +192,7 @@ private:
* The result is positive if the points are arrange counterclockwise,
* and negative if they are arranged counter-clockwise.
*/
- static int _TriangleArea2(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
+ static int _TriangleArea2(const Vertex &a, const Vertex &b, const Vertex &c) {
return a.X * b.Y - a.Y * b.X +
a.Y * c.X - a.X * c.Y +
b.X * c.Y - c.X * b.Y;
diff --git a/engines/sword25/math/polygon.cpp b/engines/sword25/math/polygon.cpp
index 57a6a37cf4..fb5af91816 100644
--- a/engines/sword25/math/polygon.cpp
+++ b/engines/sword25/math/polygon.cpp
@@ -47,36 +47,36 @@ namespace Sword25 {
// Constructor / Destructor
// --------------------------
-BS_Polygon::BS_Polygon() : VertexCount(0), Vertecies(NULL) {
+Polygon::Polygon() : VertexCount(0), Vertecies(NULL) {
}
-BS_Polygon::BS_Polygon(int VertexCount_, const BS_Vertex *Vertecies_) : VertexCount(0), Vertecies(NULL) {
+Polygon::Polygon(int VertexCount_, const Vertex *Vertecies_) : VertexCount(0), Vertecies(NULL) {
Init(VertexCount_, Vertecies_);
}
-BS_Polygon::BS_Polygon(const BS_Polygon &Other) : VertexCount(0), Vertecies(NULL) {
+Polygon::Polygon(const Polygon &Other) : VertexCount(0), Vertecies(NULL) {
Init(Other.VertexCount, Other.Vertecies);
}
-BS_Polygon::BS_Polygon(BS_InputPersistenceBlock &Reader) : VertexCount(0), Vertecies(NULL) {
+Polygon::Polygon(BS_InputPersistenceBlock &Reader) : VertexCount(0), Vertecies(NULL) {
Unpersist(Reader);
}
-BS_Polygon::~BS_Polygon() {
+Polygon::~Polygon() {
delete[] Vertecies;
}
// Initialisation
// ---------------
-bool BS_Polygon::Init(int VertexCount_, const BS_Vertex *Vertecies_) {
+bool Polygon::Init(int VertexCount_, const Vertex *Vertecies_) {
// Rember the old obstate to restore it if an error occurs whilst initialising it with the new data
int OldVertexCount = this->VertexCount;
- BS_Vertex *OldVertecies = this->Vertecies;
+ Vertex *OldVertecies = this->Vertecies;
this->VertexCount = VertexCount_;
- this->Vertecies = new BS_Vertex[VertexCount_ + 1];
- memcpy(this->Vertecies, Vertecies_, sizeof(BS_Vertex) * VertexCount_);
+ this->Vertecies = new Vertex[VertexCount_ + 1];
+ memcpy(this->Vertecies, Vertecies_, sizeof(Vertex) * VertexCount_);
// TODO:
// Duplicate and remove redundant vertecies (Superflous = 3 co-linear verts)
// _WeedRepeatedVertecies();
@@ -108,15 +108,15 @@ bool BS_Polygon::Init(int VertexCount_, const BS_Vertex *Vertecies_) {
// Review the order of the Vertecies
// ---------------------------------
-bool BS_Polygon::IsCW() const {
+bool Polygon::IsCW() const {
return m_IsCW;
}
-bool BS_Polygon::IsCCW() const {
+bool Polygon::IsCCW() const {
return !IsCW();
}
-bool BS_Polygon::ComputeIsCW() const {
+bool Polygon::ComputeIsCW() const {
if (VertexCount) {
// Find the vertex on extreme bottom right
int V2Index = FindLRVertexIndex();
@@ -134,7 +134,7 @@ bool BS_Polygon::ComputeIsCW() const {
return false;
}
-int BS_Polygon::FindLRVertexIndex() const {
+int Polygon::FindLRVertexIndex() const {
if (VertexCount) {
int CurIndex = 0;
int MaxX = Vertecies[0].X;
@@ -158,15 +158,15 @@ int BS_Polygon::FindLRVertexIndex() const {
// Testing for Convex / Concave
// ------------------------
-bool BS_Polygon::IsConvex() const {
+bool Polygon::IsConvex() const {
return m_IsConvex;
}
-bool BS_Polygon::IsConcave() const {
+bool Polygon::IsConcave() const {
return !IsConvex();
}
-bool BS_Polygon::ComputeIsConvex() const {
+bool Polygon::ComputeIsConvex() const {
// Polygons with three or less Vertecies can only be convex
if (VertexCount <= 3) return true;
@@ -201,12 +201,12 @@ bool BS_Polygon::ComputeIsConvex() const {
// Make a determine vertex order
// -----------------------------
-void BS_Polygon::EnsureCWOrder() {
+void Polygon::EnsureCWOrder() {
if (!IsCW())
ReverseVertexOrder();
}
-void BS_Polygon::EnsureCCWOrder() {
+void Polygon::EnsureCCWOrder() {
if (!IsCCW())
ReverseVertexOrder();
}
@@ -214,10 +214,10 @@ void BS_Polygon::EnsureCCWOrder() {
// Reverse the order of vertecies
// ------------------------------
-void BS_Polygon::ReverseVertexOrder() {
+void Polygon::ReverseVertexOrder() {
// Vertecies are exchanged in pairs, until the list has been completely reversed
for (int i = 0; i < VertexCount / 2; i++) {
- BS_Vertex tempVertex = Vertecies[i];
+ Vertex tempVertex = Vertecies[i];
Vertecies[i] = Vertecies[VertexCount - i - 1];
Vertecies[VertexCount - i - 1] = tempVertex;
}
@@ -229,7 +229,7 @@ void BS_Polygon::ReverseVertexOrder() {
// Cross Product
// -------------
-int BS_Polygon::CrossProduct(const BS_Vertex &V1, const BS_Vertex &V2, const BS_Vertex &V3) const {
+int Polygon::CrossProduct(const Vertex &V1, const Vertex &V2, const Vertex &V3) const {
return (V2.X - V1.X) * (V3.Y - V2.Y) -
(V2.Y - V1.Y) * (V3.X - V2.X);
}
@@ -237,7 +237,7 @@ int BS_Polygon::CrossProduct(const BS_Vertex &V1, const BS_Vertex &V2, const BS_
// Scalar Product
// --------------
-int BS_Polygon::DotProduct(const BS_Vertex &V1, const BS_Vertex &V2, const BS_Vertex &V3) const {
+int Polygon::DotProduct(const Vertex &V1, const Vertex &V2, const Vertex &V3) const {
return (V1.X - V2.X) * (V3.X - V2.X) +
(V1.Y - V2.Y) * (V3.X - V2.Y);
}
@@ -245,7 +245,7 @@ int BS_Polygon::DotProduct(const BS_Vertex &V1, const BS_Vertex &V2, const BS_Ve
// Check for self-intersections
// ----------------------------
-bool BS_Polygon::CheckForSelfIntersection() const {
+bool Polygon::CheckForSelfIntersection() const {
// TODO: Finish this
/*
float AngleSum = 0.0f;
@@ -275,7 +275,7 @@ bool BS_Polygon::CheckForSelfIntersection() const {
// Move
// ----
-void BS_Polygon::operator+=(const BS_Vertex &Delta) {
+void Polygon::operator+=(const Vertex &Delta) {
// Move all vertecies
for (int i = 0; i < VertexCount; i++)
Vertecies[i] += Delta;
@@ -287,7 +287,7 @@ void BS_Polygon::operator+=(const BS_Vertex &Delta) {
// Line of Sight
// -------------
-bool BS_Polygon::IsLineInterior(const BS_Vertex &a, const BS_Vertex &b) const {
+bool Polygon::IsLineInterior(const Vertex &a, const Vertex &b) const {
// Both points have to be in the polygon
if (!IsPointInPolygon(a, true) || !IsPointInPolygon(b, true)) return false;
@@ -297,16 +297,16 @@ bool BS_Polygon::IsLineInterior(const BS_Vertex &a, const BS_Vertex &b) const {
// Test whether the line intersects a line segment strictly (proper intersection)
for (int i = 0; i < VertexCount; i++) {
int j = (i + 1) % VertexCount;
- const BS_Vertex &VS = Vertecies[i];
- const BS_Vertex &VE = Vertecies[j];
+ const Vertex &VS = Vertecies[i];
+ const Vertex &VE = Vertecies[j];
// If the line intersects a line segment strictly (proper cross section) the line is not in the polygon
- if (BS_Line::DoesIntersectProperly(a, b, VS, VE)) return false;
+ if (Line::DoesIntersectProperly(a, b, VS, VE)) return false;
// If one of the two line items is on the edge and the other is to the right of the edge,
// then the line is not completely within the polygon
- if (BS_Line::IsOnLineStrict(VS, VE, a) && BS_Line::IsVertexRight(VS, VE, b)) return false;
- if (BS_Line::IsOnLineStrict(VS, VE, b) && BS_Line::IsVertexRight(VS, VE, a)) return false;
+ if (Line::IsOnLineStrict(VS, VE, a) && Line::IsVertexRight(VS, VE, b)) return false;
+ if (Line::IsOnLineStrict(VS, VE, b) && Line::IsVertexRight(VS, VE, a)) return false;
// If one of the two line items is on a vertex, the line traces into the polygon
if ((a == VS) && !IsLineInCone(i, b, true)) return false;
@@ -316,7 +316,7 @@ bool BS_Polygon::IsLineInterior(const BS_Vertex &a, const BS_Vertex &b) const {
return true;
}
-bool BS_Polygon::IsLineExterior(const BS_Vertex &a, const BS_Vertex &b) const {
+bool Polygon::IsLineExterior(const Vertex &a, const Vertex &b) const {
// Neither of the two points must be strictly in the polygon (on the edge is allowed)
if (IsPointInPolygon(a, false) || IsPointInPolygon(b, false)) return false;
@@ -326,24 +326,24 @@ bool BS_Polygon::IsLineExterior(const BS_Vertex &a, const BS_Vertex &b) const {
// Test whether the line intersects a line segment strictly (proper intersection)
for (int i = 0; i < VertexCount; i++) {
int j = (i + 1) % VertexCount;
- const BS_Vertex &VS = Vertecies[i];
- const BS_Vertex &VE = Vertecies[j];
+ const Vertex &VS = Vertecies[i];
+ const Vertex &VE = Vertecies[j];
// If the line intersects a line segment strictly (proper intersection), then
// the line is partially inside the polygon
- if (BS_Line::DoesIntersectProperly(a, b, VS, VE)) return false;
+ if (Line::DoesIntersectProperly(a, b, VS, VE)) return false;
// If one of the two line items is on the edge and the other is to the right of the edge,
// the line is not completely outside the polygon
- if (BS_Line::IsOnLineStrict(VS, VE, a) && BS_Line::IsVertexLeft(VS, VE, b)) return false;
- if (BS_Line::IsOnLineStrict(VS, VE, b) && BS_Line::IsVertexLeft(VS, VE, a)) return false;
+ if (Line::IsOnLineStrict(VS, VE, a) && Line::IsVertexLeft(VS, VE, b)) return false;
+ if (Line::IsOnLineStrict(VS, VE, b) && Line::IsVertexLeft(VS, VE, a)) return false;
// If one of the lwo line items is on a vertex, the line must not run into the polygon
if ((a == VS) && IsLineInCone(i, b, false)) return false;
if ((b == VS) && IsLineInCone(i, a, false)) return false;
// If the vertex with start and end point is collinear, (a VS) and (b, VS) is not in the polygon
- if (BS_Line::IsOnLine(a, b, VS)) {
+ if (Line::IsOnLine(a, b, VS)) {
if (IsLineInCone(i, a, false)) return false;
if (IsLineInCone(i, b, false)) return false;
}
@@ -352,43 +352,43 @@ bool BS_Polygon::IsLineExterior(const BS_Vertex &a, const BS_Vertex &b) const {
return true;
}
-bool BS_Polygon::IsLineInCone(int StartVertexIndex, const BS_Vertex &EndVertex, bool IncludeEdges) const {
- const BS_Vertex &StartVertex = Vertecies[StartVertexIndex];
- const BS_Vertex &NextVertex = Vertecies[(StartVertexIndex + 1) % VertexCount];
- const BS_Vertex &PrevVertex = Vertecies[(StartVertexIndex + VertexCount - 1) % VertexCount];
+bool Polygon::IsLineInCone(int StartVertexIndex, const Vertex &EndVertex, bool IncludeEdges) const {
+ const Vertex &StartVertex = Vertecies[StartVertexIndex];
+ const Vertex &NextVertex = Vertecies[(StartVertexIndex + 1) % VertexCount];
+ const Vertex &PrevVertex = Vertecies[(StartVertexIndex + VertexCount - 1) % VertexCount];
- if (BS_Line::IsVertexLeftOn(PrevVertex, StartVertex, NextVertex)) {
+ if (Line::IsVertexLeftOn(PrevVertex, StartVertex, NextVertex)) {
if (IncludeEdges)
- return BS_Line::IsVertexLeftOn(EndVertex, StartVertex, NextVertex) &&
- BS_Line::IsVertexLeftOn(StartVertex, EndVertex, PrevVertex);
+ return Line::IsVertexLeftOn(EndVertex, StartVertex, NextVertex) &&
+ Line::IsVertexLeftOn(StartVertex, EndVertex, PrevVertex);
else
- return BS_Line::IsVertexLeft(EndVertex, StartVertex, NextVertex) &&
- BS_Line::IsVertexLeft(StartVertex, EndVertex, PrevVertex);
+ return Line::IsVertexLeft(EndVertex, StartVertex, NextVertex) &&
+ Line::IsVertexLeft(StartVertex, EndVertex, PrevVertex);
} else {
if (IncludeEdges)
- return !(BS_Line::IsVertexLeft(EndVertex, StartVertex, PrevVertex) &&
- BS_Line::IsVertexLeft(StartVertex, EndVertex, NextVertex));
+ return !(Line::IsVertexLeft(EndVertex, StartVertex, PrevVertex) &&
+ Line::IsVertexLeft(StartVertex, EndVertex, NextVertex));
else
- return !(BS_Line::IsVertexLeftOn(EndVertex, StartVertex, PrevVertex) &&
- BS_Line::IsVertexLeftOn(StartVertex, EndVertex, NextVertex));
+ return !(Line::IsVertexLeftOn(EndVertex, StartVertex, PrevVertex) &&
+ Line::IsVertexLeftOn(StartVertex, EndVertex, NextVertex));
}
}
// Point-Polygon Tests
// -------------------
-bool BS_Polygon::IsPointInPolygon(int X, int Y, bool BorderBelongsToPolygon) const {
- return IsPointInPolygon(BS_Vertex(X, Y), BorderBelongsToPolygon);
+bool Polygon::IsPointInPolygon(int X, int Y, bool BorderBelongsToPolygon) const {
+ return IsPointInPolygon(Vertex(X, Y), BorderBelongsToPolygon);
}
-bool BS_Polygon::IsPointInPolygon(const BS_Vertex &Point, bool EdgesBelongToPolygon) const {
+bool Polygon::IsPointInPolygon(const Vertex &Point, bool EdgesBelongToPolygon) const {
int Rcross = 0; // Number of right-side overlaps
int Lcross = 0; // Number of left-side overlaps
// Each edge is checked whether it cuts the outgoing stream from the point
for (int i = 0; i < VertexCount; i++) {
- const BS_Vertex &EdgeStart = Vertecies[i];
- const BS_Vertex &EdgeEnd = Vertecies[(i + 1) % VertexCount];
+ const Vertex &EdgeStart = Vertecies[i];
+ const Vertex &EdgeEnd = Vertecies[(i + 1) % VertexCount];
// A vertex is a point? Then it lies on one edge of the polygon
if (Point == EdgeStart) return EdgesBelongToPolygon;
@@ -414,7 +414,7 @@ bool BS_Polygon::IsPointInPolygon(const BS_Vertex &Point, bool EdgesBelongToPoly
else return false;
}
-bool BS_Polygon::Persist(BS_OutputPersistenceBlock &Writer) {
+bool Polygon::Persist(BS_OutputPersistenceBlock &Writer) {
Writer.Write(VertexCount);
for (int i = 0; i < VertexCount; ++i) {
Writer.Write(Vertecies[i].X);
@@ -424,16 +424,16 @@ bool BS_Polygon::Persist(BS_OutputPersistenceBlock &Writer) {
return true;
}
-bool BS_Polygon::Unpersist(BS_InputPersistenceBlock &Reader) {
+bool Polygon::Unpersist(BS_InputPersistenceBlock &Reader) {
int StoredVertexCount;
Reader.Read(StoredVertexCount);
- Common::Array<BS_Vertex> StoredVertecies;
+ Common::Array<Vertex> StoredVertecies;
for (int i = 0; i < StoredVertexCount; ++i) {
int x, y;
Reader.Read(x);
Reader.Read(y);
- StoredVertecies.push_back(BS_Vertex(x, y));
+ StoredVertecies.push_back(Vertex(x, y));
}
Init(StoredVertexCount, &StoredVertecies[0]);
@@ -444,11 +444,11 @@ bool BS_Polygon::Unpersist(BS_InputPersistenceBlock &Reader) {
// Main Focus
// ----------
-BS_Vertex BS_Polygon::GetCentroid() const {
+Vertex Polygon::GetCentroid() const {
return m_Centroid;
}
-BS_Vertex BS_Polygon::ComputeCentroid() const {
+Vertex Polygon::ComputeCentroid() const {
// Area of the polygon is calculated
int DoubleArea = 0;
for (int i = 0; i < VertexCount; ++i) {
@@ -456,10 +456,10 @@ BS_Vertex BS_Polygon::ComputeCentroid() const {
}
// Avoid division by zero in the next step
- if (DoubleArea == 0) return BS_Vertex();
+ if (DoubleArea == 0) return Vertex();
// Calculate centroid
- BS_Vertex Centroid;
+ Vertex Centroid;
for (int i = 0; i < VertexCount; ++i) {
int Area = Vertecies[i].X * Vertecies[i + 1].Y - Vertecies[i + 1].X * Vertecies[i].Y;
Centroid.X += (Vertecies[i].X + Vertecies[i + 1].X) * Area;
diff --git a/engines/sword25/math/polygon.h b/engines/sword25/math/polygon.h
index 1621efb645..bb0f2d774f 100644
--- a/engines/sword25/math/polygon.h
+++ b/engines/sword25/math/polygon.h
@@ -46,29 +46,29 @@ namespace Sword25 {
// Forward Declarations
// -----------------------------------------------------------------------------
-class BS_Vertex;
+class Vertex;
/**
@brief Eine Polygonklasse.
*/
-class BS_Polygon : public BS_Persistable {
+class Polygon : public BS_Persistable {
public:
/**
* Creates an object of type #BS_Polygon, containing 0 Vertecies.
*
* With the method Init(), Vertices can be added in later
*/
- BS_Polygon();
+ Polygon();
/**
* Copy constructor
*/
- BS_Polygon(const BS_Polygon &Other);
+ Polygon(const Polygon &Other);
/**
* Creates a polygon using persisted data
*/
- BS_Polygon(BS_InputPersistenceBlock &Reader);
+ Polygon(BS_InputPersistenceBlock &Reader);
/**
* Creaes an object of type #BS_Polygon, and assigns Vertices to it
@@ -77,12 +77,12 @@ public:
* @remark The Vertecies that define a polygon must not have any self-intersections.
* If the polygon does have self-intersections, then an empty polygon object is created.
*/
- BS_Polygon(int VertexCount, const BS_Vertex *Vertecies);
+ Polygon(int VertexCount, const Vertex *Vertecies);
/**
* Deletes the BS_Polygon object
*/
- virtual ~BS_Polygon();
+ virtual ~Polygon();
/**
* Initialises the BS_Polygon with a list of Vertecies.
@@ -95,7 +95,7 @@ public:
* @return Returns false if the Vertecies have self-intersections. In this case,
* the object is not initialised.
*/
- bool Init(int VertexCount, const BS_Vertex *Vertecies);
+ bool Init(int VertexCount, const Vertex *Vertecies);
//
// ** Exploratory methods **
@@ -137,7 +137,7 @@ public:
* @param BorderBelongsToPolygon Specifies whether the edge of the polygon should be considered
* @return Returns true if the point is inside the polygon, false if it is outside.
*/
- bool IsPointInPolygon(const BS_Vertex &Vertex, bool BorderBelongsToPolygon = true) const;
+ bool IsPointInPolygon(const Vertex &Vertex, bool BorderBelongsToPolygon = true) const;
/**
* Checks whether a point is inside the polygon
@@ -151,14 +151,14 @@ public:
/**
* Returns the focus/centroid of the polygon
*/
- BS_Vertex GetCentroid() const;
+ Vertex GetCentroid() const;
// Edge belongs to the polygon
// Polygon must be CW
- bool IsLineInterior(const BS_Vertex &a, const BS_Vertex &b) const;
+ bool IsLineInterior(const Vertex &a, const Vertex &b) const;
// Edge does not belong to the polygon
// Polygon must be CW
- bool IsLineExterior(const BS_Vertex &a, const BS_Vertex &b) const;
+ bool IsLineExterior(const Vertex &a, const Vertex &b) const;
//
// Manipulation methods
@@ -183,7 +183,7 @@ public:
* Moves the polygon.
* @param Delta The vertex around the polygon to be moved.
*/
- void operator+=(const BS_Vertex &Delta);
+ void operator+=(const Vertex &Delta);
//
//------------------
@@ -192,7 +192,7 @@ public:
/// Specifies the number of Vertecies in the Vertecies array.
int VertexCount;
/// COntains the Vertecies of the polygon
- BS_Vertex *Vertecies;
+ Vertex *Vertecies;
virtual bool Persist(BS_OutputPersistenceBlock &Writer);
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
@@ -200,12 +200,12 @@ public:
private:
bool m_IsCW;
bool m_IsConvex;
- BS_Vertex m_Centroid;
+ Vertex m_Centroid;
/**
* Computes the centroid of the polygon.
*/
- BS_Vertex ComputeCentroid() const;
+ Vertex ComputeCentroid() const;
/**
* Determines how the Vertecies of the polygon are arranged.
@@ -228,7 +228,7 @@ private:
* @return Returns the cross-product of the three vertecies
* @todo This method would be better as a method of the BS_Vertex class
*/
- int CrossProduct(const BS_Vertex &V1, const BS_Vertex &V2, const BS_Vertex &V3) const;
+ int CrossProduct(const Vertex &V1, const Vertex &V2, const Vertex &V3) const;
/**
* Computes the scalar product of two vectors spanning three vertecies
@@ -241,7 +241,7 @@ private:
* @return Returns the dot product of the three Vertecies.
* @todo This method would be better as a method of the BS_Vertex class
*/
- int DotProduct(const BS_Vertex &V1, const BS_Vertex &V2, const BS_Vertex &V3) const;
+ int DotProduct(const Vertex &V1, const Vertex &V2, const Vertex &V3) const;
/**
* Checks whether the polygon is self-intersecting
@@ -258,7 +258,7 @@ private:
*/
int FindLRVertexIndex() const;
- bool IsLineInCone(int StartVertexIndex, const BS_Vertex &EndVertex, bool IncludeEdges) const;
+ bool IsLineInCone(int StartVertexIndex, const Vertex &EndVertex, bool IncludeEdges) const;
};
} // End of namespace Sword25
diff --git a/engines/sword25/math/rect.h b/engines/sword25/math/rect.h
index e97feefe41..c08169e86e 100644
--- a/engines/sword25/math/rect.h
+++ b/engines/sword25/math/rect.h
@@ -98,7 +98,7 @@ public:
return isValidRect();
}
- bool IsPointInRect(const BS_Vertex &Vertex) const {
+ bool IsPointInRect(const Vertex &Vertex) const {
return contains(Vertex.X, Vertex.Y);
}
diff --git a/engines/sword25/math/region.cpp b/engines/sword25/math/region.cpp
index b967d001c5..0fd9af861d 100644
--- a/engines/sword25/math/region.cpp
+++ b/engines/sword25/math/region.cpp
@@ -46,69 +46,69 @@ namespace Sword25 {
// Constructor / Destructor
// ------------------------
-BS_Region::BS_Region() : m_Valid(false), m_Type(RT_REGION) {
- BS_RegionRegistry::GetInstance().RegisterObject(this);
+Region::Region() : m_Valid(false), m_Type(RT_REGION) {
+ RegionRegistry::GetInstance().RegisterObject(this);
}
// -----------------------------------------------------------------------------
-BS_Region::BS_Region(BS_InputPersistenceBlock &Reader, unsigned int Handle) : m_Valid(false), m_Type(RT_REGION) {
- BS_RegionRegistry::GetInstance().RegisterObject(this, Handle);
+Region::Region(BS_InputPersistenceBlock &Reader, unsigned int Handle) : m_Valid(false), m_Type(RT_REGION) {
+ RegionRegistry::GetInstance().RegisterObject(this, Handle);
Unpersist(Reader);
}
// -----------------------------------------------------------------------------
-unsigned int BS_Region::Create(REGION_TYPE Type) {
- BS_Region *RegionPtr = NULL;
+unsigned int Region::Create(REGION_TYPE Type) {
+ Region *RegionPtr = NULL;
switch (Type) {
case RT_REGION:
- RegionPtr = new BS_Region();
+ RegionPtr = new Region();
break;
case RT_WALKREGION:
- RegionPtr = new BS_WalkRegion();
+ RegionPtr = new WalkRegion();
break;
default:
BS_ASSERT(true);
}
- return BS_RegionRegistry::GetInstance().ResolvePtr(RegionPtr);
+ return RegionRegistry::GetInstance().ResolvePtr(RegionPtr);
}
// -----------------------------------------------------------------------------
-unsigned int BS_Region::Create(BS_InputPersistenceBlock &Reader, unsigned int Handle) {
+unsigned int Region::Create(BS_InputPersistenceBlock &Reader, unsigned int Handle) {
// Read type
unsigned int Type;
Reader.Read(Type);
// Depending on the type, create a new BS_Region or BS_WalkRegion object
- BS_Region *RegionPtr = NULL;
+ Region *RegionPtr = NULL;
if (Type == RT_REGION) {
- RegionPtr = new BS_Region(Reader, Handle);
+ RegionPtr = new Region(Reader, Handle);
} else if (Type == RT_WALKREGION) {
- RegionPtr = new BS_WalkRegion(Reader, Handle);
+ RegionPtr = new WalkRegion(Reader, Handle);
} else {
BS_ASSERT(false);
}
- return BS_RegionRegistry::GetInstance().ResolvePtr(RegionPtr);
+ return RegionRegistry::GetInstance().ResolvePtr(RegionPtr);
}
// -----------------------------------------------------------------------------
-BS_Region::~BS_Region() {
- BS_RegionRegistry::GetInstance().DeregisterObject(this);
+Region::~Region() {
+ RegionRegistry::GetInstance().DeregisterObject(this);
}
// -----------------------------------------------------------------------------
-bool BS_Region::Init(const BS_Polygon &Contour, const Common::Array<BS_Polygon> *pHoles) {
+bool Region::Init(const Polygon &Contour, const Common::Array<Polygon> *pHoles) {
// Reset object state
m_Valid = false;
- m_Position = BS_Vertex(0, 0);
+ m_Position = Vertex(0, 0);
m_Polygons.clear();
// Reserve sufficient space for countour and holes in the polygon list
@@ -118,7 +118,7 @@ bool BS_Region::Init(const BS_Polygon &Contour, const Common::Array<BS_Polygon>
m_Polygons.reserve(1);
// The first polygon will be the contour
- m_Polygons.push_back(BS_Polygon());
+ m_Polygons.push_back(Polygon());
m_Polygons[0].Init(Contour.VertexCount, Contour.Vertecies);
// Make sure that the Vertecies in the Contour are arranged in a clockwise direction
m_Polygons[0].EnsureCWOrder();
@@ -126,7 +126,7 @@ bool BS_Region::Init(const BS_Polygon &Contour, const Common::Array<BS_Polygon>
// Place the hole polygons in the following positions
if (pHoles) {
for (unsigned int i = 0; i < pHoles->size(); ++i) {
- m_Polygons.push_back(BS_Polygon());
+ m_Polygons.push_back(Polygon());
m_Polygons[i + 1].Init((*pHoles)[i].VertexCount, (*pHoles)[i].Vertecies);
m_Polygons[i + 1].EnsureCWOrder();
}
@@ -142,7 +142,7 @@ bool BS_Region::Init(const BS_Polygon &Contour, const Common::Array<BS_Polygon>
// -----------------------------------------------------------------------------
-void BS_Region::UpdateBoundingBox() {
+void Region::UpdateBoundingBox() {
if (m_Polygons[0].VertexCount) {
int MinX = m_Polygons[0].Vertecies[0].X;
int MaxX = m_Polygons[0].Vertecies[0].X;
@@ -163,12 +163,12 @@ void BS_Region::UpdateBoundingBox() {
// Position Changes
// ----------------
-void BS_Region::SetPos(int X, int Y) {
+void Region::SetPos(int X, int Y) {
// Calculate the difference between the old and new position
- BS_Vertex Delta(X - m_Position.X, Y - m_Position.Y);
+ Vertex Delta(X - m_Position.X, Y - m_Position.Y);
// Save the new position
- m_Position = BS_Vertex(X, Y);
+ m_Position = Vertex(X, Y);
// Move all the vertecies
for (unsigned int i = 0; i < m_Polygons.size(); ++i) {
@@ -181,20 +181,20 @@ void BS_Region::SetPos(int X, int Y) {
// -----------------------------------------------------------------------------
-void BS_Region::SetPosX(int X) {
+void Region::SetPosX(int X) {
SetPos(X, m_Position.Y);
}
// -----------------------------------------------------------------------------
-void BS_Region::SetPosY(int Y) {
+void Region::SetPosY(int Y) {
SetPos(m_Position.X, Y);
}
// Point-Region Tests
// ------------------
-bool BS_Region::IsPointInRegion(int X, int Y) const {
+bool Region::IsPointInRegion(int X, int Y) const {
// Test whether the point is in the bounding box
if (m_BoundingBox.IsPointInRect(X, Y)) {
// Test whether the point is in the contour
@@ -214,13 +214,13 @@ bool BS_Region::IsPointInRegion(int X, int Y) const {
// -----------------------------------------------------------------------------
-bool BS_Region::IsPointInRegion(const BS_Vertex &Vertex) const {
+bool Region::IsPointInRegion(const Vertex &Vertex) const {
return IsPointInRegion(Vertex.X, Vertex.Y);
}
// -----------------------------------------------------------------------------
-BS_Vertex BS_Region::FindClosestRegionPoint(const BS_Vertex &Point) const {
+Vertex Region::FindClosestRegionPoint(const Vertex &Point) const {
// Determine whether the point is inside a hole. If that is the case, the closest
// point on the edge of the hole is determined
int PolygonIdx = 0;
@@ -233,18 +233,18 @@ BS_Vertex BS_Region::FindClosestRegionPoint(const BS_Vertex &Point) const {
}
}
- const BS_Polygon &Polygon = m_Polygons[PolygonIdx];
+ const Polygon &Polygon = m_Polygons[PolygonIdx];
BS_ASSERT(Polygon.VertexCount > 1);
// For each line of the polygon, calculate the point that is cloest to the given point
// The point of this set with the smallest distance to the given point is the result.
- BS_Vertex ClosestVertex = FindClosestPointOnLine(Polygon.Vertecies[0], Polygon.Vertecies[1], Point);
+ Vertex ClosestVertex = FindClosestPointOnLine(Polygon.Vertecies[0], Polygon.Vertecies[1], Point);
int ClosestVertexDistance2 = ClosestVertex.Distance(Point);
for (int i = 1; i < Polygon.VertexCount; ++i) {
int j = (i + 1) % Polygon.VertexCount;
- BS_Vertex CurVertex = FindClosestPointOnLine(Polygon.Vertecies[i], Polygon.Vertecies[j], Point);
+ Vertex CurVertex = FindClosestPointOnLine(Polygon.Vertecies[i], Polygon.Vertecies[j], Point);
if (CurVertex.Distance(Point) < ClosestVertexDistance2) {
ClosestVertex = CurVertex;
ClosestVertexDistance2 = CurVertex.Distance(Point);
@@ -258,22 +258,22 @@ BS_Vertex BS_Region::FindClosestRegionPoint(const BS_Vertex &Point) const {
else {
// Try to construct a point within the region - 8 points are tested in the immediate vacinity
// of the point
- if (IsPointInRegion(ClosestVertex + BS_Vertex(-2, -2)))
- return ClosestVertex + BS_Vertex(-2, -2);
- else if (IsPointInRegion(ClosestVertex + BS_Vertex(0, -2)))
- return ClosestVertex + BS_Vertex(0, -2);
- else if (IsPointInRegion(ClosestVertex + BS_Vertex(2, -2)))
- return ClosestVertex + BS_Vertex(2, -2);
- else if (IsPointInRegion(ClosestVertex + BS_Vertex(-2, 0)))
- return ClosestVertex + BS_Vertex(-2, 0);
- else if (IsPointInRegion(ClosestVertex + BS_Vertex(0, 2)))
- return ClosestVertex + BS_Vertex(0, 2);
- else if (IsPointInRegion(ClosestVertex + BS_Vertex(-2, 2)))
- return ClosestVertex + BS_Vertex(-2, 2);
- else if (IsPointInRegion(ClosestVertex + BS_Vertex(-2, 0)))
- return ClosestVertex + BS_Vertex(2, 2);
- else if (IsPointInRegion(ClosestVertex + BS_Vertex(2, 2)))
- return ClosestVertex + BS_Vertex(2, 2);
+ if (IsPointInRegion(ClosestVertex + Vertex(-2, -2)))
+ return ClosestVertex + Vertex(-2, -2);
+ else if (IsPointInRegion(ClosestVertex + Vertex(0, -2)))
+ return ClosestVertex + Vertex(0, -2);
+ else if (IsPointInRegion(ClosestVertex + Vertex(2, -2)))
+ return ClosestVertex + Vertex(2, -2);
+ else if (IsPointInRegion(ClosestVertex + Vertex(-2, 0)))
+ return ClosestVertex + Vertex(-2, 0);
+ else if (IsPointInRegion(ClosestVertex + Vertex(0, 2)))
+ return ClosestVertex + Vertex(0, 2);
+ else if (IsPointInRegion(ClosestVertex + Vertex(-2, 2)))
+ return ClosestVertex + Vertex(-2, 2);
+ else if (IsPointInRegion(ClosestVertex + Vertex(-2, 0)))
+ return ClosestVertex + Vertex(2, 2);
+ else if (IsPointInRegion(ClosestVertex + Vertex(2, 2)))
+ return ClosestVertex + Vertex(2, 2);
// If no point could be found that way that lies within the region, find the next point
ClosestVertex = Polygon.Vertecies[0];
@@ -295,7 +295,7 @@ BS_Vertex BS_Region::FindClosestRegionPoint(const BS_Vertex &Point) const {
// -----------------------------------------------------------------------------
-BS_Vertex BS_Region::FindClosestPointOnLine(const BS_Vertex &LineStart, const BS_Vertex &LineEnd, const BS_Vertex Point) const {
+Vertex Region::FindClosestPointOnLine(const Vertex &LineStart, const Vertex &LineEnd, const Vertex Point) const {
float Vector1X = static_cast<float>(Point.X - LineStart.X);
float Vector1Y = static_cast<float>(Point.Y - LineStart.Y);
float Vector2X = static_cast<float>(LineEnd.X - LineStart.X);
@@ -310,7 +310,7 @@ BS_Vertex BS_Region::FindClosestPointOnLine(const BS_Vertex &LineStart, const BS
if (Dot <= 0) return LineStart;
if (Dot >= Distance) return LineEnd;
- BS_Vertex Vector3(static_cast<int>(Vector2X * Dot + 0.5f), static_cast<int>(Vector2Y * Dot + 0.5f));
+ Vertex Vector3(static_cast<int>(Vector2X * Dot + 0.5f), static_cast<int>(Vector2Y * Dot + 0.5f));
return LineStart + Vector3;
}
@@ -318,11 +318,11 @@ BS_Vertex BS_Region::FindClosestPointOnLine(const BS_Vertex &LineStart, const BS
// Line of Sight
// -----------------------------------------------------------------------------
-bool BS_Region::IsLineOfSight(const BS_Vertex &a, const BS_Vertex &b) const {
+bool Region::IsLineOfSight(const Vertex &a, const Vertex &b) const {
BS_ASSERT(m_Polygons.size());
// The line must be within the contour polygon, and outside of any hole polygons
- Common::Array<BS_Polygon>::const_iterator iter = m_Polygons.begin();
+ Common::Array<Polygon>::const_iterator iter = m_Polygons.begin();
if (!(*iter).IsLineInterior(a, b)) return false;
for (iter++; iter != m_Polygons.end(); iter++)
if (!(*iter).IsLineExterior(a, b)) return false;
@@ -334,7 +334,7 @@ bool BS_Region::IsLineOfSight(const BS_Vertex &a, const BS_Vertex &b) const {
// Persistence
// -----------------------------------------------------------------------------
-bool BS_Region::Persist(BS_OutputPersistenceBlock &Writer) {
+bool Region::Persist(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
Writer.Write(static_cast<unsigned int>(m_Type));
@@ -343,7 +343,7 @@ bool BS_Region::Persist(BS_OutputPersistenceBlock &Writer) {
Writer.Write(m_Position.Y);
Writer.Write(m_Polygons.size());
- Common::Array<BS_Polygon>::iterator It = m_Polygons.begin();
+ Common::Array<Polygon>::iterator It = m_Polygons.begin();
while (It != m_Polygons.end()) {
Result &= It->Persist(Writer);
++It;
@@ -359,7 +359,7 @@ bool BS_Region::Persist(BS_OutputPersistenceBlock &Writer) {
// -----------------------------------------------------------------------------
-bool BS_Region::Unpersist(BS_InputPersistenceBlock &Reader) {
+bool Region::Unpersist(BS_InputPersistenceBlock &Reader) {
Reader.Read(m_Valid);
Reader.Read(m_Position.X);
Reader.Read(m_Position.Y);
@@ -368,7 +368,7 @@ bool BS_Region::Unpersist(BS_InputPersistenceBlock &Reader) {
unsigned int PolygonCount;
Reader.Read(PolygonCount);
for (unsigned int i = 0; i < PolygonCount; ++i) {
- m_Polygons.push_back(BS_Polygon(Reader));
+ m_Polygons.push_back(Polygon(Reader));
}
Reader.Read(m_BoundingBox.left);
@@ -381,11 +381,11 @@ bool BS_Region::Unpersist(BS_InputPersistenceBlock &Reader) {
// -----------------------------------------------------------------------------
-BS_Vertex BS_Region::GetCentroid() const {
+Vertex Region::GetCentroid() const {
if (m_Polygons.size() > 0)
return m_Polygons[0].GetCentroid();
return
- BS_Vertex();
+ Vertex();
}
} // End of namespace Sword25
diff --git a/engines/sword25/math/region.h b/engines/sword25/math/region.h
index e3718dd1c9..2afc9e9a45 100644
--- a/engines/sword25/math/region.h
+++ b/engines/sword25/math/region.h
@@ -52,7 +52,7 @@ namespace Sword25 {
* arranged in a clockwise direction, so that the polygon working algorithms will
* work properly.
*/
-class BS_Region : public BS_Persistable {
+class Region : public BS_Persistable {
protected:
/**
* Creates a new BS_Region object
@@ -60,9 +60,9 @@ protected:
* After creation the object is invaild (IsValid() return false), but a call can
* be made later on to Init() to set up the region into a valid state.
*/
- BS_Region();
+ Region();
- BS_Region(BS_InputPersistenceBlock &Reader, unsigned int Handle);
+ Region(BS_InputPersistenceBlock &Reader, unsigned int Handle);
public:
enum REGION_TYPE {
@@ -73,7 +73,7 @@ public:
static unsigned int Create(REGION_TYPE Type);
static unsigned int Create(BS_InputPersistenceBlock &Reader, unsigned int Handle = 0);
- virtual ~BS_Region();
+ virtual ~Region();
/**
* Initialises a BS_Region object
@@ -83,7 +83,7 @@ public:
* @return Returns true if the initialisation was successful, otherwise false.
* @remark If the region was already initialised, the old state will be deleted.
*/
- virtual bool Init(const BS_Polygon &Contour, const Common::Array<BS_Polygon> *pHoles = NULL);
+ virtual bool Init(const Polygon &Contour, const Common::Array<Polygon> *pHoles = NULL);
//
// Exploratory Methods
@@ -101,7 +101,7 @@ public:
/**
* Returns the position of the region
*/
- const BS_Vertex &GetPosition() const {
+ const Vertex &GetPosition() const {
return m_Position;
}
@@ -124,7 +124,7 @@ public:
* @param Vertex A verex with the co-ordinates of the test point
* @return Returns true if the point is within the region, otherwise false.
*/
- bool IsPointInRegion(const BS_Vertex &Vertex) const;
+ bool IsPointInRegion(const Vertex &Vertex) const;
/**
* Indicates whether a point is inside the region
@@ -137,7 +137,7 @@ public:
/**
* Returns the countour of the region
*/
- const BS_Polygon &GetContour() const {
+ const Polygon &GetContour() const {
return m_Polygons[0];
}
@@ -154,7 +154,7 @@ public:
* The index must be between 0 and GetHoleCount() - 1.
* @return Returns the desired hole polygon
*/
- inline const BS_Polygon &GetHole(unsigned int i) const;
+ inline const Polygon &GetHole(unsigned int i) const;
/**
* For a point outside the region, finds the closest point inside the region
@@ -164,14 +164,14 @@ public:
* One should not therefore rely on the fact that there is really no point in
* the region which is closer to the given point.
*/
- BS_Vertex FindClosestRegionPoint(const BS_Vertex &Point) const;
+ Vertex FindClosestRegionPoint(const Vertex &Point) const;
/**
* Returns the centroid for the region
*/
- BS_Vertex GetCentroid() const;
+ Vertex GetCentroid() const;
- bool IsLineOfSight(const BS_Vertex &a, const BS_Vertex &b) const;
+ bool IsLineOfSight(const Vertex &a, const Vertex &b) const;
//
// Manipulation Methods
@@ -209,10 +209,10 @@ protected:
/// This variable indicates whether the current object state is valid
bool m_Valid;
/// This vertex is the position of the region
- BS_Vertex m_Position;
+ Vertex m_Position;
/// This array contains all the polygons that define the region. The first element of
// the array is the contour, all others are the holes
- Common::Array<BS_Polygon> m_Polygons;
+ Common::Array<Polygon> m_Polygons;
/// The bounding box for the region
BS_Rect m_BoundingBox;
@@ -228,7 +228,7 @@ protected:
* @param Point The point to be compared against
* @return Returns the point on the line which is cloest to the passed point.
*/
- BS_Vertex FindClosestPointOnLine(const BS_Vertex &LineStart, const BS_Vertex &LineEnd, const BS_Vertex Point) const;
+ Vertex FindClosestPointOnLine(const Vertex &LineStart, const Vertex &LineEnd, const Vertex Point) const;
};
@@ -236,7 +236,7 @@ protected:
// Inlines
// -----------------------------------------------------------------------------
-inline const BS_Polygon &BS_Region::GetHole(unsigned int i) const {
+inline const Polygon &Region::GetHole(unsigned int i) const {
BS_ASSERT(i < m_Polygons.size() - 1);
return m_Polygons[i + 1];
}
diff --git a/engines/sword25/math/regionregistry.cpp b/engines/sword25/math/regionregistry.cpp
index b03d1c1152..55ace78ab2 100644
--- a/engines/sword25/math/regionregistry.cpp
+++ b/engines/sword25/math/regionregistry.cpp
@@ -53,23 +53,23 @@ namespace Sword25 {
// Implementation
// -----------------------------------------------------------------------------
-Common::SharedPtr<BS_RegionRegistry> BS_RegionRegistry::m_InstancePtr;
+Common::SharedPtr<RegionRegistry> RegionRegistry::m_InstancePtr;
// -----------------------------------------------------------------------------
-void BS_RegionRegistry::LogErrorLn(const char *Message) const {
+void RegionRegistry::LogErrorLn(const char *Message) const {
BS_LOG_ERRORLN(Message);
}
// -----------------------------------------------------------------------------
-void BS_RegionRegistry::LogWarningLn(const char *Message) const {
+void RegionRegistry::LogWarningLn(const char *Message) const {
BS_LOG_WARNINGLN(Message);
}
// -----------------------------------------------------------------------------
-bool BS_RegionRegistry::Persist(BS_OutputPersistenceBlock &Writer) {
+bool RegionRegistry::Persist(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
// Write out the next handle
@@ -95,7 +95,7 @@ bool BS_RegionRegistry::Persist(BS_OutputPersistenceBlock &Writer) {
// -----------------------------------------------------------------------------
-bool BS_RegionRegistry::Unpersist(BS_InputPersistenceBlock &Reader) {
+bool RegionRegistry::Unpersist(BS_InputPersistenceBlock &Reader) {
bool Result = true;
// Read in the next handle
@@ -116,7 +116,7 @@ bool BS_RegionRegistry::Unpersist(BS_InputPersistenceBlock &Reader) {
Reader.Read(Handle);
// BS_Region restore
- Result &= BS_Region::Create(Reader, Handle) != 0;
+ Result &= Region::Create(Reader, Handle) != 0;
}
return Reader.IsGood() && Result;
diff --git a/engines/sword25/math/regionregistry.h b/engines/sword25/math/regionregistry.h
index 9600dbbdc4..13642c965c 100644
--- a/engines/sword25/math/regionregistry.h
+++ b/engines/sword25/math/regionregistry.h
@@ -50,16 +50,16 @@ namespace Sword25 {
// Forward Declarations
// -----------------------------------------------------------------------------
-class BS_Region;
+class Region;
// -----------------------------------------------------------------------------
// Class definitions
// -----------------------------------------------------------------------------
-class BS_RegionRegistry : public BS_ObjectRegistry<BS_Region>, public BS_Persistable {
+class RegionRegistry : public BS_ObjectRegistry<Region>, public BS_Persistable {
public:
- static BS_RegionRegistry &GetInstance() {
- if (!m_InstancePtr.get()) m_InstancePtr = Common::SharedPtr<BS_RegionRegistry>(new BS_RegionRegistry());
+ static RegionRegistry &GetInstance() {
+ if (!m_InstancePtr.get()) m_InstancePtr = Common::SharedPtr<RegionRegistry>(new RegionRegistry());
return *m_InstancePtr.get();
}
@@ -70,7 +70,7 @@ private:
virtual void LogErrorLn(const char *Message) const;
virtual void LogWarningLn(const char *Message) const;
- static Common::SharedPtr<BS_RegionRegistry> m_InstancePtr;
+ static Common::SharedPtr<RegionRegistry> m_InstancePtr;
};
} // End of namespace Sword25
diff --git a/engines/sword25/math/vertex.cpp b/engines/sword25/math/vertex.cpp
index 575618dbb9..058f1c5cd1 100644
--- a/engines/sword25/math/vertex.cpp
+++ b/engines/sword25/math/vertex.cpp
@@ -48,7 +48,7 @@ extern "C"
namespace Sword25 {
-BS_Vertex &BS_Vertex::LuaVertexToVertex(lua_State *L, int StackIndex, BS_Vertex &Vertex) {
+Vertex &Vertex::LuaVertexToVertex(lua_State *L, int StackIndex, Vertex &vertex) {
#ifdef DEBUG
int __startStackDepth = lua_gettop(L);
#endif
@@ -60,37 +60,37 @@ BS_Vertex &BS_Vertex::LuaVertexToVertex(lua_State *L, int StackIndex, BS_Vertex
lua_pushstring(L, "X");
lua_gettable(L, StackIndex);
if (!lua_isnumber(L, -1)) luaL_argcheck(L, 0, StackIndex, "the X component has to be a number");
- Vertex.X = static_cast<int>(lua_tonumber(L, -1));
+ vertex.X = static_cast<int>(lua_tonumber(L, -1));
lua_pop(L, 1);
// Read Y Component
lua_pushstring(L, "Y");
lua_gettable(L, StackIndex);
if (!lua_isnumber(L, -1)) luaL_argcheck(L, 0, StackIndex, "the Y component has to be a number");
- Vertex.Y = static_cast<int>(lua_tonumber(L, -1));
+ vertex.Y = static_cast<int>(lua_tonumber(L, -1));
lua_pop(L, 1);
#ifdef DEBUG
BS_ASSERT(__startStackDepth == lua_gettop(L));
#endif
- return Vertex;
+ return vertex;
}
// -----------------------------------------------------------------------------
-void BS_Vertex::VertexToLuaVertex(lua_State *L, const BS_Vertex &Vertex) {
+void Vertex::VertexToLuaVertex(lua_State *L, const Vertex &vertex) {
// Create New Table
lua_newtable(L);
// X value is written to table
lua_pushstring(L, "X");
- lua_pushnumber(L, Vertex.X);
+ lua_pushnumber(L, vertex.X);
lua_settable(L, -3);
// Y value is written to table
lua_pushstring(L, "Y");
- lua_pushnumber(L, Vertex.Y);
+ lua_pushnumber(L, vertex.Y);
lua_settable(L, -3);
}
diff --git a/engines/sword25/math/vertex.h b/engines/sword25/math/vertex.h
index b39de82fac..22fc1e49e4 100644
--- a/engines/sword25/math/vertex.h
+++ b/engines/sword25/math/vertex.h
@@ -60,10 +60,10 @@ namespace Sword25 {
/**
* Defines a 2-D Vertex
*/
-class BS_Vertex {
+class Vertex {
public:
- BS_Vertex() : X(0), Y(0) {};
- BS_Vertex(int X_, int Y_) {
+ Vertex() : X(0), Y(0) {};
+ Vertex(int X_, int Y_) {
this->X = X_;
this->Y = Y_;
}
@@ -74,21 +74,21 @@ public:
/**
* Compares two Vertecies.
*/
- inline bool operator==(const BS_Vertex &rhs) const {
+ inline bool operator==(const Vertex &rhs) const {
if (X == rhs.X && Y == rhs.Y) return true;
return false;
}
/**
* Compares two Vertecies.
*/
- inline bool operator!=(const BS_Vertex &rhs) const {
+ inline bool operator!=(const Vertex &rhs) const {
if (X != rhs.X || Y != rhs.Y) return true;
return false;
}
/**
* Adds a vertex to vertex
*/
- inline void operator+=(const BS_Vertex &Delta) {
+ inline void operator+=(const Vertex &Delta) {
X += Delta.X;
Y += Delta.Y;
}
@@ -96,7 +96,7 @@ public:
/**
* Subtracts a vertex from a vertex
*/
- inline void operator-=(const BS_Vertex &Delta) {
+ inline void operator-=(const Vertex &Delta) {
X -= Delta.X;
Y -= Delta.Y;
}
@@ -104,15 +104,15 @@ public:
/**
* Adds two vertecies
*/
- inline BS_Vertex operator+(const BS_Vertex &Delta) const {
- return BS_Vertex(X + Delta.X, Y + Delta.Y);
+ inline Vertex operator+(const Vertex &Delta) const {
+ return Vertex(X + Delta.X, Y + Delta.Y);
}
/**
* Subtracts two vertecies
*/
- inline BS_Vertex operator-(const BS_Vertex &Delta) const {
- return BS_Vertex(X - Delta.X, Y - Delta.Y);
+ inline Vertex operator-(const Vertex &Delta) const {
+ return Vertex(X - Delta.X, Y - Delta.Y);
}
/**
@@ -122,8 +122,8 @@ public:
* @remark If only distances should be compared, this method should be used because
* it is faster than Distance()
*/
- inline int Distance2(const BS_Vertex &Vertex) const {
- return (X - Vertex.X) * (X - Vertex.X) + (Y - Vertex.Y) * (Y - Vertex.Y);
+ inline int Distance2(const Vertex &vertex) const {
+ return (X - vertex.X) * (X - vertex.X) + (Y - vertex.Y) * (Y - vertex.Y);
}
/**
@@ -132,8 +132,8 @@ public:
* @return Returns the square of the distance between itself and the passed vertex
* @remark If only distances should be compared, Distance2() should be used, since it is faster.
*/
- inline int Distance(const BS_Vertex &Vertex) const {
- return (int)(sqrtf(static_cast<float>(Distance2(Vertex))) + 0.5);
+ inline int Distance(const Vertex &vertex) const {
+ return (int)(sqrtf(static_cast<float>(Distance2(vertex))) + 0.5);
}
/**
@@ -142,8 +142,8 @@ public:
* @param Vertex The second vertex
* @return Returns the cross product of this vertex and the passed vertex.
*/
- inline int ComputeCrossProduct(const BS_Vertex &Vertex) const {
- return X * Vertex.Y - Vertex.X * Y;
+ inline int ComputeCrossProduct(const Vertex &vertex) const {
+ return X * vertex.Y - vertex.X * Y;
}
/**
@@ -151,8 +151,8 @@ public:
* @param Vertex The second vertex
* @return Returns the dot product of this vertex and the passed vertex.
*/
- inline int ComputeDotProduct(const BS_Vertex &Vertex) const {
- return X * Vertex.X + Y * Vertex.Y;
+ inline int ComputeDotProduct(const Vertex &vertex) const {
+ return X * vertex.X + Y * vertex.Y;
}
/**
@@ -160,8 +160,8 @@ public:
* @param Vertex The second vertex
* @return Returns the angle between this vertex and the passed vertex in radians.
*/
- inline float ComputeAngle(const BS_Vertex &Vertex) const {
- return atan2f(static_cast<float>(ComputeCrossProduct(Vertex)), static_cast<float>(ComputeDotProduct(Vertex)));
+ inline float ComputeAngle(const Vertex &vertex) const {
+ return atan2f(static_cast<float>(ComputeCrossProduct(vertex)), static_cast<float>(ComputeDotProduct(vertex)));
}
/**
@@ -171,8 +171,8 @@ public:
return sqrtf(static_cast<float>(X * X + Y * Y));
}
- static BS_Vertex &LuaVertexToVertex(lua_State *L, int StackIndex, BS_Vertex &Vertex);
- static void VertexToLuaVertex(lua_State *L, const BS_Vertex &Vertex);
+ static Vertex &LuaVertexToVertex(lua_State *L, int StackIndex, Vertex &vertex);
+ static void VertexToLuaVertex(lua_State *L, const Vertex &vertex);
};
} // End of namespace Sword25
diff --git a/engines/sword25/math/walkregion.cpp b/engines/sword25/math/walkregion.cpp
index 82ee0bf782..01db9c385b 100644
--- a/engines/sword25/math/walkregion.cpp
+++ b/engines/sword25/math/walkregion.cpp
@@ -52,28 +52,28 @@ static const int infinity = (~(-1));
// Constructor / Destructor
// -----------------------------------------------------------------------------
-BS_WalkRegion::BS_WalkRegion() {
+WalkRegion::WalkRegion() {
m_Type = RT_WALKREGION;
}
// -----------------------------------------------------------------------------
-BS_WalkRegion::BS_WalkRegion(BS_InputPersistenceBlock &Reader, unsigned int Handle) :
- BS_Region(Reader, Handle) {
+WalkRegion::WalkRegion(BS_InputPersistenceBlock &Reader, unsigned int Handle) :
+ Region(Reader, Handle) {
m_Type = RT_WALKREGION;
Unpersist(Reader);
}
// -----------------------------------------------------------------------------
-BS_WalkRegion::~BS_WalkRegion() {
+WalkRegion::~WalkRegion() {
}
// -----------------------------------------------------------------------------
-bool BS_WalkRegion::Init(const BS_Polygon &Contour, const Common::Array<BS_Polygon> *pHoles) {
+bool WalkRegion::Init(const Polygon &Contour, const Common::Array<Polygon> *pHoles) {
// Default initialisation of the region
- if (!BS_Region::Init(Contour, pHoles)) return false;
+ if (!Region::Init(Contour, pHoles)) return false;
// Prepare structures for pathfinding
InitNodeVector();
@@ -85,7 +85,7 @@ bool BS_WalkRegion::Init(const BS_Polygon &Contour, const Common::Array<BS_Polyg
// -----------------------------------------------------------------------------
-bool BS_WalkRegion::QueryPath(BS_Vertex StartPoint, BS_Vertex EndPoint, BS_Path &Path) {
+bool WalkRegion::QueryPath(Vertex StartPoint, Vertex EndPoint, BS_Path &Path) {
BS_ASSERT(Path.empty());
// If the start and finish are identical, no path can be found trivially
@@ -118,14 +118,14 @@ struct DijkstraNode {
bool Chosen;
};
-static void InitDijkstraNodes(DijkstraNode::Container &DijkstraNodes, const BS_Region &Region,
- const BS_Vertex &Start, const Common::Array<BS_Vertex> &Nodes) {
+static void InitDijkstraNodes(DijkstraNode::Container &DijkstraNodes, const Region &Region,
+ const Vertex &Start, const Common::Array<Vertex> &Nodes) {
// Allocate sufficient space in the array
DijkstraNodes.resize(Nodes.size());
// Initialise all the nodes which are visible from the starting node
DijkstraNode::Iter DijkstraIter = DijkstraNodes.begin();
- for (Common::Array<BS_Vertex>::const_iterator NodesIter = Nodes.begin();
+ for (Common::Array<Vertex>::const_iterator NodesIter = Nodes.begin();
NodesIter != Nodes.end(); NodesIter++, DijkstraIter++) {
(*DijkstraIter).ParentIter = DijkstraNodes.end();
if (Region.IsLineOfSight(*NodesIter, Start))(*DijkstraIter).Cost = (*NodesIter).Distance(Start);
@@ -167,11 +167,11 @@ static void RelaxNodes(DijkstraNode::Container &Nodes,
}
}
-static void RelaxEndPoint(const BS_Vertex &CurNodePos,
+static void RelaxEndPoint(const Vertex &CurNodePos,
const DijkstraNode::ConstIter &CurNodeIter,
- const BS_Vertex &EndPointPos,
+ const Vertex &EndPointPos,
DijkstraNode &EndPoint,
- const BS_Region &Region) {
+ const Region &Region) {
if (Region.IsLineOfSight(CurNodePos, EndPointPos)) {
int TotalCost = (*CurNodeIter).Cost + CurNodePos.Distance(EndPointPos);
if (TotalCost < EndPoint.Cost) {
@@ -181,7 +181,7 @@ static void RelaxEndPoint(const BS_Vertex &CurNodePos,
}
}
-bool BS_WalkRegion::FindPath(const BS_Vertex &Start, const BS_Vertex &End, BS_Path &Path) const {
+bool WalkRegion::FindPath(const Vertex &Start, const Vertex &End, BS_Path &Path) const {
// This is an implementation of Dijkstra's algorithm
// Initialise edge node list
@@ -221,7 +221,7 @@ bool BS_WalkRegion::FindPath(const BS_Vertex &Start, const BS_Vertex &End, BS_Pa
// The nodes of the path must be untwisted, as they were extracted in reverse order.
// This step could be saved if the path from end to the beginning was desired
- ReverseArray<BS_Vertex>(Path);
+ ReverseArray<Vertex>(Path);
return true;
}
@@ -238,7 +238,7 @@ bool BS_WalkRegion::FindPath(const BS_Vertex &Start, const BS_Vertex &End, BS_Pa
// -----------------------------------------------------------------------------
-void BS_WalkRegion::InitNodeVector() {
+void WalkRegion::InitNodeVector() {
// Empty the Node list
m_Nodes.clear();
@@ -260,7 +260,7 @@ void BS_WalkRegion::InitNodeVector() {
// -----------------------------------------------------------------------------
-void BS_WalkRegion::ComputeVisibilityMatrix() {
+void WalkRegion::ComputeVisibilityMatrix() {
// Initialise visibility matrix
m_VisibilityMatrix = Common::Array< Common::Array <int> >();
for (uint idx = 0; idx < m_Nodes.size(); ++idx) {
@@ -290,9 +290,9 @@ void BS_WalkRegion::ComputeVisibilityMatrix() {
// -----------------------------------------------------------------------------
-bool BS_WalkRegion::CheckAndPrepareStartAndEnd(BS_Vertex &Start, BS_Vertex &End) const {
+bool WalkRegion::CheckAndPrepareStartAndEnd(Vertex &Start, Vertex &End) const {
if (!IsPointInRegion(Start)) {
- BS_Vertex NewStart = FindClosestRegionPoint(Start);
+ Vertex NewStart = FindClosestRegionPoint(Start);
// Check to make sure the point is really in the region. If not, stop with an error
if (!IsPointInRegion(NewStart)) {
@@ -308,7 +308,7 @@ bool BS_WalkRegion::CheckAndPrepareStartAndEnd(BS_Vertex &Start, BS_Vertex &End)
// If the destination is outside the region, a point is determined that is within the region,
// and that is used as an endpoint instead
if (!IsPointInRegion(End)) {
- BS_Vertex NewEnd = FindClosestRegionPoint(End);
+ Vertex NewEnd = FindClosestRegionPoint(End);
// Make sure that the determined point is really within the region
if (!IsPointInRegion(NewEnd)) {
@@ -327,28 +327,28 @@ bool BS_WalkRegion::CheckAndPrepareStartAndEnd(BS_Vertex &Start, BS_Vertex &End)
// -----------------------------------------------------------------------------
-void BS_WalkRegion::SetPos(int X, int Y) {
+void WalkRegion::SetPos(int X, int Y) {
// Calculate the difference between old and new position
- BS_Vertex Delta(X - m_Position.X, Y - m_Position.Y);
+ Vertex Delta(X - m_Position.X, Y - m_Position.Y);
// Move all the nodes
for (unsigned int i = 0; i < m_Nodes.size(); i++) m_Nodes[i] += Delta;
// Move regions
- BS_Region::SetPos(X, Y);
+ Region::SetPos(X, Y);
}
// -----------------------------------------------------------------------------
-bool BS_WalkRegion::Persist(BS_OutputPersistenceBlock &Writer) {
+bool WalkRegion::Persist(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
// Persist the parent region
- Result &= BS_Region::Persist(Writer);
+ Result &= Region::Persist(Writer);
// Persist the nodes
Writer.Write(m_Nodes.size());
- Common::Array<BS_Vertex>::const_iterator It = m_Nodes.begin();
+ Common::Array<Vertex>::const_iterator It = m_Nodes.begin();
while (It != m_Nodes.end()) {
Writer.Write(It->X);
Writer.Write(It->Y);
@@ -374,7 +374,7 @@ bool BS_WalkRegion::Persist(BS_OutputPersistenceBlock &Writer) {
// -----------------------------------------------------------------------------
-bool BS_WalkRegion::Unpersist(BS_InputPersistenceBlock &Reader) {
+bool WalkRegion::Unpersist(BS_InputPersistenceBlock &Reader) {
bool Result = true;
// The parent object was already loaded in the constructor of BS_Region, so at
@@ -385,7 +385,7 @@ bool BS_WalkRegion::Unpersist(BS_InputPersistenceBlock &Reader) {
Reader.Read(NodeCount);
m_Nodes.clear();
m_Nodes.resize(NodeCount);
- Common::Array<BS_Vertex>::iterator It = m_Nodes.begin();
+ Common::Array<Vertex>::iterator It = m_Nodes.begin();
while (It != m_Nodes.end()) {
Reader.Read(It->X);
Reader.Read(It->Y);
diff --git a/engines/sword25/math/walkregion.h b/engines/sword25/math/walkregion.h
index f23044ecef..fd71ade981 100644
--- a/engines/sword25/math/walkregion.h
+++ b/engines/sword25/math/walkregion.h
@@ -45,7 +45,7 @@ namespace Sword25 {
// Type definitions
// -----------------------------------------------------------------------------
-typedef Common::Array<BS_Vertex> BS_Path;
+typedef Common::Array<Vertex> BS_Path;
// -----------------------------------------------------------------------------
// Class definitions
@@ -54,17 +54,17 @@ typedef Common::Array<BS_Vertex> BS_Path;
/**
* This class represents the region in which the main character can move
*/
-class BS_WalkRegion : public BS_Region {
- friend class BS_Region;
+class WalkRegion : public Region {
+ friend class Region;
protected:
- BS_WalkRegion();
- BS_WalkRegion(BS_InputPersistenceBlock &Reader, unsigned int Handle);
+ WalkRegion();
+ WalkRegion(BS_InputPersistenceBlock &Reader, unsigned int Handle);
public:
- virtual ~BS_WalkRegion();
+ virtual ~WalkRegion();
- virtual bool Init(const BS_Polygon &Contour, const Common::Array<BS_Polygon> *pHoles = 0);
+ virtual bool Init(const Polygon &Contour, const Common::Array<Polygon> *pHoles = 0);
/**
* Get the shortest path between two points in the region
@@ -81,7 +81,7 @@ public:
* @return Returns false if the result is invalid, otherwise returns true.
*/
bool QueryPath(int X1, int Y1, int X2, int Y2, BS_Path &Path) {
- return QueryPath(BS_Vertex(X1, Y1), BS_Vertex(X2, Y2), Path);
+ return QueryPath(Vertex(X1, Y1), Vertex(X2, Y2), Path);
}
/**
@@ -92,11 +92,11 @@ public:
* @param Path An empty BS_Path that will be set to the resulting path
* @return Returns false if the result is invalid, otherwise returns true.
*/
- bool QueryPath(BS_Vertex StartPoint, BS_Vertex EndPoint, BS_Path &Path);
+ bool QueryPath(Vertex StartPoint, Vertex EndPoint, BS_Path &Path);
virtual void SetPos(int X, int Y);
- const Common::Array<BS_Vertex> &GetNodes() const {
+ const Common::Array<Vertex> &GetNodes() const {
return m_Nodes;
}
const Common::Array< Common::Array<int> > &GetVisibilityMatrix() const {
@@ -107,13 +107,13 @@ public:
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
private:
- Common::Array<BS_Vertex> m_Nodes;
+ Common::Array<Vertex> m_Nodes;
Common::Array< Common::Array<int> > m_VisibilityMatrix;
void InitNodeVector();
void ComputeVisibilityMatrix();
- bool CheckAndPrepareStartAndEnd(BS_Vertex &Start, BS_Vertex &End) const;
- bool FindPath(const BS_Vertex &Start, const BS_Vertex &End, BS_Path &Path) const;
+ bool CheckAndPrepareStartAndEnd(Vertex &Start, Vertex &End) const;
+ bool FindPath(const Vertex &Start, const Vertex &End, BS_Path &Path) const;
};
} // End of namespace Sword25