Index: 0ad/build/workspaces/update-workspaces.sh =================================================================== --- 0ad/build/workspaces/update-workspaces.sh (revision 24769) +++ 0ad/build/workspaces/update-workspaces.sh (working copy) @@ -130,7 +130,8 @@ echo "Premake args: ${premake_args}" if [ "`uname -s`" != "Darwin" ]; then - ${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake || die "Premake failed" + # ${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" ${premake_args} + ${premake_command} --file="premake5.lua" --outpath="../workspaces/codelite/" ${premake_args} codelite || die "Premake failed" else ${premake_command} --file="premake5.lua" --outpath="../workspaces/gcc/" --macosx-version-min="${MIN_OSX_VERSION}" ${premake_args} gmake || die "Premake failed" # Also generate xcode workspaces if on OS X Index: 0ad/source/graphics/CinemaManager.cpp =================================================================== --- 0ad/source/graphics/CinemaManager.cpp (revision 24769) +++ 0ad/source/graphics/CinemaManager.cpp (working copy) @@ -174,7 +174,7 @@ glBegin(GL_POINTS); for (const SplineData& node : spline.GetAllNodes()) - glVertex3f(node.Position.X.ToFloat(), node.Position.Y.ToFloat(), node.Position.Z.ToFloat()); + glVertex3f(node.Position.getX().ToFloat(), node.Position.getY().ToFloat(), node.Position.getZ().ToFloat()); glEnd(); glPointSize(1.0f); Index: 0ad/source/graphics/MapReader.cpp =================================================================== --- 0ad/source/graphics/MapReader.cpp (revision 24769) +++ 0ad/source/graphics/MapReader.cpp (working copy) @@ -321,7 +321,7 @@ { // Use player starting camera CFixedVector3D pos = cmpPlayer->GetStartingCameraPos(); - pGameView->ResetCameraTarget(CVector3D(pos.X.ToFloat(), pos.Y.ToFloat(), pos.Z.ToFloat())); + pGameView->ResetCameraTarget(CVector3D(pos.getX().ToFloat(), pos.getY().ToFloat(), pos.getZ().ToFloat())); } else if (m_StartingCameraTarget != INVALID_ENTITY) { @@ -330,7 +330,7 @@ if (cmpPosition) { CFixedVector3D pos = cmpPosition->GetPosition(); - pGameView->ResetCameraTarget(CVector3D(pos.X.ToFloat(), pos.Y.ToFloat(), pos.Z.ToFloat())); + pGameView->ResetCameraTarget(CVector3D(pos.getX().ToFloat(), pos.getY().ToFloat(), pos.getZ().ToFloat())); } } } @@ -1053,8 +1053,8 @@ CmpPtr cmpPosition(sim, ent); if (cmpPosition) { - cmpPosition->JumpTo(Position.X, Position.Z); - cmpPosition->SetYRotation(Orientation.Y); + cmpPosition->JumpTo(Position.getX(), Position.getZ()); + cmpPosition->SetYRotation(Orientation.getY()); // TODO: other parts of the position } @@ -1432,8 +1432,8 @@ CmpPtr cmpPosition(sim, ent); if (cmpPosition) { - cmpPosition->JumpTo(currEnt.position.X * (int)TERRAIN_TILE_SIZE, currEnt.position.Z * (int)TERRAIN_TILE_SIZE); - cmpPosition->SetYRotation(currEnt.rotation.Y); + cmpPosition->JumpTo(currEnt.position.getX() * (int)TERRAIN_TILE_SIZE, currEnt.position.getZ() * (int)TERRAIN_TILE_SIZE); + cmpPosition->SetYRotation(currEnt.rotation.getY()); // TODO: other parts of the position } Index: 0ad/source/graphics/MapWriter.cpp =================================================================== --- 0ad/source/graphics/MapWriter.cpp (revision 24769) +++ 0ad/source/graphics/MapWriter.cpp (working copy) @@ -378,13 +378,13 @@ CFixedVector3D rot = cmpPosition->GetRotation(); { XMLWriter_Element positionTag(xmlMapFile, "Position"); - positionTag.Attribute("x", pos.X); - positionTag.Attribute("z", pos.Z); + positionTag.Attribute("x", pos.getX()); + positionTag.Attribute("z", pos.getZ()); // TODO: height offset etc } { XMLWriter_Element orientationTag(xmlMapFile, "Orientation"); - orientationTag.Attribute("y", rot.Y); + orientationTag.Attribute("y", rot.getY()); // TODO: X, Z maybe } } @@ -491,9 +491,9 @@ { // Types: Position/Rotation/Target XMLWriter_Element eventTypeTag(xmlMapFile, events[j].type); - eventTypeTag.Attribute("x", events[j].value.X); - eventTypeTag.Attribute("y", events[j].value.Y); - eventTypeTag.Attribute("z", events[j].value.Z); + eventTypeTag.Attribute("x", events[j].value.getX()); + eventTypeTag.Attribute("y", events[j].value.getY()); + eventTypeTag.Attribute("z", events[j].value.getZ()); } i = j; } Index: 0ad/source/graphics/Terrain.cpp =================================================================== --- 0ad/source/graphics/Terrain.cpp (revision 24769) +++ 0ad/source/graphics/Terrain.cpp (working copy) @@ -133,10 +133,10 @@ ssize_t hi = Clamp(i, static_cast(0), m_MapSize - 1); ssize_t hj = Clamp(j, static_cast(0), m_MapSize - 1); u16 height = m_Heightmap[hj*m_MapSize + hi]; - pos.X = fixed::FromInt(i) * (int)TERRAIN_TILE_SIZE; + pos.Xref() = fixed::FromInt(i) * (int)TERRAIN_TILE_SIZE; // fixed max value is 32767, but height is a u16, so divide by two to avoid overflow - pos.Y = fixed::FromInt(height/ 2 ) / ((int)HEIGHT_UNITS_PER_METRE / 2); - pos.Z = fixed::FromInt(j) * (int)TERRAIN_TILE_SIZE; + pos.Yref() = fixed::FromInt(height/ 2 ) / ((int)HEIGHT_UNITS_PER_METRE / 2); + pos.Zref() = fixed::FromInt(j) * (int)TERRAIN_TILE_SIZE; } Index: 0ad/source/graphics/tests/test_Terrain.h =================================================================== --- 0ad/source/graphics/tests/test_Terrain.h (revision 24769) +++ 0ad/source/graphics/tests/test_Terrain.h (working copy) @@ -181,19 +181,19 @@ CFixedVector3D vec; terrain.CalcNormalFixed(1, 1, vec); - TS_ASSERT_DELTA(vec.X.ToFloat(), -1.f/sqrt(2.f), 0.01f); - TS_ASSERT_DELTA(vec.Y.ToFloat(), 1.f/sqrt(2.f), 0.01f); - TS_ASSERT_EQUALS(vec.Z.ToFloat(), 0.f); + TS_ASSERT_DELTA(vec.getX().ToFloat(), -1.f/sqrt(2.f), 0.01f); + TS_ASSERT_DELTA(vec.getY().ToFloat(), 1.f/sqrt(2.f), 0.01f); + TS_ASSERT_EQUALS(vec.getZ().ToFloat(), 0.f); terrain.CalcNormalFixed(2, 1, vec); - TS_ASSERT_DELTA(vec.X.ToFloat(), (-1.f/sqrt(2.f)) / sqrt(2.f+sqrt(2.f)), 0.01f); - TS_ASSERT_DELTA(vec.Y.ToFloat(), (1.f+1.f/sqrt(2.f)) / sqrt(2.f+sqrt(2.f)), 0.01f); - TS_ASSERT_EQUALS(vec.Z.ToFloat(), 0); + TS_ASSERT_DELTA(vec.getX().ToFloat(), (-1.f/sqrt(2.f)) / sqrt(2.f+sqrt(2.f)), 0.01f); + TS_ASSERT_DELTA(vec.getY().ToFloat(), (1.f+1.f/sqrt(2.f)) / sqrt(2.f+sqrt(2.f)), 0.01f); + TS_ASSERT_EQUALS(vec.getZ().ToFloat(), 0); terrain.CalcNormalFixed(5, 1, vec); - TS_ASSERT_EQUALS(vec.X.ToFloat(), 0.f); - TS_ASSERT_EQUALS(vec.Y.ToFloat(), 1.f); - TS_ASSERT_EQUALS(vec.Z.ToFloat(), 0.f); + TS_ASSERT_EQUALS(vec.getX().ToFloat(), 0.f); + TS_ASSERT_EQUALS(vec.getY().ToFloat(), 1.f); + TS_ASSERT_EQUALS(vec.getZ().ToFloat(), 0.f); } void test_Resize() Index: 0ad/source/lib/self_test.h =================================================================== --- 0ad/source/lib/self_test.h (revision 24769) +++ 0ad/source/lib/self_test.h (working copy) @@ -75,7 +75,7 @@ ValueTraits(const CFixedVector3D& v) { std::stringstream s; - s << "[" << v.X.ToDouble() << ", " << v.Y.ToDouble() << ", " << v.Z.ToDouble() << "]"; + s << "[" << v.getX().ToDouble() << ", " << v.getY().ToDouble() << ", " << v.getZ().ToDouble() << "]"; m_StringRepr = s.str(); } const char* asString() const Index: 0ad/source/maths/FixedVector2D.h =================================================================== --- 0ad/source/maths/FixedVector2D.h (revision 24769) +++ 0ad/source/maths/FixedVector2D.h (working copy) @@ -21,14 +21,64 @@ #include "maths/Fixed.h" #include "maths/Sqrt.h" +/** + * @class CFixedVector3D + * @mod by DanW58 + * @date 21/01/21 + * @file FixedVector3D.h + * @brief: The proposed changes to this class may result in a performance increase + * by reducing the frequency of calls to isqrt64. The basic idea here is that a + * fourth member variable is introduced, mutable fixed L, which stores the length + * of the vector. All non-const functions clear its value to signal its needing to + * be re-computed. The function Length(), as well as Normalize() will respectively + * return or use the value of this variable, -unless it is zero, in which case they + * will call the (private) ComputeLength() function first, to update L. Note that + * the function Length() is a const function as it should be; but by the same token + * it should not be able to trigger a recomputation of private member L... This is + * why L is declared mutable. + * Why not, you might ask, recompute L within every non-const function? The reason + * is that, for some vectors, the length may never be needed; so this lazy approach + * only computes L if and when it is actually needed. + * And why do I use the value of zero to signal the need to re-update? Ans.: + * 1) an extra bool would make the size of the class alignment unfriendly + * 2) all representable values are valid, but zero is an unlikely value, and its + * triggering a recomputation upon a call to Length() should not be big issue. + * 3) of all representative values, zero/non-zero takes less cycles to test for. + */ + class CFixedVector2D { + fixed X, Y; //made private; returning const reference should be fastER + mutable fixed L; //cache for Length() computation; must be mutable... + fixed padding; //dummy fill for 128-bit alignment + public: - fixed X, Y; + ///constructors, etc. CFixedVector2D() { } - CFixedVector2D(fixed X, fixed Y) : X(X), Y(Y) { } + CFixedVector2D(fixed X, fixed Y) : X(X), Y(Y) + { + MarkLengthUpdateIsRequired(); //this boils to a quick inline reg clear op + } + /*virtual*/ ~CFixedVector2D() { padding.SetInternalValue(0); } //do not inherit + ///get functions + fixed const & getX() const { return X; } + fixed const & getY() const { return Y; } + + ///set functions, only used by deserializer, CTerrain::CalcPositionFixed, + ///Pathfinding::NavcellCenter, and VertexPathfinder::ComputeShortPath + fixed& Xref() + { + MarkLengthUpdateIsRequired(); //this boils to a quick inline reg clear op + return X; + } + fixed& Yref() + { + MarkLengthUpdateIsRequired(); + return Y; + } + /// Vector equality bool operator==(const CFixedVector2D& v) const { @@ -63,6 +113,7 @@ CFixedVector2D& operator+=(const CFixedVector2D& v) { *this = *this + v; + MarkLengthUpdateIsRequired(); return *this; } @@ -70,6 +121,7 @@ CFixedVector2D& operator-=(const CFixedVector2D& v) { *this = *this - v; + MarkLengthUpdateIsRequired(); return *this; } @@ -93,12 +145,15 @@ { return CFixedVector2D(X.Multiply(n), Y.Multiply(n)); } - + +private: + /** - * Returns the length of the vector. + * Updates the stored value of the length of the vector. * Will not overflow if the result can be represented as type 'fixed'. + * Needs to be const to auto-update upon const function call; but L is mutable */ - fixed Length() const + void UnconditionallyUpdateLength() const //see note above { // Do intermediate calculations with 64-bit ints to avoid overflows u64 xx = SQUARE_U64_FIXED(X); @@ -107,14 +162,32 @@ CheckUnsignedAdditionOverflow(d2, xx, L"Overflow in CFixedVector2D::Length() part 1") u32 d = isqrt64(d2); + CheckU32CastOverflow(d, i32, L"Overflow in CFixedVector2D::Length() part 2") - CheckU32CastOverflow(d, i32, L"Overflow in CFixedVector2D::Length() part 2") - fixed r; - r.SetInternalValue(static_cast(d)); - return r; + L.SetInternalValue(static_cast(d)); //Store the length in L } + void ConditionallyUpdateLength() const //L/L2 are mutable + { + if( L.IsZero() && !(X.IsZero() && Y.IsZero()) ) + UnconditionallyUpdateLength(); + } + void MarkLengthUpdateIsRequired() const //L is mutable + { + L.SetInternalValue(0); + } +public: + /** + * Returns the cached length of the vector. + */ + fixed const & Length() const + { + ConditionallyUpdateLength(); + return L; + } + + /** * Returns -1, 0, +1 depending on whether length is less/equal/greater * than the argument. * Avoids sqrting and overflowing. @@ -121,21 +194,17 @@ */ int CompareLength(fixed cmp) const { - u64 d2 = SQUARE_U64_FIXED(X) + SQUARE_U64_FIXED(Y); // d2 <= 2^63 (no overflow) - u64 cmpSquared = SQUARE_U64_FIXED(cmp); - - if (d2 < cmpSquared) - return -1; - - if (d2 > cmpSquared) - return +1; - - return 0; + ConditionallyUpdateLength(); + int result = 0; + if (Length() < cmp) result = -1; + if (cmp < L) result = 1; //already updated + return result; } /** * Same as above, but avoids squaring the compared value. * The argument must be the result of an SQUARE_U64_FIXED operation. + * DanW says: This function should be obsolete now. */ int CompareLengthSquared(u64 cmpSquared) const { @@ -153,20 +222,17 @@ /** * Returns -1, 0, +1 depending on whether length is less/equal/greater * than the argument's length. - * Avoids sqrting and overflowing. + * Uses the stored value of length squared if possible; otherwise + * it recalculates it. */ int CompareLength(const CFixedVector2D& other) const { - u64 d2 = SQUARE_U64_FIXED(X) + SQUARE_U64_FIXED(Y); - u64 od2 = SQUARE_U64_FIXED(other.X) + SQUARE_U64_FIXED(other.Y); - - if (d2 < od2) - return -1; - - if (d2 > od2) - return +1; - - return 0; + ConditionallyUpdateLength(); + other.ConditionallyUpdateLength(); + int result = 0; + if ( L < other.L ) result = -1; + if ( other.L < L ) result = 1; + return result; } bool IsZero() const @@ -180,11 +246,12 @@ */ void Normalize() { - if (!IsZero()) + ConditionallyUpdateLength(); + if (!L.IsZero()) { - fixed l = Length(); - X = X / l; - Y = Y / l; + X = X / L; + Y = Y / L; + UnconditionallyUpdateLength(); //L will be pretty close to one } } @@ -194,11 +261,12 @@ */ void Normalize(fixed n) { - fixed l = Length(); - if (!l.IsZero()) + ConditionallyUpdateLength(); + if (!L.IsZero()) { - X = X.MulDiv(n, l); - Y = Y.MulDiv(n, l); + X = X.MulDiv(n, L); + Y = Y.MulDiv(n, L); + UnconditionallyUpdateLength(); //L will be pretty close to n } } Index: 0ad/source/maths/FixedVector3D.h =================================================================== --- 0ad/source/maths/FixedVector3D.h (revision 24769) +++ 0ad/source/maths/FixedVector3D.h (working copy) @@ -21,14 +21,68 @@ #include "maths/Fixed.h" #include "maths/Sqrt.h" + +/** + * @class CFixedVector3D + * @mod by DanW58 + * @date 21/01/21 + * @file FixedVector3D.h + * @brief: The proposed changes to this class may result in a performance increase + * by reducing the frequency of calls to isqrt64. The basic idea here is that a + * fourth member variable is introduced, mutable fixed L, which stores the length + * of the vector. All non-const functions clear its value to signal its needing to + * be re-computed. The function Length(), as well as Normalize() will respectively + * return or use the value of this variable, -unless it is zero, in which case they + * will call the (private) ComputeLength() function first, to update L. Note that + * the function Length() is a const function as it should be; but by the same token + * it should not be able to trigger a recomputation of private member L... This is + * why L is declared mutable. + * Why not, you might ask, recompute L within every non-const function? The reason + * is that, for some vectors, the length may never be needed; so this lazy approach + * only computes L if and when it is actually needed. + * And why do I use the value of zero to signal the need to re-update? Ans.: + * 1) an extra bool would make the size of the class alignment unfriendly + * 2) all representable values are valid, but zero is an unlikely value, and its + * triggering a recomputation upon a call to Length() should not be big issue. + * 3) of all representative values, zero/non-zero takes less cycles to test for. + */ + class CFixedVector3D { + fixed X, Y, Z; //made private; returning const reference should be fastER + mutable fixed L; //cache for Length() computation; must be mutable... + public: - fixed X, Y, Z; - + ///constructors, etc. CFixedVector3D() { } + CFixedVector3D(fixed X, fixed Y, fixed Z) : X(X), Y(Y), Z(Z) + { + MarkLengthUpdateIsRequired(); //this boils to a quick inline reg clear op + } + //virtual ~CFixedVector2D() {} //do not inherit - CFixedVector3D(fixed X, fixed Y, fixed Z) : X(X), Y(Y), Z(Z) { } + ///get functions + fixed const & getX() const { return X; } //this should be fastER than making + fixed const & getY() const { return Y; } //the members public, as many engine + fixed const & getZ() const { return Z; } //optimizations are subverted otherwise + + //"set functions" (ref's), only used by deserializer, CTerrain::CalcPositionFixed + //and some javascript initializer, I forget now... + fixed& Xref() + { + MarkLengthUpdateIsRequired(); //this boils to a quick inline reg clear op + return X; + } + fixed& Yref() + { + MarkLengthUpdateIsRequired(); + return Y; + } + fixed& Zref() + { + MarkLengthUpdateIsRequired(); + return Z; + } /// Vector equality bool operator==(const CFixedVector3D& v) const @@ -64,6 +118,7 @@ CFixedVector3D& operator+=(const CFixedVector3D& v) { *this = *this + v; + MarkLengthUpdateIsRequired(); return *this; } @@ -71,15 +126,45 @@ CFixedVector3D& operator-=(const CFixedVector3D& v) { *this = *this - v; + MarkLengthUpdateIsRequired(); return *this; } /** - * Returns the length of the vector. + * Returns the cached length of the vector. + */ + fixed const & Length() const + { + ConditionallyUpdateLength(); + return L; + } + + /** + * This function added by DanW58, to match CFixedVector2D's interface + * Returns -1, 0, +1 depending on whether length is less/equal/greater + * than the argument's length. + * Uses the stored value of length squared if possible; otherwise + * it recalculates it. + */ + int CompareLength(const CFixedVector3D& other) const + { + ConditionallyUpdateLength(); + other.ConditionallyUpdateLength(); + int result = 0; + if ( L < other.L ) result = -1; + if ( other.L < L ) result = 1; + return result; + } + +private: + + /** + * Computes and caches the length of the vector. * Will not overflow if the result can be represented as type 'fixed'. + * Needs to be const to auto-update upon const function call; but L is mutable */ - fixed Length() const + void UnconditionallyUpdateLength() const //see note above { // Do intermediate calculations with 64-bit ints to avoid overflows u64 xx = SQUARE_U64_FIXED(X); @@ -92,13 +177,22 @@ CheckUnsignedAdditionOverflow(d2, t, L"Overflow in CFixedVector3D::Length() part 2") u32 d = isqrt64(d2); - CheckU32CastOverflow(d, i32, L"Overflow in CFixedVector3D::Length() part 3") - fixed r; - r.SetInternalValue((i32)d); - return r; + + L.SetInternalValue((i32)d); } + void ConditionallyUpdateLength() const //L is mutable + { + if( L.IsZero() && !(X.IsZero() && Y.IsZero() && Z.IsZero()) ) + UnconditionallyUpdateLength(); + } + void MarkLengthUpdateIsRequired() const //L is mutable + { + L.SetInternalValue(0); + } +public: + /** * Normalize the vector so that length is close to 1. * If length is 0, does nothing. @@ -105,12 +199,13 @@ */ void Normalize() { - fixed l = Length(); - if (!l.IsZero()) + ConditionallyUpdateLength(); + if (!L.IsZero()) { - X = X / l; - Y = Y / l; - Z = Z / l; + X = X/L; + Y = Y/L; + Z = Z/L; + UnconditionallyUpdateLength(); //L will be pretty close to one } } @@ -120,12 +215,13 @@ */ void Normalize(fixed n) { - fixed l = Length(); - if (!l.IsZero()) + ConditionallyUpdateLength(); + if (!L.IsZero()) { - X = X.MulDiv(n, l); - Y = Y.MulDiv(n, l); - Z = Z.MulDiv(n, l); + X = X.MulDiv(n, L); + Y = Y.MulDiv(n, L); + Z = Z.MulDiv(n, L); + UnconditionallyUpdateLength(); //L will be pretty close to n } } @@ -132,7 +228,7 @@ /** * Compute the cross product of this vector with another. */ - CFixedVector3D Cross(const CFixedVector3D& v) + CFixedVector3D Cross(const CFixedVector3D& v) const //DanW58: const added; it was missing { i64 y_vz = MUL_I64_I32_I32(Y.GetInternalValue(), v.Z.GetInternalValue()); i64 z_vy = MUL_I64_I32_I32(Z.GetInternalValue(), v.Y.GetInternalValue()); @@ -165,7 +261,7 @@ /** * Compute the dot product of this vector with another. */ - fixed Dot(const CFixedVector3D& v) + fixed Dot(const CFixedVector3D& v) const //DanW58: const added; it was missing { i64 x = MUL_I64_I32_I32(X.GetInternalValue(), v.X.GetInternalValue()); i64 y = MUL_I64_I32_I32(Y.GetInternalValue(), v.Y.GetInternalValue()); @@ -184,4 +280,5 @@ } }; + #endif // INCLUDED_FIXED_VECTOR3D Index: 0ad/source/maths/Vector3D.cpp =================================================================== --- 0ad/source/maths/Vector3D.cpp (revision 24769) +++ 0ad/source/maths/Vector3D.cpp (working copy) @@ -32,7 +32,7 @@ #include CVector3D::CVector3D(const CFixedVector3D& v) : - X(v.X.ToFloat()), Y(v.Y.ToFloat()), Z(v.Z.ToFloat()) + X(v.getX().ToFloat()), Y(v.getY().ToFloat()), Z(v.getZ().ToFloat()) { } Index: 0ad/source/maths/tests/test_FixedVector2D.h =================================================================== --- 0ad/source/maths/tests/test_FixedVector2D.h (revision 24769) +++ 0ad/source/maths/tests/test_FixedVector2D.h (working copy) @@ -20,12 +20,12 @@ #include "maths/FixedVector2D.h" #define TS_ASSERT_VEC_EQUALS(v, x, y) \ - TS_ASSERT_EQUALS(v.X.ToDouble(), x); \ - TS_ASSERT_EQUALS(v.Y.ToDouble(), y); + TS_ASSERT_EQUALS(v.getX().ToDouble(), x); \ + TS_ASSERT_EQUALS(v.getY().ToDouble(), y); #define TS_ASSERT_VEC_DELTA(v, x, y, delta) \ - TS_ASSERT_DELTA(v.X.ToDouble(), x, delta); \ - TS_ASSERT_DELTA(v.Y.ToDouble(), y, delta); + TS_ASSERT_DELTA(v.getX().ToDouble(), x, delta); \ + TS_ASSERT_DELTA(v.getY().ToDouble(), y, delta); class TestFixedVector2D : public CxxTest::TestSuite { Index: 0ad/source/maths/tests/test_FixedVector3D.h =================================================================== --- 0ad/source/maths/tests/test_FixedVector3D.h (revision 24769) +++ 0ad/source/maths/tests/test_FixedVector3D.h (working copy) @@ -20,14 +20,14 @@ #include "maths/FixedVector3D.h" #define TS_ASSERT_VEC_EQUALS(v, x, y, z) \ - TS_ASSERT_EQUALS(v.X.ToDouble(), x); \ - TS_ASSERT_EQUALS(v.Y.ToDouble(), y); \ - TS_ASSERT_EQUALS(v.Z.ToDouble(), z); + TS_ASSERT_EQUALS(v.getX().ToDouble(), x); \ + TS_ASSERT_EQUALS(v.getY().ToDouble(), y); \ + TS_ASSERT_EQUALS(v.getZ().ToDouble(), z); #define TS_ASSERT_VEC_DELTA(v, x, y, z, delta) \ - TS_ASSERT_DELTA(v.X.ToDouble(), x, delta); \ - TS_ASSERT_DELTA(v.Y.ToDouble(), y, delta); \ - TS_ASSERT_DELTA(v.Z.ToDouble(), z, delta); + TS_ASSERT_DELTA(v.getX().ToDouble(), x, delta); \ + TS_ASSERT_DELTA(v.getY().ToDouble(), y, delta); \ + TS_ASSERT_DELTA(v.getZ().ToDouble(), z, delta); class TestFixedVector3D : public CxxTest::TestSuite { Index: 0ad/source/ps/Replay.cpp =================================================================== --- 0ad/source/ps/Replay.cpp (revision 24769) +++ 0ad/source/ps/Replay.cpp (working copy) @@ -201,6 +201,8 @@ new CProfileManager; g_ScriptStatsTable = new CScriptStatsTable; g_ProfileViewer.AddRootTable(g_ScriptStatsTable); + + g_Profiler2.EnableHTTP(); const int contextSize = 384 * 1024 * 1024; const int heapGrowthBytesGCTrigger = 20 * 1024 * 1024; Index: 0ad/source/simulation2/components/CCmpAIManager.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpAIManager.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpAIManager.cpp (working copy) @@ -330,8 +330,8 @@ void ComputePath(const CFixedVector2D& pos, const CFixedVector2D& goal, pass_class_t passClass, std::vector& waypoints) { WaypointPath ret; - PathGoal pathGoal = { PathGoal::POINT, goal.X, goal.Y }; - m_LongPathfinder.ComputePath(m_HierarchicalPathfinder, pos.X, pos.Y, pathGoal, passClass, ret); + PathGoal pathGoal = { PathGoal::POINT, goal.getX(), goal.getY() }; + m_LongPathfinder.ComputePath(m_HierarchicalPathfinder, pos.getX(), pos.getY(), pathGoal, passClass, ret); for (Waypoint& wp : ret.m_Waypoints) waypoints.emplace_back(wp.x, wp.z); Index: 0ad/source/simulation2/components/CCmpCinemaManager.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpCinemaManager.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpCinemaManager.cpp (working copy) @@ -275,13 +275,13 @@ else serializer.NumberFixed_Unbounded("NodeDeltaTime", fixed::Zero()); - serializer.NumberFixed_Unbounded("PositionX", nodes[i].Position.X); - serializer.NumberFixed_Unbounded("PositionY", nodes[i].Position.Y); - serializer.NumberFixed_Unbounded("PositionZ", nodes[i].Position.Z); + serializer.NumberFixed_Unbounded("PositionX", nodes[i].Position.getX()); + serializer.NumberFixed_Unbounded("PositionY", nodes[i].Position.getY()); + serializer.NumberFixed_Unbounded("PositionZ", nodes[i].Position.getZ()); - serializer.NumberFixed_Unbounded("RotationX", nodes[i].Rotation.X); - serializer.NumberFixed_Unbounded("RotationY", nodes[i].Rotation.Y); - serializer.NumberFixed_Unbounded("RotationZ", nodes[i].Rotation.Z); + serializer.NumberFixed_Unbounded("RotationX", nodes[i].Rotation.getX()); + serializer.NumberFixed_Unbounded("RotationY", nodes[i].Rotation.getY()); + serializer.NumberFixed_Unbounded("RotationZ", nodes[i].Rotation.getZ()); } if (!data->m_LookAtTarget) @@ -295,9 +295,9 @@ serializer.NumberFixed_Unbounded("NodeDeltaTime", targetNodes[i - 1].Distance); else serializer.NumberFixed_Unbounded("NodeDeltaTime", fixed::Zero()); - serializer.NumberFixed_Unbounded("PositionX", targetNodes[i].Position.X); - serializer.NumberFixed_Unbounded("PositionY", targetNodes[i].Position.Y); - serializer.NumberFixed_Unbounded("PositionZ", targetNodes[i].Position.Z); + serializer.NumberFixed_Unbounded("PositionX", targetNodes[i].Position.getX()); + serializer.NumberFixed_Unbounded("PositionY", targetNodes[i].Position.getY()); + serializer.NumberFixed_Unbounded("PositionZ", targetNodes[i].Position.getZ()); } } @@ -320,13 +320,13 @@ SplineData node; deserializer.NumberFixed_Unbounded("NodeDeltaTime", node.Distance); - deserializer.NumberFixed_Unbounded("PositionX", node.Position.X); - deserializer.NumberFixed_Unbounded("PositionY", node.Position.Y); - deserializer.NumberFixed_Unbounded("PositionZ", node.Position.Z); + deserializer.NumberFixed_Unbounded("PositionX", node.Position.Xref()); + deserializer.NumberFixed_Unbounded("PositionY", node.Position.Yref()); + deserializer.NumberFixed_Unbounded("PositionZ", node.Position.Zref()); - deserializer.NumberFixed_Unbounded("RotationX", node.Rotation.X); - deserializer.NumberFixed_Unbounded("RotationY", node.Rotation.Y); - deserializer.NumberFixed_Unbounded("RotationZ", node.Rotation.Z); + deserializer.NumberFixed_Unbounded("RotationX", node.Rotation.Xref()); + deserializer.NumberFixed_Unbounded("RotationY", node.Rotation.Yref()); + deserializer.NumberFixed_Unbounded("RotationZ", node.Rotation.Zref()); pathSpline.AddNode(node.Position, node.Rotation, node.Distance); } @@ -340,9 +340,9 @@ SplineData node; deserializer.NumberFixed_Unbounded("NodeDeltaTime", node.Distance); - deserializer.NumberFixed_Unbounded("PositionX", node.Position.X); - deserializer.NumberFixed_Unbounded("PositionY", node.Position.Y); - deserializer.NumberFixed_Unbounded("PositionZ", node.Position.Z); + deserializer.NumberFixed_Unbounded("PositionX", node.Position.Xref()); + deserializer.NumberFixed_Unbounded("PositionY", node.Position.Yref()); + deserializer.NumberFixed_Unbounded("PositionZ", node.Position.Zref()); targetSpline.AddNode(node.Position, CFixedVector3D(), node.Distance); } Index: 0ad/source/simulation2/components/CCmpDecay.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpDecay.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpDecay.cpp (working copy) @@ -168,8 +168,8 @@ CmpPtr cmpTerrain(GetSystemEntity()); if (cmpTerrain) { - fixed ground = cmpTerrain->GetGroundLevel(pos.X, pos.Z); - m_TotalSinkDepth += std::max(0.f, (pos.Y - ground).ToFloat()); + fixed ground = cmpTerrain->GetGroundLevel(pos.getX(), pos.getZ()); + m_TotalSinkDepth += std::max(0.f, (pos.getY() - ground).ToFloat()); } // Sink it further down if it sinks like a ship, as it will rotate. @@ -176,13 +176,13 @@ if (m_ShipSink) { // lacking randomness we'll trick - m_SinkingAngleX = (pos.X.ToInt_RoundToNearest() % 30 - 15) / 15.0; - m_SinkingAngleZ = (pos.Z.ToInt_RoundToNearest() % 30) / 40.0; + m_SinkingAngleX = (pos.getX().ToInt_RoundToNearest() % 30 - 15) / 15.0; + m_SinkingAngleZ = (pos.getZ().ToInt_RoundToNearest() % 30) / 40.0; m_TotalSinkDepth += 10.f; } // probably 0 in both cases but we'll remember it anyway. - m_InitialXRotation = cmpPosition->GetRotation().X; - m_InitialZRotation = cmpPosition->GetRotation().Z; + m_InitialXRotation = cmpPosition->GetRotation().getX(); + m_InitialZRotation = cmpPosition->GetRotation().getZ(); } m_CurrentTime += msgData.deltaSimTime; Index: 0ad/source/simulation2/components/CCmpFootprint.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpFootprint.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpFootprint.cpp (working copy) @@ -187,7 +187,7 @@ SkipTagRequireFlagsObstructionFilter filter(spawnedTag, ICmpObstructionManager::FLAG_BLOCK_MOVEMENT); CFixedVector2D initialPos = cmpPosition->GetPosition2D(); - entity_angle_t initialAngle = cmpPosition->GetRotation().Y; + entity_angle_t initialAngle = cmpPosition->GetRotation().getY(); CFixedVector2D u = CFixedVector2D(fixed::Zero(), fixed::FromInt(1)).Rotate(initialAngle); CFixedVector2D v = u.Perpendicular(); @@ -203,8 +203,8 @@ // Figure out how many units can fit on each halfside of the rectangle. // Since 2*pi/6 ~= 1, this is also how many units can fit on a sixth of the circle. - int distX = std::max(1, (halfSize.X / gap).ToInt_RoundToNegInfinity()); - int distY = std::max(1, (halfSize.Y / gap).ToInt_RoundToNegInfinity()); + int distX = std::max(1, (halfSize.getX() / gap).ToInt_RoundToNegInfinity()); + int distY = std::max(1, (halfSize.getY() / gap).ToInt_RoundToNegInfinity()); // Try more spawning points for large units in case some of them are partially blocked. if (rows == 1) @@ -222,7 +222,7 @@ CFixedVector2D rallyPointPos = cmpRallyPoint->GetFirstPosition(); if (m_Shape == CIRCLE) { - entity_angle_t offsetAngle = atan2_approx(rallyPointPos.X - initialPos.X, rallyPointPos.Y - initialPos.Y) - initialAngle; + entity_angle_t offsetAngle = atan2_approx(rallyPointPos.getX() - initialPos.getX(), rallyPointPos.getY() - initialPos.getY()) - initialAngle; // There are 6*(distX+r) points in row r, so multiply that by angle/2pi to find the offset within the row. for (int r = 0; r < rows; ++r) @@ -233,8 +233,8 @@ CFixedVector2D offsetPos = Geometry::NearestPointOnSquare(rallyPointPos - initialPos, u, v, halfSize); // Scale and convert the perimeter coordinates of the point to its offset within the row. - int x = (offsetPos.Dot(u) * distX / halfSize.X).ToInt_RoundToNearest(); - int y = (offsetPos.Dot(v) * distY / halfSize.Y).ToInt_RoundToNearest(); + int x = (offsetPos.Dot(u) * distX / halfSize.getX()).ToInt_RoundToNearest(); + int y = (offsetPos.Dot(v) * distY / halfSize.getY()).ToInt_RoundToNearest(); for (int r = 0; r < rows; ++r) offsetPoints[r] = Geometry::GetPerimeterDistance( distX + r, @@ -250,17 +250,17 @@ CFixedVector2D pos = initialPos; if (m_Shape == CIRCLE) // Multiply the point by 2pi / 6*(distX+r) to get the angle. - pos += u.Rotate(fixed::Pi() * (offsetPoints[r] + k) / (3 * (distX + r))).Multiply(halfSize.X + gap * r ); + pos += u.Rotate(fixed::Pi() * (offsetPoints[r] + k) / (3 * (distX + r))).Multiply(halfSize.getX() + gap * r ); else { // Convert the point to coordinates and scale. std::pair p = Geometry::GetPerimeterCoordinates(distX + r, distY + r, offsetPoints[r] + k); - pos += u.Multiply((halfSize.X + gap * r) * p.first / (distX + r)) + - v.Multiply((halfSize.Y + gap * r) * p.second / (distY + r)); + pos += u.Multiply((halfSize.getX() + gap * r) * p.first / (distX + r)) + + v.Multiply((halfSize.getY() + gap * r) * p.second / (distY + r)); } - if (cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Y, spawnedRadius, spawnedPass) == ICmpObstruction::FOUNDATION_CHECK_SUCCESS) - return CFixedVector3D(pos.X, fixed::Zero(), pos.Y); + if (cmpPathfinder->CheckUnitPlacement(filter, pos.getX(), pos.getY(), spawnedRadius, spawnedPass) == ICmpObstruction::FOUNDATION_CHECK_SUCCESS) + return CFixedVector3D(pos.getX(), fixed::Zero(), pos.getY()); } return error; @@ -314,7 +314,7 @@ pass_class_t entityPass = cmpEntityMotion->GetPassabilityClass(); CFixedVector2D initialPos = cmpPosition->GetPosition2D(); - entity_angle_t initialAngle = cmpPosition->GetRotation().Y; + entity_angle_t initialAngle = cmpPosition->GetRotation().getY(); // Max spawning distance + 1 (in meters) const i32 maxSpawningDistance = 13; @@ -337,11 +337,11 @@ fixed s, c; sincos_approx(angle, s, c); - CFixedVector3D pos (initialPos.X + s.Multiply(radius), fixed::Zero(), initialPos.Y + c.Multiply(radius)); + CFixedVector3D pos (initialPos.getX() + s.Multiply(radius), fixed::Zero(), initialPos.getY() + c.Multiply(radius)); SkipTagObstructionFilter filter(spawnedTag); // ignore collisions with the spawned entity - if (cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Z, spawnedRadius, spawnedPass) == ICmpObstruction::FOUNDATION_CHECK_SUCCESS && - cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Z, spawnedRadius, entityPass) == ICmpObstruction::FOUNDATION_CHECK_SUCCESS) + if (cmpPathfinder->CheckUnitPlacement(filter, pos.getX(), pos.getZ(), spawnedRadius, spawnedPass) == ICmpObstruction::FOUNDATION_CHECK_SUCCESS && + cmpPathfinder->CheckUnitPlacement(filter, pos.getX(), pos.getZ(), spawnedRadius, entityPass) == ICmpObstruction::FOUNDATION_CHECK_SUCCESS) return pos; // this position is okay, so return it } } @@ -395,9 +395,9 @@ CFixedVector2D pos (center + dir*i); SkipTagObstructionFilter filter(spawnedTag); // ignore collisions with the spawned entity - if (cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Y, spawnedRadius, spawnedPass) == ICmpObstruction::FOUNDATION_CHECK_SUCCESS && - cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Y, spawnedRadius, entityPass) == ICmpObstruction::FOUNDATION_CHECK_SUCCESS) - return CFixedVector3D(pos.X, fixed::Zero(), pos.Y); // this position is okay, so return it + if (cmpPathfinder->CheckUnitPlacement(filter, pos.getX(), pos.getY(), spawnedRadius, spawnedPass) == ICmpObstruction::FOUNDATION_CHECK_SUCCESS && + cmpPathfinder->CheckUnitPlacement(filter, pos.getX(), pos.getY(), spawnedRadius, entityPass) == ICmpObstruction::FOUNDATION_CHECK_SUCCESS) + return CFixedVector3D(pos.getX(), fixed::Zero(), pos.getY()); // this position is okay, so return it } } } Index: 0ad/source/simulation2/components/CCmpMotionBall.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpMotionBall.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpMotionBall.cpp (working copy) @@ -91,8 +91,8 @@ // TODO: this is all FP-unsafe CFixedVector3D pos = cmpPosition->GetPosition(); - float x = pos.X.ToFloat(); - float z = pos.Z.ToFloat(); + float x = pos.getX().ToFloat(); + float z = pos.getZ().ToFloat(); CVector3D normal = GetSimContext().GetTerrain().CalcExactNormal(x, z); // Flatten the vector, to get the downhill force Index: 0ad/source/simulation2/components/CCmpObstruction.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpObstruction.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpObstruction.cpp (working copy) @@ -248,13 +248,13 @@ b.da = entity_angle_t::FromInt(0); b.flags = m_Flags; m_Shapes.push_back(b); - max.X = std::max(max.X, b.dx + b.size0/2); - max.Y = std::max(max.Y, b.dz + b.size1/2); - min.X = std::min(min.X, b.dx - b.size0/2); - min.Y = std::min(min.Y, b.dz - b.size1/2); + max.Xref() = std::max(max.getX(), b.dx + b.size0/2); + max.Yref() = std::max(max.getY(), b.dz + b.size1/2); + min.Xref() = std::min(min.getX(), b.dx - b.size0/2); + min.Yref() = std::min(min.getY(), b.dz - b.size1/2); } - m_Size0 = fixed::FromInt(2).Multiply(std::max(max.X, -min.X)); - m_Size1 = fixed::FromInt(2).Multiply(std::max(max.Y, -min.Y)); + m_Size0 = fixed::FromInt(2).Multiply(std::max(max.getX(), -min.getX())); + m_Size1 = fixed::FromInt(2).Multiply(std::max(max.getY(), -min.getY())); } m_Active = paramNode.GetChild("Active").ToBool(); @@ -396,12 +396,12 @@ CFixedVector2D pos = cmpPosition->GetPosition2D(); if (m_Type == STATIC) m_Tag = cmpObstructionManager->AddStaticShape(GetEntityId(), - pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, m_Flags, m_ControlGroup, m_ControlGroup2); + pos.getX(), pos.getY(), cmpPosition->GetRotation().getY(), m_Size0, m_Size1, m_Flags, m_ControlGroup, m_ControlGroup2); else if (m_Type == UNIT) m_Tag = cmpObstructionManager->AddUnitShape(GetEntityId(), - pos.X, pos.Y, m_Clearance, (flags_t)(m_Flags | (m_Moving ? ICmpObstructionManager::FLAG_MOVING : 0)), m_ControlGroup); + pos.getX(), pos.getY(), m_Clearance, (flags_t)(m_Flags | (m_Moving ? ICmpObstructionManager::FLAG_MOVING : 0)), m_ControlGroup); else - AddClusterShapes(pos.X, pos.Y, cmpPosition->GetRotation().Y); + AddClusterShapes(pos.getX(), pos.getY(), cmpPosition->GetRotation().getY()); } else if (!active && m_Active) { @@ -499,9 +499,9 @@ else pos = cmpPosition->GetPosition2D(); if (m_Type == UNIT) - out = cmpObstructionManager->GetUnitShapeObstruction(pos.X, pos.Y, m_Clearance); + out = cmpObstructionManager->GetUnitShapeObstruction(pos.getX(), pos.getY(), m_Clearance); else - out = cmpObstructionManager->GetStaticShapeObstruction(pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1); + out = cmpObstructionManager->GetStaticShapeObstruction(pos.getX(), pos.getY(), cmpPosition->GetRotation().getY(), m_Size0, m_Size1); return true; } @@ -544,8 +544,8 @@ return false; // Keep these constants in agreement with the pathfinder. - return cmpWaterManager->GetWaterLevel(front.X, front.Y) - cmpTerrain->GetGroundLevel(front.X, front.Y) > fixed::FromInt(1) && - cmpWaterManager->GetWaterLevel( back.X, back.Y) - cmpTerrain->GetGroundLevel( back.X, back.Y) < fixed::FromInt(2); + return cmpWaterManager->GetWaterLevel(front.getX(), front.getY()) - cmpTerrain->GetGroundLevel(front.getX(), front.getY()) > fixed::FromInt(1) && + cmpWaterManager->GetWaterLevel( back.getX(), back.getY()) - cmpTerrain->GetGroundLevel( back.getX(), back.getY()) < fixed::FromInt(2); } virtual EFoundationCheck CheckFoundation(const std::string& className) const @@ -585,9 +585,9 @@ ICmpObstructionManager::FLAG_BLOCK_FOUNDATION); if (m_Type == UNIT) - return cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Y, m_Clearance, passClass, onlyCenterPoint); + return cmpPathfinder->CheckUnitPlacement(filter, pos.getX(), pos.getY(), m_Clearance, passClass, onlyCenterPoint); else - return cmpPathfinder->CheckBuildingPlacement(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, GetEntityId(), passClass, onlyCenterPoint); + return cmpPathfinder->CheckBuildingPlacement(filter, pos.getX(), pos.getY(), cmpPosition->GetRotation().getY(), m_Size0, m_Size1, GetEntityId(), passClass, onlyCenterPoint); } virtual bool CheckDuplicateFoundation() const @@ -617,9 +617,9 @@ ICmpObstructionManager::FLAG_BLOCK_FOUNDATION); if (m_Type == UNIT) - return !cmpObstructionManager->TestUnitShape(filter, pos.X, pos.Y, m_Clearance, NULL); + return !cmpObstructionManager->TestUnitShape(filter, pos.getX(), pos.getY(), m_Clearance, NULL); else - return !cmpObstructionManager->TestStaticShape(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, NULL ); + return !cmpObstructionManager->TestStaticShape(filter, pos.getX(), pos.getY(), cmpPosition->GetRotation().getY(), m_Size0, m_Size1, NULL ); } virtual std::vector GetEntitiesByFlags(flags_t flags) const @@ -746,7 +746,7 @@ ICmpObstructionManager::FLAG_BLOCK_FOUNDATION); std::vector collisions; - if (cmpObstructionManager->TestStaticShape(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, &collisions)) + if (cmpObstructionManager->TestStaticShape(filter, pos.getX(), pos.getY(), cmpPosition->GetRotation().getY(), m_Size0, m_Size1, &collisions)) { std::vector persistentEnts, normalEnts; Index: 0ad/source/simulation2/components/CCmpObstructionManager.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpObstructionManager.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpObstructionManager.cpp (working copy) @@ -104,10 +104,10 @@ serialize.NumberU32_Unbounded("entity", value.entity); serialize.NumberFixed_Unbounded("x", value.x); serialize.NumberFixed_Unbounded("z", value.z); - serialize.NumberFixed_Unbounded("u.x", value.u.X); - serialize.NumberFixed_Unbounded("u.y", value.u.Y); - serialize.NumberFixed_Unbounded("v.x", value.v.X); - serialize.NumberFixed_Unbounded("v.y", value.v.Y); + serialize.NumberFixed_Unbounded("u.x", value.u.Xref()); + serialize.NumberFixed_Unbounded("u.y", value.u.Yref()); + serialize.NumberFixed_Unbounded("v.x", value.v.Xref()); + serialize.NumberFixed_Unbounded("v.y", value.v.Yref()); serialize.NumberFixed_Unbounded("hw", value.hw); serialize.NumberFixed_Unbounded("hh", value.hh); serialize.NumberU8_Unbounded("flags", value.flags); @@ -563,8 +563,8 @@ return; u16 j0, j1, i0, i1; - Pathfinding::NearestNavcell(x - hbox.X, z - hbox.Y, i0, j0, m_UpdateInformations.dirtinessGrid.m_W, m_UpdateInformations.dirtinessGrid.m_H); - Pathfinding::NearestNavcell(x + hbox.X, z + hbox.Y, i1, j1, m_UpdateInformations.dirtinessGrid.m_W, m_UpdateInformations.dirtinessGrid.m_H); + Pathfinding::NearestNavcell(x - hbox.getX(), z - hbox.getY(), i0, j0, m_UpdateInformations.dirtinessGrid.m_W, m_UpdateInformations.dirtinessGrid.m_H); + Pathfinding::NearestNavcell(x + hbox.getX(), z + hbox.getY(), i1, j1, m_UpdateInformations.dirtinessGrid.m_W, m_UpdateInformations.dirtinessGrid.m_H); for (int j = j0; j < j1; ++j) for (int i = i0; i < i1; ++i) @@ -662,7 +662,7 @@ */ inline bool IsInWorld(const CFixedVector2D& p) const { - return (m_WorldX0 <= p.X && p.X <= m_WorldX1 && m_WorldZ0 <= p.Y && p.Y <= m_WorldZ1); + return (m_WorldX0 <= p.getX() && p.getX() <= m_WorldX1 && m_WorldZ0 <= p.getY() && p.getY() <= m_WorldZ1); } void RasterizeHelper(Grid& grid, ICmpObstructionManager::flags_t requireMask, bool fullUpdate, pass_class_t appliedMask, entity_pos_t clearance = fixed::Zero()) const; @@ -691,7 +691,7 @@ if (!cmpPosition || !cmpPosition->IsInWorld()) return fixed::FromInt(-1); - return (CFixedVector2D(cmpPosition->GetPosition2D().X, cmpPosition->GetPosition2D().Y) - CFixedVector2D(px, pz)).Length(); + return (CFixedVector2D(cmpPosition->GetPosition2D().getX(), cmpPosition->GetPosition2D().getY()) - CFixedVector2D(px, pz)).Length(); } fixed CCmpObstructionManager::MaxDistanceToPoint(entity_id_t ent, entity_pos_t px, entity_pos_t pz) const @@ -710,7 +710,7 @@ if (!cmpPosition || !cmpPosition->IsInWorld()) return fixed::FromInt(-1); - return (CFixedVector2D(cmpPosition->GetPosition2D().X, cmpPosition->GetPosition2D().Y) - CFixedVector2D(px, pz)).Length(); + return (CFixedVector2D(cmpPosition->GetPosition2D().getX(), cmpPosition->GetPosition2D().getY()) - CFixedVector2D(px, pz)).Length(); } fixed CCmpObstructionManager::DistanceToTarget(entity_id_t ent, entity_id_t target) const @@ -722,7 +722,7 @@ CmpPtr cmpPosition(GetSimContext(), ent); if (!cmpPosition || !cmpPosition->IsInWorld()) return fixed::FromInt(-1); - return DistanceToPoint(target, cmpPosition->GetPosition2D().X, cmpPosition->GetPosition2D().Y); + return DistanceToPoint(target, cmpPosition->GetPosition2D().getX(), cmpPosition->GetPosition2D().getY()); } ObstructionSquare target_obstruction; @@ -732,7 +732,7 @@ CmpPtr cmpPositionTarget(GetSimContext(), target); if (!cmpPositionTarget || !cmpPositionTarget->IsInWorld()) return fixed::FromInt(-1); - return DistanceToPoint(ent, cmpPositionTarget->GetPosition2D().X, cmpPositionTarget->GetPosition2D().Y); + return DistanceToPoint(ent, cmpPositionTarget->GetPosition2D().getX(), cmpPositionTarget->GetPosition2D().getY()); } return DistanceBetweenShapes(obstruction, target_obstruction); @@ -747,7 +747,7 @@ CmpPtr cmpPosition(GetSimContext(), ent); if (!cmpPosition || !cmpPosition->IsInWorld()) return fixed::FromInt(-1); - return MaxDistanceToPoint(target, cmpPosition->GetPosition2D().X, cmpPosition->GetPosition2D().Y); + return MaxDistanceToPoint(target, cmpPosition->GetPosition2D().getX(), cmpPosition->GetPosition2D().getY()); } ObstructionSquare target_obstruction; @@ -757,7 +757,7 @@ CmpPtr cmpPositionTarget(GetSimContext(), target); if (!cmpPositionTarget || !cmpPositionTarget->IsInWorld()) return fixed::FromInt(-1); - return MaxDistanceToPoint(ent, cmpPositionTarget->GetPosition2D().X, cmpPositionTarget->GetPosition2D().Y); + return MaxDistanceToPoint(ent, cmpPositionTarget->GetPosition2D().getX(), cmpPositionTarget->GetPosition2D().getY()); } return MaxDistanceBetweenShapes(obstruction, target_obstruction); @@ -922,8 +922,8 @@ CFixedVector2D v(s, c); CFixedVector2D center(x, z); CFixedVector2D halfSize(w/2, h/2); - CFixedVector2D corner1 = u.Multiply(halfSize.X) + v.Multiply(halfSize.Y); - CFixedVector2D corner2 = u.Multiply(halfSize.X) - v.Multiply(halfSize.Y); + CFixedVector2D corner1 = u.Multiply(halfSize.getX()) + v.Multiply(halfSize.getY()); + CFixedVector2D corner2 = u.Multiply(halfSize.getX()) - v.Multiply(halfSize.getY()); // Check that all corners are within the world (which means the whole shape must be) if (!IsInWorld(center + corner1) || !IsInWorld(center + corner2) || @@ -935,8 +935,8 @@ return true; } - fixed bbHalfWidth = std::max(corner1.X.Absolute(), corner2.X.Absolute()); - fixed bbHalfHeight = std::max(corner1.Y.Absolute(), corner2.Y.Absolute()); + fixed bbHalfWidth = std::max(corner1.getX().Absolute(), corner2.getX().Absolute()); + fixed bbHalfHeight = std::max(corner1.getY().Absolute(), corner2.getY().Absolute()); CFixedVector2D posMin(x - bbHalfWidth, z - bbHalfHeight); CFixedVector2D posMax(x + bbHalfWidth, z + bbHalfHeight); @@ -952,7 +952,7 @@ CFixedVector2D center1(it->second.x, it->second.z); - if (Geometry::PointIsInSquare(center1 - center, u, v, CFixedVector2D(halfSize.X + it->second.clearance, halfSize.Y + it->second.clearance))) + if (Geometry::PointIsInSquare(center1 - center, u, v, CFixedVector2D(halfSize.getX() + it->second.clearance, halfSize.getY() + it->second.clearance))) { if (out) out->push_back(it->second.entity); @@ -1141,8 +1141,8 @@ entity_pos_t r = pair.second.clearance + clearance; u16 i0, j0, i1, j1; - Pathfinding::NearestNavcell(center.X - r, center.Y - r, i0, j0, grid.m_W, grid.m_H); - Pathfinding::NearestNavcell(center.X + r, center.Y + r, i1, j1, grid.m_W, grid.m_H); + Pathfinding::NearestNavcell(center.getX() - r, center.getY() - r, i0, j0, grid.m_W, grid.m_H); + Pathfinding::NearestNavcell(center.getX() + r, center.getY() + r, i1, j1, grid.m_W, grid.m_H); for (u16 j = j0+1; j < j1; ++j) for (u16 i = i0+1; i < i1; ++i) grid.set(i, j, grid.get(i, j) | appliedMask); @@ -1338,7 +1338,7 @@ { m_DebugOverlayLines.push_back(SOverlayLine()); m_DebugOverlayLines.back().m_Color = defaultColor; - float a = atan2f(it->second.v.X.ToFloat(), it->second.v.Y.ToFloat()); + float a = atan2f(it->second.v.getX().ToFloat(), it->second.v.getY().ToFloat()); SimRender::ConstructSquareOnGround(GetSimContext(), it->second.x.ToFloat(), it->second.z.ToFloat(), it->second.hw.ToFloat()*2, it->second.hh.ToFloat()*2, a, m_DebugOverlayLines.back(), true); } Index: 0ad/source/simulation2/components/CCmpOverlayRenderer.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpOverlayRenderer.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpOverlayRenderer.cpp (working copy) @@ -125,10 +125,10 @@ SOverlaySprite sprite; sprite.m_Texture = g_Renderer.GetTextureManager().CreateTexture(textureProps); - sprite.m_X0 = corner0.X.ToFloat(); - sprite.m_Y0 = corner0.Y.ToFloat(); - sprite.m_X1 = corner1.X.ToFloat(); - sprite.m_Y1 = corner1.Y.ToFloat(); + sprite.m_X0 = corner0.getX().ToFloat(); + sprite.m_Y0 = corner0.getY().ToFloat(); + sprite.m_X1 = corner1.getX().ToFloat(); + sprite.m_Y1 = corner1.getY().ToFloat(); sprite.m_Color = colorObj; m_Sprites.push_back(sprite); Index: 0ad/source/simulation2/components/CCmpPosition.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpPosition.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpPosition.cpp (working copy) @@ -224,9 +224,9 @@ serialize.NumberU32_Unbounded("turret parent", m_TurretParent); if (m_TurretParent != INVALID_ENTITY) { - serialize.NumberFixed_Unbounded("x", m_TurretPosition.X); - serialize.NumberFixed_Unbounded("y", m_TurretPosition.Y); - serialize.NumberFixed_Unbounded("z", m_TurretPosition.Z); + serialize.NumberFixed_Unbounded("x", m_TurretPosition.getX()); + serialize.NumberFixed_Unbounded("y", m_TurretPosition.getY()); + serialize.NumberFixed_Unbounded("z", m_TurretPosition.getZ()); } } @@ -261,9 +261,9 @@ deserialize.NumberU32_Unbounded("turret parent", m_TurretParent); if (m_TurretParent != INVALID_ENTITY) { - deserialize.NumberFixed_Unbounded("x", m_TurretPosition.X); - deserialize.NumberFixed_Unbounded("y", m_TurretPosition.Y); - deserialize.NumberFixed_Unbounded("z", m_TurretPosition.Z); + deserialize.NumberFixed_Unbounded("x", m_TurretPosition.Xref()); + deserialize.NumberFixed_Unbounded("y", m_TurretPosition.Yref()); + deserialize.NumberFixed_Unbounded("z", m_TurretPosition.Zref()); } if (m_InWorld) @@ -291,14 +291,14 @@ MoveOutOfWorld(); else { - CFixedVector2D rotatedPosition = CFixedVector2D(m_TurretPosition.X, m_TurretPosition.Z); - rotatedPosition = rotatedPosition.Rotate(cmpPosition->GetRotation().Y); + CFixedVector2D rotatedPosition = CFixedVector2D(m_TurretPosition.getX(), m_TurretPosition.getZ()); + rotatedPosition = rotatedPosition.Rotate(cmpPosition->GetRotation().getY()); CFixedVector2D rootPosition = cmpPosition->GetPosition2D(); - entity_pos_t x = rootPosition.X + rotatedPosition.X; - entity_pos_t z = rootPosition.Y + rotatedPosition.Y; + entity_pos_t x = rootPosition.getX() + rotatedPosition.getX(); + entity_pos_t z = rootPosition.getY() + rotatedPosition.getY(); if (!m_InWorld || m_X != x || m_Z != z) MoveTo(x, z); - entity_pos_t y = cmpPosition->GetHeightOffset() + m_TurretPosition.Y; + entity_pos_t y = cmpPosition->GetHeightOffset() + m_TurretPosition.getY(); if (!m_InWorld || GetHeightOffset() != y) SetHeightOffset(y); m_InWorld = true; @@ -312,7 +312,7 @@ virtual void SetTurretParent(entity_id_t id, const CFixedVector3D& offset) { - entity_angle_t angle = GetRotation().Y; + entity_angle_t angle = GetRotation().getY(); if (m_TurretParent != INVALID_ENTITY) { CmpPtr cmpPosition(GetSimContext(), m_TurretParent); @@ -555,7 +555,7 @@ { CmpPtr cmpPosition(GetSimContext(), m_TurretParent); if (cmpPosition) - y -= cmpPosition->GetRotation().Y; + y -= cmpPosition->GetRotation().getY(); } m_RotY = y; @@ -569,7 +569,7 @@ { CmpPtr cmpPosition(GetSimContext(), m_TurretParent); if (cmpPosition) - y -= cmpPosition->GetRotation().Y; + y -= cmpPosition->GetRotation().getY(); } m_RotY = y; m_InterpolatedRotY = m_RotY.ToFloat(); @@ -607,7 +607,7 @@ { CmpPtr cmpPosition(GetSimContext(), m_TurretParent); if (cmpPosition) - y += cmpPosition->GetRotation().Y; + y += cmpPosition->GetRotation().getY(); } return CFixedVector3D(m_RotX, y, m_RotZ); } @@ -691,7 +691,7 @@ CMatrix3D parentTransformMatrix = cmpPosition->GetInterpolatedTransform(frameOffset); CMatrix3D ownTransformation = CMatrix3D(); ownTransformation.SetYRotation(m_InterpolatedRotY); - ownTransformation.Translate(-m_TurretPosition.X.ToFloat(), m_TurretPosition.Y.ToFloat(), -m_TurretPosition.Z.ToFloat()); + ownTransformation.Translate(-m_TurretPosition.getX().ToFloat(), m_TurretPosition.getY().ToFloat(), -m_TurretPosition.getZ().ToFloat()); return parentTransformMatrix * ownTransformation; } } Index: 0ad/source/simulation2/components/CCmpRallyPointRenderer.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpRallyPointRenderer.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpRallyPointRenderer.cpp (working copy) @@ -244,7 +244,7 @@ { if (m_Displayed && IsSet()) { - markerCmpPosition->MoveTo(m_RallyPoints[i].X, m_RallyPoints[i].Y); + markerCmpPosition->MoveTo(m_RallyPoints[i].getX(), m_RallyPoints[i].getY()); } else { @@ -367,22 +367,22 @@ std::vector& waypoints = path.m_Waypoints; CFixedVector2D start(cmpPosition->GetPosition2D()); - PathGoal goal = { PathGoal::POINT, m_RallyPoints[index].X, m_RallyPoints[index].Y }; + PathGoal goal = { PathGoal::POINT, m_RallyPoints[index].getX(), m_RallyPoints[index].getY() }; if (index == 0) GetClosestsEdgePointFrom(start,m_RallyPoints[index], cmpPosition, cmpFootprint); else { - start.X = m_RallyPoints[index-1].X; - start.Y = m_RallyPoints[index-1].Y; + start.Xref() = m_RallyPoints[index-1].getX(); + start.Yref() = m_RallyPoints[index-1].getY(); } - cmpPathfinder->ComputePathImmediate(start.X, start.Y, goal, cmpPathfinder->GetPassabilityClass(m_LinePassabilityClass), path); + cmpPathfinder->ComputePathImmediate(start.getX(), start.getY(), goal, cmpPathfinder->GetPassabilityClass(m_LinePassabilityClass), path); // Check if we got a path back; if not we probably have two markers less than one tile apart. if (path.m_Waypoints.size() < 2) { - m_Path[index].emplace_back(start.X.ToFloat(), start.Y.ToFloat()); - m_Path[index].emplace_back(m_RallyPoints[index].X.ToFloat(), m_RallyPoints[index].Y.ToFloat()); + m_Path[index].emplace_back(start.getX().ToFloat(), start.getY().ToFloat()); + m_Path[index].emplace_back(m_RallyPoints[index].getX().ToFloat(), m_RallyPoints[index].getY().ToFloat()); return; } else if (index == 0) @@ -390,19 +390,19 @@ // Sometimes this ends up not being optimal if you asked for a long path, so improve. CFixedVector2D newend(waypoints[waypoints.size()-2].x,waypoints[waypoints.size()-2].z); GetClosestsEdgePointFrom(newend,newend, cmpPosition, cmpFootprint); - waypoints.back().x = newend.X; - waypoints.back().z = newend.Y; + waypoints.back().x = newend.getX(); + waypoints.back().z = newend.getY(); } else { // Make sure we actually start at the rallypoint because the pathfinder moves us to a usable tile. - waypoints.back().x = m_RallyPoints[index-1].X; - waypoints.back().z = m_RallyPoints[index-1].Y; + waypoints.back().x = m_RallyPoints[index-1].getX(); + waypoints.back().z = m_RallyPoints[index-1].getY(); } // Pathfinder makes us go to the nearest passable cell which isn't always what we want - waypoints[0].x = m_RallyPoints[index].X; - waypoints[0].z = m_RallyPoints[index].Y; + waypoints[0].x = m_RallyPoints[index].getX(); + waypoints[0].z = m_RallyPoints[index].getY(); // From here on, we choose to represent the waypoints as CVector2D floats to avoid to have to convert back and forth // between fixed-point Waypoint/CFixedVector2D and various other float-based formats used by interpolation and whatnot. @@ -677,7 +677,7 @@ // Sinus and cosinus of the Y axis rotation angle (aka the yaw) fixed s, c; - fixed a = cmpPosition->GetRotation().Y; + fixed a = cmpPosition->GetRotation().getY(); sincos_approx(a, s, c); // Unit vector along the rotated X axis CFixedVector2D u(c, -s); @@ -693,7 +693,7 @@ { // In this case, both footprintSize0 and 1 indicate the circle's radius // Transform target to the point nearest on the edge. - CFixedVector2D centerVec2D(center.X, center.Y); + CFixedVector2D centerVec2D(center.getX(), center.getY()); CFixedVector2D centerToLast(start - centerVec2D); centerToLast.Normalize(); result = centerVec2D + (centerToLast.Multiply(footprintSize0)); Index: 0ad/source/simulation2/components/CCmpRangeManager.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpRangeManager.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpRangeManager.cpp (working copy) @@ -166,11 +166,11 @@ */ static bool InParabolicRange(CFixedVector3D v, fixed range) { - u64 xx = SQUARE_U64_FIXED(v.X); // xx <= 2^62 - u64 zz = SQUARE_U64_FIXED(v.Z); + u64 xx = SQUARE_U64_FIXED(v.getX()); // xx <= 2^62 + u64 zz = SQUARE_U64_FIXED(v.getZ()); i64 d2 = (xx + zz) >> 1; // d2 <= 2^62 (no overflow) - i32 y = v.Y.GetInternalValue(); + i32 y = v.getY().GetInternalValue(); i32 c = range.GetInternalValue(); i32 c_2 = c >> 1; @@ -1221,7 +1221,7 @@ // they have an intersection after which the former grows slower, and then use that to prove the above. // Note that this is only true because we do not account for vertical size here, // if we did, we would also need to artificially 'raise' the source over the target. - if (!InParabolicRange(CFixedVector3D(it->second.x, secondPosition.Y, it->second.z) - pos3d, + if (!InParabolicRange(CFixedVector3D(it->second.x, secondPosition.getY(), it->second.z) - pos3d, q.maxRange + fixed::FromInt(it->second.size))) continue; @@ -1267,8 +1267,8 @@ entity_pos_t r = entity_pos_t::Zero(); CFixedVector3D pos(pos1); - pos.Y += elevationBonus; - entity_pos_t orientation = rot.Y; + pos.Yref() += elevationBonus; + entity_pos_t orientation = rot.getY(); entity_pos_t maxAngle = orientation + angle/2; entity_pos_t minAngle = orientation - angle/2; @@ -1301,8 +1301,8 @@ u64 precisionSquared = SQUARE_U64_FIXED(entity_pos_t::FromInt(static_cast(TERRAIN_TILE_SIZE)) / 8); CmpPtr cmpWaterManager(GetSystemEntity()); - entity_pos_t waterLevel = cmpWaterManager ? cmpWaterManager->GetWaterLevel(pos.X, pos.Z) : entity_pos_t::Zero(); - entity_pos_t thisHeight = pos.Y > waterLevel ? pos.Y : waterLevel; + entity_pos_t waterLevel = cmpWaterManager ? cmpWaterManager->GetWaterLevel(pos.getX(), pos.getZ()) : entity_pos_t::Zero(); + entity_pos_t thisHeight = pos.getY() > waterLevel ? pos.getY() : waterLevel; for (int i = 0; i < numberOfSteps; ++i) { @@ -1315,14 +1315,14 @@ CFixedVector2D minVector = CFixedVector2D(entity_pos_t::Zero(), entity_pos_t::Zero()); CFixedVector2D maxVector = CFixedVector2D(sin, cos).Multiply(cutoff); - entity_pos_t targetHeight = cmpTerrain->GetGroundLevel(pos.X+maxVector.X, pos.Z+maxVector.Y); + entity_pos_t targetHeight = cmpTerrain->GetGroundLevel(pos.getX()+maxVector.getX(), pos.getZ()+maxVector.getY()); // use water level to display range on water targetHeight = targetHeight > waterLevel ? targetHeight : waterLevel; - if (InParabolicRange(CFixedVector3D(maxVector.X, targetHeight-thisHeight, maxVector.Y), maxRange)) + if (InParabolicRange(CFixedVector3D(maxVector.getX(), targetHeight-thisHeight, maxVector.getY()), maxRange)) { - r.push_back(maxVector.X); - r.push_back(maxVector.Y); + r.push_back(maxVector.getX()); + r.push_back(maxVector.getY()); continue; } @@ -1335,10 +1335,10 @@ CFixedVector2D newVector = CFixedVector2D(sin, cos).Multiply(newDistance); // get the height of the ground - targetHeight = cmpTerrain->GetGroundLevel(pos.X+newVector.X, pos.Z+newVector.Y); + targetHeight = cmpTerrain->GetGroundLevel(pos.getX()+newVector.getX(), pos.getZ()+newVector.getY()); targetHeight = targetHeight > waterLevel ? targetHeight : waterLevel; - if (InParabolicRange(CFixedVector3D(newVector.X, targetHeight-thisHeight, newVector.Y), maxRange)) + if (InParabolicRange(CFixedVector3D(newVector.getX(), targetHeight-thisHeight, newVector.getY()), maxRange)) { // new vector is in parabolic range, so this is a new minVector minVector = newVector; @@ -1352,8 +1352,8 @@ } } - r.push_back(maxVector.X); - r.push_back(maxVector.Y); + r.push_back(maxVector.getX()); + r.push_back(maxVector.getY()); } r.push_back(r[0]); @@ -1453,13 +1453,13 @@ { m_DebugOverlayLines.push_back(SOverlayLine()); m_DebugOverlayLines.back().m_Color = (q.enabled ? enabledRingColor : disabledRingColor); - SimRender::ConstructCircleOnGround(GetSimContext(), pos.X.ToFloat(), pos.Y.ToFloat(), q.maxRange.ToFloat(), m_DebugOverlayLines.back(), true); + SimRender::ConstructCircleOnGround(GetSimContext(), pos.getX().ToFloat(), pos.getY().ToFloat(), q.maxRange.ToFloat(), m_DebugOverlayLines.back(), true); } else { // elevation bonus is part of the 3D position. As if the unit is really that much higher CFixedVector3D pos3D = cmpSourcePosition->GetPosition(); - pos3D.Y += q.elevationBonus; + pos3D.Yref() += q.elevationBonus; std::vector coords; @@ -1504,10 +1504,10 @@ for (size_t i = 3; i < coords.size(); i += 2) { std::vector c; - c.push_back((coords[i - 3] + pos3D.X).ToFloat()); - c.push_back((coords[i - 2] + pos3D.Z).ToFloat()); - c.push_back((coords[i - 1] + pos3D.X).ToFloat()); - c.push_back((coords[i] + pos3D.Z).ToFloat()); + c.push_back((coords[i - 3] + pos3D.getX()).ToFloat()); + c.push_back((coords[i - 2] + pos3D.getZ()).ToFloat()); + c.push_back((coords[i - 1] + pos3D.getX()).ToFloat()); + c.push_back((coords[i] + pos3D.getZ()).ToFloat()); m_DebugOverlayLines.push_back(SOverlayLine()); m_DebugOverlayLines.back().m_Color = thiscolor; SimRender::ConstructLineOnGround(GetSimContext(), c, m_DebugOverlayLines.back(), true); @@ -1516,7 +1516,7 @@ // Draw the min range circle if (!q.minRange.IsZero()) - SimRender::ConstructCircleOnGround(GetSimContext(), pos.X.ToFloat(), pos.Y.ToFloat(), q.minRange.ToFloat(), m_DebugOverlayLines.back(), true); + SimRender::ConstructCircleOnGround(GetSimContext(), pos.getX().ToFloat(), pos.getY().ToFloat(), q.minRange.ToFloat(), m_DebugOverlayLines.back(), true); // Draw a ray from the source to each matched entity for (size_t i = 0; i < q.lastMatch.size(); ++i) @@ -1527,10 +1527,10 @@ CFixedVector2D targetPos = cmpTargetPosition->GetPosition2D(); std::vector coords; - coords.push_back(pos.X.ToFloat()); - coords.push_back(pos.Y.ToFloat()); - coords.push_back(targetPos.X.ToFloat()); - coords.push_back(targetPos.Y.ToFloat()); + coords.push_back(pos.getX().ToFloat()); + coords.push_back(pos.getY().ToFloat()); + coords.push_back(targetPos.getX().ToFloat()); + coords.push_back(targetPos.getY().ToFloat()); m_DebugOverlayLines.push_back(SOverlayLine()); m_DebugOverlayLines.back().m_Color = rayColor; @@ -1623,8 +1623,8 @@ return LosVisibility::HIDDEN; CFixedVector2D pos = cmpPosition->GetPosition2D(); - int i = (pos.X / (int)TERRAIN_TILE_SIZE).ToInt_RoundToNearest(); - int j = (pos.Y / (int)TERRAIN_TILE_SIZE).ToInt_RoundToNearest(); + int i = (pos.getX() / (int)TERRAIN_TILE_SIZE).ToInt_RoundToNearest(); + int j = (pos.getY() / (int)TERRAIN_TILE_SIZE).ToInt_RoundToNearest(); // Reveal flag makes all positioned entities visible and all mirages useless if (GetLosRevealAll(player)) @@ -1729,7 +1729,7 @@ CFixedVector2D pos = cmpPosition->GetPosition2D(); - if (IsVisibilityDirty(m_DirtyVisibility[PosToLosTilesHelper(pos.X, pos.Y)], player)) + if (IsVisibilityDirty(m_DirtyVisibility[PosToLosTilesHelper(pos.getX(), pos.getY())], player)) return ComputeLosVisibility(ent, player); if (std::find(m_ModifiedEntities.begin(), m_ModifiedEntities.end(), entId) != m_ModifiedEntities.end()) @@ -2017,8 +2017,8 @@ continue; CFixedVector2D pos = cmpPosition->GetPosition2D(); - int i = (pos.X / (int)TERRAIN_TILE_SIZE).ToInt_RoundToNearest(); - int j = (pos.Y / (int)TERRAIN_TILE_SIZE).ToInt_RoundToNearest(); + int i = (pos.getX() / (int)TERRAIN_TILE_SIZE).ToInt_RoundToNearest(); + int j = (pos.getY() / (int)TERRAIN_TILE_SIZE).ToInt_RoundToNearest(); CLosQuerier los(GetSharedLosMask(p), m_LosState, m_TerrainVerticesPerSide); if (!los.IsExplored(i,j) || los.IsVisible(i,j)) @@ -2203,14 +2203,14 @@ // Compute top/bottom coordinates, and clamp to exclude the 1-tile border around the map // (so that we never render the sharp edge of the map) - i32 j0 = ((pos.Y - visionRange)/(int)TERRAIN_TILE_SIZE).ToInt_RoundToInfinity(); - i32 j1 = ((pos.Y + visionRange)/(int)TERRAIN_TILE_SIZE).ToInt_RoundToNegInfinity(); + i32 j0 = ((pos.getY() - visionRange)/(int)TERRAIN_TILE_SIZE).ToInt_RoundToInfinity(); + i32 j1 = ((pos.getY() + visionRange)/(int)TERRAIN_TILE_SIZE).ToInt_RoundToNegInfinity(); i32 j0clamp = std::max(j0, 1); i32 j1clamp = std::min(j1, m_TerrainVerticesPerSide-2); // Translate world coordinates into fractional tile-space coordinates - entity_pos_t x = pos.X / (int)TERRAIN_TILE_SIZE; - entity_pos_t y = pos.Y / (int)TERRAIN_TILE_SIZE; + entity_pos_t x = pos.getX() / (int)TERRAIN_TILE_SIZE; + entity_pos_t y = pos.getY() / (int)TERRAIN_TILE_SIZE; entity_pos_t r = visionRange / (int)TERRAIN_TILE_SIZE; entity_pos_t r2 = r.Square(); @@ -2286,17 +2286,17 @@ // so we can compute the difference between the removed/added strips // and only have to touch tiles that have a net change.) - i32 j0_from = ((from.Y - visionRange)/(int)TERRAIN_TILE_SIZE).ToInt_RoundToInfinity(); - i32 j1_from = ((from.Y + visionRange)/(int)TERRAIN_TILE_SIZE).ToInt_RoundToNegInfinity(); - i32 j0_to = ((to.Y - visionRange)/(int)TERRAIN_TILE_SIZE).ToInt_RoundToInfinity(); - i32 j1_to = ((to.Y + visionRange)/(int)TERRAIN_TILE_SIZE).ToInt_RoundToNegInfinity(); + i32 j0_from = ((from.getY() - visionRange)/(int)TERRAIN_TILE_SIZE).ToInt_RoundToInfinity(); + i32 j1_from = ((from.getY() + visionRange)/(int)TERRAIN_TILE_SIZE).ToInt_RoundToNegInfinity(); + i32 j0_to = ((to.getY() - visionRange)/(int)TERRAIN_TILE_SIZE).ToInt_RoundToInfinity(); + i32 j1_to = ((to.getY() + visionRange)/(int)TERRAIN_TILE_SIZE).ToInt_RoundToNegInfinity(); i32 j0clamp = std::max(std::min(j0_from, j0_to), 1); i32 j1clamp = std::min(std::max(j1_from, j1_to), m_TerrainVerticesPerSide-2); - entity_pos_t x_from = from.X / (int)TERRAIN_TILE_SIZE; - entity_pos_t y_from = from.Y / (int)TERRAIN_TILE_SIZE; - entity_pos_t x_to = to.X / (int)TERRAIN_TILE_SIZE; - entity_pos_t y_to = to.Y / (int)TERRAIN_TILE_SIZE; + entity_pos_t x_from = from.getX() / (int)TERRAIN_TILE_SIZE; + entity_pos_t y_from = from.getY() / (int)TERRAIN_TILE_SIZE; + entity_pos_t x_to = to.getX() / (int)TERRAIN_TILE_SIZE; + entity_pos_t y_to = to.getY() / (int)TERRAIN_TILE_SIZE; entity_pos_t r = visionRange / (int)TERRAIN_TILE_SIZE; entity_pos_t r2 = r.Square(); Index: 0ad/source/simulation2/components/CCmpTerritoryManager.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpTerritoryManager.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpTerritoryManager.cpp (working copy) @@ -486,7 +486,7 @@ CFixedVector2D pos = cmpPosition->GetPosition2D(); u16 i, j; - NearestTerritoryTile(pos.X, pos.Y, i, j, tilesW, tilesH); + NearestTerritoryTile(pos.getX(), pos.getY(), i, j, tilesW, tilesH); if (cmpTerritoryInfluence->IsRoot()) rootInfluenceEntities.push_back(ent); @@ -539,7 +539,7 @@ CFixedVector2D pos = cmpPosition->GetPosition2D(); u16 i, j; - NearestTerritoryTile(pos.X, pos.Y, i, j, tilesW, tilesH); + NearestTerritoryTile(pos.getX(), pos.getY(), i, j, tilesW, tilesH); u8 owner = (u8)cmpOwnership->GetOwner(); Index: 0ad/source/simulation2/components/CCmpUnitMotion.cpp =================================================================== --- 0ad/source/simulation2/components/CCmpUnitMotion.cpp (revision 24769) +++ 0ad/source/simulation2/components/CCmpUnitMotion.cpp (working copy) @@ -276,8 +276,8 @@ Serializer(serialize, "target type", m_MoveRequest.m_Type, MoveRequest::Type::OFFSET); serialize.NumberU32_Unbounded("target entity", m_MoveRequest.m_Entity); - serialize.NumberFixed_Unbounded("target pos x", m_MoveRequest.m_Position.X); - serialize.NumberFixed_Unbounded("target pos y", m_MoveRequest.m_Position.Y); + serialize.NumberFixed_Unbounded("target pos x", m_MoveRequest.m_Position.Xref()); + serialize.NumberFixed_Unbounded("target pos y", m_MoveRequest.m_Position.Yref()); serialize.NumberFixed_Unbounded("target min range", m_MoveRequest.m_MinRange); serialize.NumberFixed_Unbounded("target max range", m_MoveRequest.m_MaxRange); @@ -415,7 +415,7 @@ // TODO: formation members should perhaps try to use the controller's position. CFixedVector2D pos = cmpPosition->GetPosition2D(); - entity_angle_t angle = cmpPosition->GetRotation().Y; + entity_angle_t angle = cmpPosition->GetRotation().getY(); // Copy the path so we don't change it. WaypointPath shortPath = m_ShortPath; @@ -497,7 +497,7 @@ { CFixedVector2D targetPos; if (ComputeTargetPosition(targetPos)) - FaceTowardsPointFromPos(cmpPosition->GetPosition2D(), targetPos.X, targetPos.Y); + FaceTowardsPointFromPos(cmpPosition->GetPosition2D(), targetPos.getX(), targetPos.getY()); } } @@ -819,7 +819,7 @@ CFixedVector2D targetPos; if (ComputeTargetPosition(targetPos)) - m_LongPath.m_Waypoints.emplace_back(Waypoint{ targetPos.X, targetPos.Y }); + m_LongPath.m_Waypoints.emplace_back(Waypoint{ targetPos.getX(), targetPos.getY() }); return; } @@ -882,7 +882,7 @@ return; CFixedVector2D initialPos = cmpPosition->GetPosition2D(); - entity_angle_t initialAngle = cmpPosition->GetRotation().Y; + entity_angle_t initialAngle = cmpPosition->GetRotation().getY(); // Keep track of the current unit's position and rotation during the update. CFixedVector2D pos = initialPos; @@ -907,8 +907,8 @@ // Update the Position component after our movement (if we actually moved anywhere) // When moving always set the angle in the direction of the movement. CFixedVector2D offset = pos - initialPos; - angle = atan2_approx(offset.X, offset.Y); - cmpPosition->MoveAndTurnTo(pos.X, pos.Y, angle); + angle = atan2_approx(offset.getX(), offset.getY()); + cmpPosition->MoveAndTurnTo(pos.getX(), pos.getY(), angle); // Calculate the mean speed over this past turn. UpdateMovementState(offset.Length() / dt); @@ -940,7 +940,7 @@ ENSURE(cmpObstructionManager); if (m_MoveRequest.m_Type == MoveRequest::POINT) - return cmpObstructionManager->IsInPointRange(GetEntityId(), m_MoveRequest.m_Position.X, m_MoveRequest.m_Position.Y, m_MoveRequest.m_MinRange, m_MoveRequest.m_MaxRange, false); + return cmpObstructionManager->IsInPointRange(GetEntityId(), m_MoveRequest.m_Position.getX(), m_MoveRequest.m_Position.getY(), m_MoveRequest.m_MinRange, m_MoveRequest.m_MaxRange, false); if (m_MoveRequest.m_Type == MoveRequest::ENTITY) return cmpObstructionManager->IsInTargetRange(GetEntityId(), m_MoveRequest.m_Entity, m_MoveRequest.m_MinRange, m_MoveRequest.m_MaxRange, false); if (m_MoveRequest.m_Type == MoveRequest::OFFSET) @@ -952,7 +952,7 @@ CFixedVector2D targetPos; ComputeTargetPosition(targetPos); CmpPtr cmpPosition(GetEntityHandle()); - return cmpObstructionManager->IsInPointRange(GetEntityId(), targetPos.X, targetPos.Y, m_MoveRequest.m_MinRange, m_MoveRequest.m_MaxRange, false); + return cmpObstructionManager->IsInPointRange(GetEntityId(), targetPos.getX(), targetPos.getY(), m_MoveRequest.m_MinRange, m_MoveRequest.m_MaxRange, false); } return false; } @@ -1009,7 +1009,7 @@ if (turnRate > zero) { fixed maxRotation = turnRate.Multiply(timeLeft); - fixed angleDiff = angle - atan2_approx(offset.X, offset.Y); + fixed angleDiff = angle - atan2_approx(offset.getX(), offset.getY()); if (angleDiff != zero) { fixed absoluteAngleDiff = angleDiff.Absolute(); @@ -1028,7 +1028,7 @@ break; } // Rotate towards the next waypoint and continue moving. - angle = atan2_approx(offset.X, offset.Y); + angle = atan2_approx(offset.getX(), offset.getY()); // Give some 'free' rotation for angles below 0.5 radians. timeLeft = (std::min(maxRotation, maxRotation - absoluteAngleDiff + fixed::FromInt(1)/2)) / turnRate; } @@ -1041,7 +1041,7 @@ fixed offsetLength = offset.Length(); if (offsetLength <= maxdist) { - if (cmpPathfinder->CheckMovement(GetObstructionFilter(), pos.X, pos.Y, target.X, target.Y, m_Clearance, m_PassClass)) + if (cmpPathfinder->CheckMovement(GetObstructionFilter(), pos.getX(), pos.getY(), target.getX(), target.getY(), m_Clearance, m_PassClass)) { pos = target; @@ -1067,7 +1067,7 @@ offset.Normalize(maxdist); target = pos + offset; - if (cmpPathfinder->CheckMovement(GetObstructionFilter(), pos.X, pos.Y, target.X, target.Y, m_Clearance, m_PassClass)) + if (cmpPathfinder->CheckMovement(GetObstructionFilter(), pos.getX(), pos.getY(), target.getX(), target.getY(), m_Clearance, m_PassClass)) pos = target; else return true; @@ -1195,7 +1195,7 @@ if (moveRequest.m_Type == MoveRequest::OFFSET) { // There is an offset, so compute it relative to orientation - entity_angle_t angle = cmpTargetPosition->GetRotation().Y; + entity_angle_t angle = cmpTargetPosition->GetRotation().getY(); CFixedVector2D offset = moveRequest.GetOffset().Rotate(angle); out = cmpTargetPosition->GetPosition2D() + offset; } @@ -1244,8 +1244,8 @@ PathGoal goal; if (!ComputeGoal(goal, m_MoveRequest)) return false; - goal.x = targetPos.X; - goal.z = targetPos.Y; + goal.x = targetPos.getX(); + goal.z = targetPos.getY(); // (we ignore changes to the target's rotation, since only buildings are // square and buildings don't move) @@ -1264,10 +1264,10 @@ if (specificIgnore.valid()) { - if (!cmpPathfinder->CheckMovement(SkipTagObstructionFilter(specificIgnore), from.X, from.Y, goalPos.X, goalPos.Y, m_Clearance, m_PassClass)) + if (!cmpPathfinder->CheckMovement(SkipTagObstructionFilter(specificIgnore), from.getX(), from.getY(), goalPos.getX(), goalPos.getY(), m_Clearance, m_PassClass)) return false; } - else if (!cmpPathfinder->CheckMovement(GetObstructionFilter(), from.X, from.Y, goalPos.X, goalPos.Y, m_Clearance, m_PassClass)) + else if (!cmpPathfinder->CheckMovement(GetObstructionFilter(), from.getX(), from.getY(), goalPos.getX(), goalPos.getY(), m_Clearance, m_PassClass)) return false; @@ -1274,7 +1274,7 @@ // That route is okay, so update our path m_LongPath.m_Waypoints.clear(); m_ShortPath.m_Waypoints.clear(); - m_ShortPath.m_Waypoints.emplace_back(Waypoint{ goalPos.X, goalPos.Y }); + m_ShortPath.m_Waypoints.emplace_back(Waypoint{ goalPos.getX(), goalPos.getY() }); return true; } @@ -1302,8 +1302,8 @@ cmpTargetObstruction->GetObstructionSquare(estimatedTargetShape); } - estimatedTargetShape.x = targetPos.X; - estimatedTargetShape.z = targetPos.Y; + estimatedTargetShape.x = targetPos.getX(); + estimatedTargetShape.z = targetPos.getY(); CmpPtr cmpObstruction(GetEntityHandle()); ICmpObstructionManager::ObstructionSquare shape; @@ -1313,8 +1313,8 @@ // Translate our own obstruction shape to our last waypoint or our current position, lacking that. if (m_LongPath.m_Waypoints.empty() && m_ShortPath.m_Waypoints.empty()) { - shape.x = from.X; - shape.z = from.Y; + shape.x = from.getX(); + shape.z = from.getY(); } else { @@ -1358,7 +1358,7 @@ CFixedVector2D offset = target - pos; if (!offset.IsZero()) { - entity_angle_t angle = atan2_approx(offset.X, offset.Y); + entity_angle_t angle = atan2_approx(offset.getX(), offset.getY()); CmpPtr cmpPosition(GetEntityHandle()); if (!cmpPosition) @@ -1407,8 +1407,8 @@ if (cmpTargetObstruction) cmpTargetObstruction->GetObstructionSquare(targetObstruction); } - targetObstruction.x = targetPosition.X; - targetObstruction.z = targetPosition.Y; + targetObstruction.x = targetPosition.getX(); + targetObstruction.z = targetPosition.getY(); ICmpObstructionManager::ObstructionSquare obstruction; CmpPtr cmpObstruction(GetEntityHandle()); @@ -1416,8 +1416,8 @@ cmpObstruction->GetObstructionSquare(obstruction); else { - obstruction.x = pos.X; - obstruction.z = pos.Y; + obstruction.x = pos.getX(); + obstruction.z = pos.getY(); } CmpPtr cmpObstructionManager(GetSystemEntity()); @@ -1552,10 +1552,10 @@ PathGoal improvedGoal = goal; improvedGoal.maxdist = SHORT_PATH_MIN_SEARCH_RANGE - entity_pos_t::FromInt(1); - cmpPathfinder->SetDebugPath(from.X, from.Y, improvedGoal, m_PassClass); + cmpPathfinder->SetDebugPath(from.getX(), from.getY(), improvedGoal, m_PassClass); m_ExpectedPathTicket.m_Type = Ticket::LONG_PATH; - m_ExpectedPathTicket.m_Ticket = cmpPathfinder->ComputePathAsync(from.X, from.Y, improvedGoal, m_PassClass, GetEntityId()); + m_ExpectedPathTicket.m_Ticket = cmpPathfinder->ComputePathAsync(from.getX(), from.getY(), improvedGoal, m_PassClass, GetEntityId()); } void CCmpUnitMotion::RequestShortPath(const CFixedVector2D &from, const PathGoal& goal, bool extendRange) @@ -1567,13 +1567,13 @@ entity_pos_t searchRange = ShortPathSearchRange(); if (extendRange) { - CFixedVector2D dist(from.X - goal.x, from.Y - goal.z); + CFixedVector2D dist(from.getX() - goal.x, from.getY() - goal.z); if (dist.CompareLength(searchRange - entity_pos_t::FromInt(1)) >= 0) searchRange = dist.Length() + fixed::FromInt(1); } m_ExpectedPathTicket.m_Type = Ticket::SHORT_PATH; - m_ExpectedPathTicket.m_Ticket = cmpPathfinder->ComputeShortPathAsync(from.X, from.Y, m_Clearance, searchRange, goal, m_PassClass, true, GetGroup(), GetEntityId()); + m_ExpectedPathTicket.m_Ticket = cmpPathfinder->ComputeShortPathAsync(from.getX(), from.getY(), m_Clearance, searchRange, goal, m_PassClass, true, GetGroup(), GetEntityId()); } bool CCmpUnitMotion::MoveTo(MoveRequest request) @@ -1612,7 +1612,7 @@ CmpPtr cmpPathfinder(GetSimContext(), SYSTEM_ENTITY); CFixedVector2D pos = cmpPosition->GetPosition2D(); - return cmpPathfinder->IsGoalReachable(pos.X, pos.Y, goal, m_PassClass); + return cmpPathfinder->IsGoalReachable(pos.getX(), pos.getY(), goal, m_PassClass); } @@ -1635,8 +1635,8 @@ lines.back().m_Color = color; SimRender::ConstructSquareOnGround(GetSimContext(), x, z, 1.0f, 1.0f, 0.0f, lines.back(), floating); } - float x = cmpPosition->GetPosition2D().X.ToFloat(); - float z = cmpPosition->GetPosition2D().Y.ToFloat(); + float x = cmpPosition->GetPosition2D().getX().ToFloat(); + float z = cmpPosition->GetPosition2D().getY().ToFloat(); waypointCoords.push_back(x); waypointCoords.push_back(z); lines.push_back(SOverlayLine()); Index: 0ad/source/simulation2/components/tests/test_RangeManager.h =================================================================== --- 0ad/source/simulation2/components/tests/test_RangeManager.h (revision 24769) +++ 0ad/source/simulation2/components/tests/test_RangeManager.h (working copy) @@ -60,7 +60,7 @@ virtual void SetActorFloating(bool UNUSED(flag)) { } virtual void SetConstructionProgress(fixed UNUSED(progress)) { } virtual CFixedVector3D GetPosition() const { return m_Pos; } - virtual CFixedVector2D GetPosition2D() const { return CFixedVector2D(m_Pos.X, m_Pos.Z); } + virtual CFixedVector2D GetPosition2D() const { return CFixedVector2D(m_Pos.getX(), m_Pos.getZ()); } virtual CFixedVector3D GetPreviousPosition() const { return CFixedVector3D(); } virtual CFixedVector2D GetPreviousPosition2D() const { return CFixedVector2D(); } virtual fixed GetTurnRate() const { return fixed::Zero(); } Index: 0ad/source/simulation2/helpers/Geometry.cpp =================================================================== --- 0ad/source/simulation2/helpers/Geometry.cpp (revision 24769) +++ 0ad/source/simulation2/helpers/Geometry.cpp (working copy) @@ -27,8 +27,8 @@ CFixedVector2D GetHalfBoundingBox(const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize) { return CFixedVector2D( - u.X.Multiply(halfSize.X).Absolute() + v.X.Multiply(halfSize.Y).Absolute(), - u.Y.Multiply(halfSize.X).Absolute() + v.Y.Multiply(halfSize.Y).Absolute() + u.getX().Multiply(halfSize.getX()).Absolute() + v.getX().Multiply(halfSize.getY()).Absolute(), + u.getY().Multiply(halfSize.getX()).Absolute() + v.getY().Multiply(halfSize.getY()).Absolute() ); } @@ -65,8 +65,8 @@ fixed du = point.Dot(u).Absolute(); fixed dv = point.Dot(v).Absolute(); - fixed hw = halfSize.X; - fixed hh = halfSize.Y; + fixed hw = halfSize.getX(); + fixed hh = halfSize.getY(); if (du < hw) // regions B, I, G { @@ -93,8 +93,8 @@ fixed du = point.Dot(u).Absolute(); fixed dv = point.Dot(v).Absolute(); - fixed hw = halfSize.X; - fixed hh = halfSize.Y; + fixed hw = halfSize.getX(); + fixed hh = halfSize.getY(); if (du < hw) // regions B, I, G { @@ -144,8 +144,8 @@ fixed du = point.Dot(u); fixed dv = point.Dot(v); - fixed hw = halfSize.X; - fixed hh = halfSize.Y; + fixed hw = halfSize.getX(); + fixed hh = halfSize.getY(); if (-hw < du && du < hw) // regions B, G; or regions D, E inside the square { @@ -196,10 +196,10 @@ * we depend on DistanceToSquare's countInsideAsZero. When no point is inside the other square, * it is enough to check that two adjacent edges of one square does not collide with the other square. */ - fixed hw1 = halfSize1.X; - fixed hh1 = halfSize1.Y; - fixed hw2 = halfSize2.X; - fixed hh2 = halfSize2.Y; + fixed hw1 = halfSize1.getX(); + fixed hh1 = halfSize1.getY(); + fixed hw2 = halfSize2.getX(); + fixed hh2 = halfSize2.getY(); if (TestRaySquare(relativePos + u1.Multiply(hw1) + v1.Multiply(hh1), relativePos - u1.Multiply(hw1) + v1.Multiply(hh1), u2, v2, halfSize2) || TestRaySquare(relativePos + u1.Multiply(hw1) + v1.Multiply(hh1), relativePos + u1.Multiply(hw1) - v1.Multiply(hh1), u2, v2, halfSize2)) return fixed::Zero(); @@ -220,8 +220,8 @@ fixed MaxDistanceToSquare(const CFixedVector2D& point, const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize, bool countInsideAsZero) { - fixed hw = halfSize.X; - fixed hh = halfSize.Y; + fixed hw = halfSize.getX(); + fixed hh = halfSize.getY(); if (point.Dot(u).Absolute() < hw && point.Dot(v).Absolute() < hh && countInsideAsZero) return fixed::Zero(); @@ -244,8 +244,8 @@ * The maximum distance from an edge of a square to the edge of another square * equals the greatest distance from the any of the 16 corner corner distances. */ - fixed hw1 = halfSize1.X; - fixed hh1 = halfSize1.Y; + fixed hw1 = halfSize1.getX(); + fixed hh1 = halfSize1.getY(); return std::max(std::max( MaxDistanceToSquare(relativePos + u1.Multiply(hw1) + v1.Multiply(hh1), u2, v2, halfSize2, true), @@ -269,8 +269,8 @@ * (Points on the edge are considered 'inside'.) */ - fixed hw = halfSize.X; - fixed hh = halfSize.Y; + fixed hw = halfSize.getX(); + fixed hh = halfSize.getY(); fixed au = a.Dot(u); fixed av = a.Dot(v); @@ -305,16 +305,16 @@ // Exactly like TestRaySquare with u=(1,0), v=(0,1) bool TestRayAASquare(const CFixedVector2D& a, const CFixedVector2D& b, const CFixedVector2D& halfSize) { - fixed hw = halfSize.X; - fixed hh = halfSize.Y; + fixed hw = halfSize.getX(); + fixed hh = halfSize.getY(); - if (-hw <= a.X && a.X <= hw && -hh <= a.Y && a.Y <= hh) + if (-hw <= a.getX() && a.getX() <= hw && -hh <= a.getY() && a.getY() <= hh) return false; // a is inside - if (-hw <= b.X && b.X <= hw && -hh <= b.Y && b.Y <= hh) // TODO: isn't this subsumed by the next checks? + if (-hw <= b.getX() && b.getX() <= hw && -hh <= b.getY() && b.getY() <= hh) // TODO: isn't this subsumed by the next checks? return true; // a is outside, b is inside - if ((a.X < -hw && b.X < -hw) || (a.X > hw && b.X > hw) || (a.Y < -hh && b.Y < -hh) || (a.Y > hh && b.Y > hh)) + if ((a.getX() < -hw && b.getX() < -hw) || (a.getX() > hw && b.getX() > hw) || (a.getY() < -hh && b.getY() < -hh) || (a.getY() > hh && b.getY() > hh)) return false; // ab is entirely above/below/side the square CFixedVector2D abp = (b - a).Perpendicular(); @@ -338,8 +338,8 @@ */ static bool SquareSAT(const CFixedVector2D& a, const CFixedVector2D& axis, const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize) { - fixed hw = halfSize.X; - fixed hh = halfSize.Y; + fixed hw = halfSize.getX(); + fixed hh = halfSize.getY(); CFixedVector2D p = axis.Perpendicular(); if (p.RelativeOrientation(u.Multiply(hw) + v.Multiply(hh) - a) <= 0) @@ -360,10 +360,10 @@ { // TODO: need to test this carefully - CFixedVector2D corner0a = c0 + u0.Multiply(halfSize0.X) + v0.Multiply(halfSize0.Y); - CFixedVector2D corner0b = c0 - u0.Multiply(halfSize0.X) - v0.Multiply(halfSize0.Y); - CFixedVector2D corner1a = c1 + u1.Multiply(halfSize1.X) + v1.Multiply(halfSize1.Y); - CFixedVector2D corner1b = c1 - u1.Multiply(halfSize1.X) - v1.Multiply(halfSize1.Y); + CFixedVector2D corner0a = c0 + u0.Multiply(halfSize0.getX()) + v0.Multiply(halfSize0.getY()); + CFixedVector2D corner0b = c0 - u0.Multiply(halfSize0.getX()) - v0.Multiply(halfSize0.getY()); + CFixedVector2D corner1a = c1 + u1.Multiply(halfSize1.getX()) + v1.Multiply(halfSize1.getY()); + CFixedVector2D corner1b = c1 - u1.Multiply(halfSize1.getX()) - v1.Multiply(halfSize1.getY()); // Do a SAT test for each square vs each edge of the other square if (!SquareSAT(corner0a - c1, -u0, u1, v1, halfSize1)) Index: 0ad/source/simulation2/helpers/Geometry.h =================================================================== --- 0ad/source/simulation2/helpers/Geometry.h (revision 24769) +++ 0ad/source/simulation2/helpers/Geometry.h (working copy) @@ -41,7 +41,7 @@ */ inline bool PointIsInSquare(const CFixedVector2D& point, const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize) { - return point.Dot(u).Absolute() <= halfSize.X && point.Dot(v).Absolute() <= halfSize.Y; + return point.Dot(u).Absolute() <= halfSize.getX() && point.Dot(v).Absolute() <= halfSize.getY(); } /** Index: 0ad/source/simulation2/helpers/HierarchicalPathfinder.cpp =================================================================== --- 0ad/source/simulation2/helpers/HierarchicalPathfinder.cpp (revision 24769) +++ 0ad/source/simulation2/helpers/HierarchicalPathfinder.cpp (working copy) @@ -601,8 +601,8 @@ chunks[region.cj * m_ChunksW + region.ci].RegionCenter(region.r, i1, j1); CFixedVector2D a, b; - Pathfinding::NavcellCenter(i0, j0, a.X, a.Y); - Pathfinding::NavcellCenter(i1, j1, b.X, b.Y); + Pathfinding::NavcellCenter(i0, j0, a.Xref(), a.Yref()); + Pathfinding::NavcellCenter(i1, j1, b.Xref(), b.Yref()); // Push the endpoints inwards a little to avoid overlaps CFixedVector2D d = b - a; @@ -611,10 +611,10 @@ b -= d; std::vector xz; - xz.push_back(a.X.ToFloat()); - xz.push_back(a.Y.ToFloat()); - xz.push_back(b.X.ToFloat()); - xz.push_back(b.Y.ToFloat()); + xz.push_back(a.getX().ToFloat()); + xz.push_back(a.getY().ToFloat()); + xz.push_back(b.getX().ToFloat()); + xz.push_back(b.getY().ToFloat()); m_DebugOverlayLines.emplace_back(); m_DebugOverlayLines.back().m_Color = CColor(1.0, 1.0, 1.0, 1.0); Index: 0ad/source/simulation2/helpers/LongPathfinder.cpp =================================================================== --- 0ad/source/simulation2/helpers/LongPathfinder.cpp (revision 24769) +++ 0ad/source/simulation2/helpers/LongPathfinder.cpp (working copy) @@ -922,7 +922,7 @@ if (offset.CompareLength(maxDist) > 0) { offset.Normalize(maxDist); - path.m_Waypoints.emplace_back(Waypoint{ (start + offset).X, (start + offset).Y }); + path.m_Waypoints.emplace_back(Waypoint{ (start + offset).getX(), (start + offset).getY() }); } } @@ -944,7 +944,7 @@ // We are too far away from the previous waypoint, so create one in // between and continue with the improvement of the path prev = prev + (curr - prev) / 2; - newWaypoints.emplace_back(Waypoint{ prev.X, prev.Y }); + newWaypoints.emplace_back(Waypoint{ prev.getX(), prev.getY() }); } // If we're mostly straight, don't even bother. @@ -951,7 +951,7 @@ if ((ahead - curr).Perpendicular().Dot(curr - prev).Absolute() <= fixed::Epsilon() * 100) continue; - if (!Pathfinding::CheckLineMovement(prev.X, prev.Y, ahead.X, ahead.Y, passClass, *m_Grid)) + if (!Pathfinding::CheckLineMovement(prev.getX(), prev.getY(), ahead.getX(), ahead.getY(), passClass, *m_Grid)) { prev = CFixedVector2D(waypoints[k].x, waypoints[k].z); newWaypoints.push_back(waypoints[k]); Index: 0ad/source/simulation2/helpers/PathGoal.cpp =================================================================== --- 0ad/source/simulation2/helpers/PathGoal.cpp (revision 24769) +++ 0ad/source/simulation2/helpers/PathGoal.cpp (working copy) @@ -293,7 +293,7 @@ fixed PathGoal::DistanceToPoint(CFixedVector2D pos) const { - CFixedVector2D d(pos.X - x, pos.Y - z); + CFixedVector2D d(pos.getX() - x, pos.getY() - z); switch (type) { @@ -335,7 +335,7 @@ case CIRCLE: { - CFixedVector2D d(pos.X - x, pos.Y - z); + CFixedVector2D d(pos.getX() - x, pos.getY() - z); if (d.CompareLength(hw) <= 0) return pos; @@ -345,7 +345,7 @@ case INVERTED_CIRCLE: { - CFixedVector2D d(pos.X - x, pos.Y - z); + CFixedVector2D d(pos.getX() - x, pos.getY() - z); if (d.CompareLength(hw) >= 0) return pos; @@ -358,7 +358,7 @@ case SQUARE: { CFixedVector2D halfSize(hw, hh); - CFixedVector2D d(pos.X - x, pos.Y - z); + CFixedVector2D d(pos.getX() - x, pos.getY() - z); return Geometry::PointIsInSquare(d, u, v, halfSize) ? pos : g + Geometry::NearestPointOnSquare(d, u, v, halfSize); } @@ -366,7 +366,7 @@ case INVERTED_SQUARE: { CFixedVector2D halfSize(hw, hh); - CFixedVector2D d(pos.X - x, pos.Y - z); + CFixedVector2D d(pos.getX() - x, pos.getY() - z); return !Geometry::PointIsInSquare(d, u, v, halfSize) ? pos : g + Geometry::NearestPointOnSquare(d, u, v, halfSize); } Index: 0ad/source/simulation2/helpers/Rasterize.cpp =================================================================== --- 0ad/source/simulation2/helpers/Rasterize.cpp (revision 24769) +++ 0ad/source/simulation2/helpers/Rasterize.cpp (working copy) @@ -48,10 +48,10 @@ CFixedVector2D shapeHalfSize(CFixedVector2D(shape.hw, shape.hh)); CFixedVector2D halfSize(shape.hw + rasterClearance, shape.hh + rasterClearance); CFixedVector2D halfBound = Geometry::GetHalfBoundingBox(shape.u, shape.v, halfSize); - i16 i0 = ((shape.x - halfBound.X) / cellSize).ToInt_RoundToNegInfinity(); - i16 j0 = ((shape.z - halfBound.Y) / cellSize).ToInt_RoundToNegInfinity(); - i16 i1 = ((shape.x + halfBound.X) / cellSize).ToInt_RoundToInfinity(); - i16 j1 = ((shape.z + halfBound.Y) / cellSize).ToInt_RoundToInfinity(); + i16 i0 = ((shape.x - halfBound.getX()) / cellSize).ToInt_RoundToNegInfinity(); + i16 j0 = ((shape.z - halfBound.getY()) / cellSize).ToInt_RoundToNegInfinity(); + i16 i1 = ((shape.x + halfBound.getX()) / cellSize).ToInt_RoundToInfinity(); + i16 j1 = ((shape.z + halfBound.getY()) / cellSize).ToInt_RoundToInfinity(); if (j1 <= j0) return; // empty bounds - this shouldn't happen Index: 0ad/source/simulation2/helpers/Render.cpp =================================================================== --- 0ad/source/simulation2/helpers/Render.cpp (revision 24769) +++ 0ad/source/simulation2/helpers/Render.cpp (working copy) @@ -603,8 +603,8 @@ void SimRender::ConstructTexturedLineBox(SOverlayTexturedLine& overlay, const CVector2D& origin, const CFixedVector3D& rotation, const float sizeX, const float sizeZ) { - float s = sinf(-rotation.Y.ToFloat()); - float c = cosf(-rotation.Y.ToFloat()); + float s = sinf(-rotation.getY().ToFloat()); + float c = cosf(-rotation.getY().ToFloat()); CVector2D unitX(c, s); CVector2D unitZ(-s, c); Index: 0ad/source/simulation2/helpers/Spatial.h =================================================================== --- 0ad/source/simulation2/helpers/Spatial.h (revision 24769) +++ 0ad/source/simulation2/helpers/Spatial.h (working copy) @@ -156,12 +156,12 @@ */ void Add(uint32_t item, CFixedVector2D toMin, CFixedVector2D toMax) { - ENSURE(toMin.X <= toMax.X && toMin.Y <= toMax.Y); + ENSURE(toMin.getX() <= toMax.getX() && toMin.getY() <= toMax.getY()); - u32 i0 = GetI0(toMin.X); - u32 j0 = GetJ0(toMin.Y); - u32 i1 = GetI1(toMax.X); - u32 j1 = GetJ1(toMax.Y); + u32 i0 = GetI0(toMin.getX()); + u32 j0 = GetJ0(toMin.getY()); + u32 i1 = GetI1(toMax.getX()); + u32 j1 = GetJ1(toMax.getY()); for (u32 j = j0; j <= j1; ++j) { for (u32 i = i0; i <= i1; ++i) @@ -178,12 +178,12 @@ */ void Remove(uint32_t item, CFixedVector2D fromMin, CFixedVector2D fromMax) { - ENSURE(fromMin.X <= fromMax.X && fromMin.Y <= fromMax.Y); + ENSURE(fromMin.getX() <= fromMax.getX() && fromMin.getY() <= fromMax.getY()); - u32 i0 = GetI0(fromMin.X); - u32 j0 = GetJ0(fromMin.Y); - u32 i1 = GetI1(fromMax.X); - u32 j1 = GetJ1(fromMax.Y); + u32 i0 = GetI0(fromMin.getX()); + u32 j0 = GetJ0(fromMin.getY()); + u32 i1 = GetI1(fromMax.getX()); + u32 j1 = GetJ1(fromMax.getY()); for (u32 j = j0; j <= j1; ++j) { for (u32 i = i0; i <= i1; ++i) @@ -247,12 +247,12 @@ void GetInRange(std::vector& out, CFixedVector2D posMin, CFixedVector2D posMax) const { out.clear(); - ENSURE(posMin.X <= posMax.X && posMin.Y <= posMax.Y); + ENSURE(posMin.getX() <= posMax.getX() && posMin.getY() <= posMax.getY()); - u32 i0 = GetI0(posMin.X); - u32 j0 = GetJ0(posMin.Y); - u32 i1 = GetI1(posMax.X); - u32 j1 = GetJ1(posMax.Y); + u32 i0 = GetI0(posMin.getX()); + u32 j0 = GetJ0(posMin.getY()); + u32 i1 = GetI1(posMax.getX()); + u32 j1 = GetJ1(posMax.getY()); for (u32 j = j0; j <= j1; ++j) { for (u32 i = i0; i <= i1; ++i) @@ -304,12 +304,12 @@ uint32_t GetIndex0(CFixedVector2D pos) const { - return GetI0(pos.X) + GetJ0(pos.Y)*m_DivisionsW; + return GetI0(pos.getX()) + GetJ0(pos.getY())*m_DivisionsW; } uint32_t GetIndex1(CFixedVector2D pos) const { - return GetI1(pos.X) + GetJ1(pos.Y)*m_DivisionsW; + return GetI1(pos.getX()) + GetJ1(pos.getY())*m_DivisionsW; } }; @@ -379,7 +379,7 @@ inline size_t SubdivisionIdx(CFixedVector2D position) const { - return Index(position.X) + Index(position.Y)*m_ArrayWidth; + return Index(position.getX()) + Index(position.getY())*m_ArrayWidth; } /** @@ -516,10 +516,10 @@ */ void GetInRange(std::vector& out, CFixedVector2D posMin, CFixedVector2D posMax) const { - size_t minX = Index(posMin.X); - size_t minY = Index(posMin.Y); - size_t maxX = Index(posMax.X) + 1; - size_t maxY = Index(posMax.Y) + 1; + size_t minX = Index(posMin.getX()); + size_t minY = Index(posMin.getY()); + size_t maxX = Index(posMax.getX()) + 1; + size_t maxY = Index(posMax.getY()) + 1; // Now expand the subdivisions by one so we make sure we've got all elements potentially in range. // Also make sure min >= 0 and max <= width Index: 0ad/source/simulation2/helpers/VertexPathfinder.cpp =================================================================== --- 0ad/source/simulation2/helpers/VertexPathfinder.cpp (revision 24769) +++ 0ad/source/simulation2/helpers/VertexPathfinder.cpp (working copy) @@ -139,7 +139,7 @@ inline static bool CheckVisibilityLeft(const CFixedVector2D& a, const CFixedVector2D& b, const std::vector& edges) { - if (a.X >= b.X) + if (a.getX() >= b.getX()) return true; CFixedVector2D abn = (b - a).Perpendicular(); @@ -146,15 +146,15 @@ for (size_t i = 0; i < edges.size(); ++i) { - if (b.X < edges[i].p0.X) + if (b.getX() < edges[i].p0.getX()) continue; - CFixedVector2D p0 (edges[i].p0.X, edges[i].c1); + CFixedVector2D p0 (edges[i].p0.getX(), edges[i].c1); fixed s = (p0 - a).Dot(abn); if (s > fixed::Zero()) continue; - CFixedVector2D p1 (edges[i].p0.X, edges[i].p0.Y); + CFixedVector2D p1 (edges[i].p0.getX(), edges[i].p0.getY()); fixed t = (p1 - a).Dot(abn); if (t < fixed::Zero()) continue; @@ -167,7 +167,7 @@ inline static bool CheckVisibilityRight(const CFixedVector2D& a, const CFixedVector2D& b, const std::vector& edges) { - if (a.X <= b.X) + if (a.getX() <= b.getX()) return true; CFixedVector2D abn = (b - a).Perpendicular(); @@ -174,15 +174,15 @@ for (size_t i = 0; i < edges.size(); ++i) { - if (b.X > edges[i].p0.X) + if (b.getX() > edges[i].p0.getX()) continue; - CFixedVector2D p0 (edges[i].p0.X, edges[i].c1); + CFixedVector2D p0 (edges[i].p0.getX(), edges[i].c1); fixed s = (p0 - a).Dot(abn); if (s > fixed::Zero()) continue; - CFixedVector2D p1 (edges[i].p0.X, edges[i].p0.Y); + CFixedVector2D p1 (edges[i].p0.getX(), edges[i].p0.getY()); fixed t = (p1 - a).Dot(abn); if (t < fixed::Zero()) continue; @@ -195,7 +195,7 @@ inline static bool CheckVisibilityBottom(const CFixedVector2D& a, const CFixedVector2D& b, const std::vector& edges) { - if (a.Y >= b.Y) + if (a.getY() >= b.getY()) return true; CFixedVector2D abn = (b - a).Perpendicular(); @@ -202,15 +202,15 @@ for (size_t i = 0; i < edges.size(); ++i) { - if (b.Y < edges[i].p0.Y) + if (b.getY() < edges[i].p0.getY()) continue; - CFixedVector2D p0 (edges[i].p0.X, edges[i].p0.Y); + CFixedVector2D p0 (edges[i].p0.getX(), edges[i].p0.getY()); fixed s = (p0 - a).Dot(abn); if (s > fixed::Zero()) continue; - CFixedVector2D p1 (edges[i].c1, edges[i].p0.Y); + CFixedVector2D p1 (edges[i].c1, edges[i].p0.getY()); fixed t = (p1 - a).Dot(abn); if (t < fixed::Zero()) continue; @@ -223,7 +223,7 @@ inline static bool CheckVisibilityTop(const CFixedVector2D& a, const CFixedVector2D& b, const std::vector& edges) { - if (a.Y <= b.Y) + if (a.getY() <= b.getY()) return true; CFixedVector2D abn = (b - a).Perpendicular(); @@ -230,15 +230,15 @@ for (size_t i = 0; i < edges.size(); ++i) { - if (b.Y > edges[i].p0.Y) + if (b.getY() > edges[i].p0.getY()) continue; - CFixedVector2D p0 (edges[i].p0.X, edges[i].p0.Y); + CFixedVector2D p0 (edges[i].p0.getX(), edges[i].p0.getY()); fixed s = (p0 - a).Dot(abn); if (s > fixed::Zero()) continue; - CFixedVector2D p1 (edges[i].c1, edges[i].p0.Y); + CFixedVector2D p1 (edges[i].c1, edges[i].p0.getY()); fixed t = (p1 - a).Dot(abn); if (t < fixed::Zero()) continue; @@ -449,46 +449,46 @@ for (const Square& square : squares) { - if (a.X <= square.p0.X) - edgesLeft.emplace_back(EdgeAA{ square.p0, square.p1.Y }); - if (a.X >= square.p1.X) - edgesRight.emplace_back(EdgeAA{ square.p1, square.p0.Y }); - if (a.Y <= square.p0.Y) - edgesBottom.emplace_back(EdgeAA{ square.p0, square.p1.X }); - if (a.Y >= square.p1.Y) - edgesTop.emplace_back(EdgeAA{ square.p1, square.p0.X }); + if (a.getX() <= square.p0.getX()) + edgesLeft.emplace_back(EdgeAA{ square.p0, square.p1.getY() }); + if (a.getX() >= square.p1.getX()) + edgesRight.emplace_back(EdgeAA{ square.p1, square.p0.getY() }); + if (a.getY() <= square.p0.getY()) + edgesBottom.emplace_back(EdgeAA{ square.p0, square.p1.getX() }); + if (a.getY() >= square.p1.getY()) + edgesTop.emplace_back(EdgeAA{ square.p1, square.p0.getX() }); } for (const Edge& edge : edges) { - if (edge.p0.X == edge.p1.X) + if (edge.p0.getX() == edge.p1.getX()) { - if (edge.p1.Y < edge.p0.Y) + if (edge.p1.getY() < edge.p0.getY()) { - if (!(a.X <= edge.p0.X)) + if (!(a.getX() <= edge.p0.getX())) continue; - edgesLeft.emplace_back(EdgeAA{ edge.p1, edge.p0.Y }); + edgesLeft.emplace_back(EdgeAA{ edge.p1, edge.p0.getY() }); } else { - if (!(a.X >= edge.p0.X)) + if (!(a.getX() >= edge.p0.getX())) continue; - edgesRight.emplace_back(EdgeAA{ edge.p1, edge.p0.Y }); + edgesRight.emplace_back(EdgeAA{ edge.p1, edge.p0.getY() }); } } - else if (edge.p0.Y == edge.p1.Y) + else if (edge.p0.getY() == edge.p1.getY()) { - if (edge.p0.X < edge.p1.X) + if (edge.p0.getX() < edge.p1.getX()) { - if (!(a.Y <= edge.p0.Y)) + if (!(a.getY() <= edge.p0.getY())) continue; - edgesBottom.emplace_back(EdgeAA{ edge.p0, edge.p1.X }); + edgesBottom.emplace_back(EdgeAA{ edge.p0, edge.p1.getX() }); } else { - if (!(a.Y >= edge.p0.Y)) + if (!(a.getY() >= edge.p0.getY())) continue; - edgesTop.emplace_back(EdgeAA{ edge.p0, edge.p1.X }); + edgesTop.emplace_back(EdgeAA{ edge.p0, edge.p1.getX() }); } } else @@ -537,10 +537,10 @@ { fixed toGoalLength = toGoal.Length(); fixed inv = fixed::FromInt(1) / toGoalLength; - rangeXMin += (toGoal.Multiply(std::min(toGoalLength / 2, request.range * 3 / 5)).Multiply(inv)).X; - rangeXMax += (toGoal.Multiply(std::min(toGoalLength / 2, request.range * 3 / 5)).Multiply(inv)).X; - rangeZMin += (toGoal.Multiply(std::min(toGoalLength / 2, request.range * 3 / 5)).Multiply(inv)).Y; - rangeZMax += (toGoal.Multiply(std::min(toGoalLength / 2, request.range * 3 / 5)).Multiply(inv)).Y; + rangeXMin += (toGoal.Multiply(std::min(toGoalLength / 2, request.range * 3 / 5)).Multiply(inv)).getX(); + rangeXMax += (toGoal.Multiply(std::min(toGoalLength / 2, request.range * 3 / 5)).Multiply(inv)).getX(); + rangeZMin += (toGoal.Multiply(std::min(toGoalLength / 2, request.range * 3 / 5)).Multiply(inv)).getY(); + rangeZMax += (toGoal.Multiply(std::min(toGoalLength / 2, request.range * 3 / 5)).Multiply(inv)).getY(); } // Add domain edges @@ -596,7 +596,7 @@ CFixedVector2D hd1(squares[i].hw + pathfindClearance + EDGE_EXPAND_DELTA, -(squares[i].hh + pathfindClearance + EDGE_EXPAND_DELTA)); // Check whether this is an axis-aligned square - bool aa = (u.X == fixed::FromInt(1) && u.Y == fixed::Zero() && v.X == fixed::Zero() && v.Y == fixed::FromInt(1)); + bool aa = (u.getX() == fixed::FromInt(1) && u.getY() == fixed::Zero() && v.getX() == fixed::Zero() && v.getY() == fixed::FromInt(1)); Vertex vert; vert.status = Vertex::UNEXPLORED; @@ -603,44 +603,44 @@ vert.quadInward = QUADRANT_NONE; vert.quadOutward = QUADRANT_ALL; - vert.p.X = center.X - hd0.Dot(u); - vert.p.Y = center.Y + hd0.Dot(v); + vert.p.Xref() = center.getX() - hd0.Dot(u); + vert.p.Yref() = center.getY() + hd0.Dot(v); if (aa) { vert.quadInward = QUADRANT_BR; vert.quadOutward = (~vert.quadInward) & 0xF; } - if (vert.p.X >= rangeXMin && vert.p.Y >= rangeZMin && vert.p.X <= rangeXMax && vert.p.Y <= rangeZMax) + if (vert.p.getX() >= rangeXMin && vert.p.getY() >= rangeZMin && vert.p.getX() <= rangeXMax && vert.p.getY() <= rangeZMax) m_Vertexes.push_back(vert); - vert.p.X = center.X - hd1.Dot(u); - vert.p.Y = center.Y + hd1.Dot(v); + vert.p.Xref() = center.getX() - hd1.Dot(u); + vert.p.Yref() = center.getY() + hd1.Dot(v); if (aa) { vert.quadInward = QUADRANT_TR; vert.quadOutward = (~vert.quadInward) & 0xF; } - if (vert.p.X >= rangeXMin && vert.p.Y >= rangeZMin && vert.p.X <= rangeXMax && vert.p.Y <= rangeZMax) + if (vert.p.getX() >= rangeXMin && vert.p.getY() >= rangeZMin && vert.p.getX() <= rangeXMax && vert.p.getY() <= rangeZMax) m_Vertexes.push_back(vert); - vert.p.X = center.X + hd0.Dot(u); - vert.p.Y = center.Y - hd0.Dot(v); + vert.p.Xref() = center.getX() + hd0.Dot(u); + vert.p.Yref() = center.getY() - hd0.Dot(v); if (aa) { vert.quadInward = QUADRANT_TL; vert.quadOutward = (~vert.quadInward) & 0xF; } - if (vert.p.X >= rangeXMin && vert.p.Y >= rangeZMin && vert.p.X <= rangeXMax && vert.p.Y <= rangeZMax) + if (vert.p.getX() >= rangeXMin && vert.p.getY() >= rangeZMin && vert.p.getX() <= rangeXMax && vert.p.getY() <= rangeZMax) m_Vertexes.push_back(vert); - vert.p.X = center.X + hd1.Dot(u); - vert.p.Y = center.Y - hd1.Dot(v); + vert.p.Xref() = center.getX() + hd1.Dot(u); + vert.p.Yref() = center.getY() - hd1.Dot(v); if (aa) { vert.quadInward = QUADRANT_BL; vert.quadOutward = (~vert.quadInward) & 0xF; } - if (vert.p.X >= rangeXMin && vert.p.Y >= rangeZMin && vert.p.X <= rangeXMax && vert.p.Y <= rangeZMax) + if (vert.p.getX() >= rangeXMin && vert.p.getY() >= rangeZMin && vert.p.getX() <= rangeXMax && vert.p.getY() <= rangeZMax) m_Vertexes.push_back(vert); // Add the edges: @@ -648,10 +648,10 @@ CFixedVector2D h0(squares[i].hw + pathfindClearance, squares[i].hh + pathfindClearance); CFixedVector2D h1(squares[i].hw + pathfindClearance, -(squares[i].hh + pathfindClearance)); - CFixedVector2D ev0(center.X - h0.Dot(u), center.Y + h0.Dot(v)); - CFixedVector2D ev1(center.X - h1.Dot(u), center.Y + h1.Dot(v)); - CFixedVector2D ev2(center.X + h0.Dot(u), center.Y - h0.Dot(v)); - CFixedVector2D ev3(center.X + h1.Dot(u), center.Y - h1.Dot(v)); + CFixedVector2D ev0(center.getX() - h0.Dot(u), center.getY() + h0.Dot(v)); + CFixedVector2D ev1(center.getX() - h1.Dot(u), center.getY() + h1.Dot(v)); + CFixedVector2D ev2(center.getX() + h0.Dot(u), center.getY() - h0.Dot(v)); + CFixedVector2D ev3(center.getX() + h1.Dot(u), center.getY() - h1.Dot(v)); if (aa) m_EdgeSquares.emplace_back(Square{ ev1, ev3 }); else @@ -676,19 +676,19 @@ for (size_t i = 2; i < m_EdgeSquares.size(); ++i) { // If the start point is inside the square, ignore it - if (start.p.X >= m_EdgeSquares[i].p0.X && - start.p.Y >= m_EdgeSquares[i].p0.Y && - start.p.X <= m_EdgeSquares[i].p1.X && - start.p.Y <= m_EdgeSquares[i].p1.Y) + if (start.p.getX() >= m_EdgeSquares[i].p0.getX() && + start.p.getY() >= m_EdgeSquares[i].p0.getY() && + start.p.getX() <= m_EdgeSquares[i].p1.getX() && + start.p.getY() <= m_EdgeSquares[i].p1.getY()) continue; // Remove every non-start/goal vertex that is inside an edgeSquare; // since remove() would be inefficient, just mark it as closed instead. for (size_t j = 2; j < m_Vertexes.size(); ++j) - if (m_Vertexes[j].p.X >= m_EdgeSquares[i].p0.X && - m_Vertexes[j].p.Y >= m_EdgeSquares[i].p0.Y && - m_Vertexes[j].p.X <= m_EdgeSquares[i].p1.X && - m_Vertexes[j].p.Y <= m_EdgeSquares[i].p1.Y) + if (m_Vertexes[j].p.getX() >= m_EdgeSquares[i].p0.getX() && + m_Vertexes[j].p.getY() >= m_EdgeSquares[i].p0.getY() && + m_Vertexes[j].p.getX() <= m_EdgeSquares[i].p1.getX() && + m_Vertexes[j].p.getY() <= m_EdgeSquares[i].p1.getY()) m_Vertexes[j].status = Vertex::CLOSED; } @@ -756,8 +756,8 @@ // To prevent integer overflows later on, we need to ensure all vertexes are // 'close' to the source. The goal might be far away (not a good idea but // sometimes it happens), so clamp it to the current search range - npos.X = Clamp(npos.X, rangeXMin + EDGE_EXPAND_DELTA, rangeXMax - EDGE_EXPAND_DELTA); - npos.Y = Clamp(npos.Y, rangeZMin + EDGE_EXPAND_DELTA, rangeZMax - EDGE_EXPAND_DELTA); + npos.Xref() = Clamp(npos.getX(), rangeXMin + EDGE_EXPAND_DELTA, rangeXMax - EDGE_EXPAND_DELTA); + npos.Yref() = Clamp(npos.getY(), rangeZMin + EDGE_EXPAND_DELTA, rangeZMax - EDGE_EXPAND_DELTA); } else npos = m_Vertexes[n].p; @@ -764,10 +764,10 @@ // Work out which quadrant(s) we're approaching the new vertex from u8 quad = 0; - if (m_Vertexes[curr.id].p.X <= npos.X && m_Vertexes[curr.id].p.Y <= npos.Y) quad |= QUADRANT_BL; - if (m_Vertexes[curr.id].p.X >= npos.X && m_Vertexes[curr.id].p.Y >= npos.Y) quad |= QUADRANT_TR; - if (m_Vertexes[curr.id].p.X <= npos.X && m_Vertexes[curr.id].p.Y >= npos.Y) quad |= QUADRANT_TL; - if (m_Vertexes[curr.id].p.X >= npos.X && m_Vertexes[curr.id].p.Y <= npos.Y) quad |= QUADRANT_BR; + if (m_Vertexes[curr.id].p.getX() <= npos.getX() && m_Vertexes[curr.id].p.getY() <= npos.getY()) quad |= QUADRANT_BL; + if (m_Vertexes[curr.id].p.getX() >= npos.getX() && m_Vertexes[curr.id].p.getY() >= npos.getY()) quad |= QUADRANT_TR; + if (m_Vertexes[curr.id].p.getX() <= npos.getX() && m_Vertexes[curr.id].p.getY() >= npos.getY()) quad |= QUADRANT_TL; + if (m_Vertexes[curr.id].p.getX() >= npos.getX() && m_Vertexes[curr.id].p.getY() <= npos.getY()) quad |= QUADRANT_BR; // Check that the new vertex is in the right quadrant for the old vertex if (!(m_Vertexes[curr.id].quadOutward & quad) && curr.id != START_VERTEX_ID) @@ -838,7 +838,7 @@ // Reconstruct the path (in reverse) WaypointPath path; for (u16 id = idBest; id != START_VERTEX_ID; id = m_Vertexes[id].pred) - path.m_Waypoints.emplace_back(Waypoint{ m_Vertexes[id].p.X, m_Vertexes[id].p.Y }); + path.m_Waypoints.emplace_back(Waypoint{ m_Vertexes[id].p.getX(), m_Vertexes[id].p.getY() }); m_Edges.clear(); @@ -880,7 +880,7 @@ case PathGoal::SQUARE: case PathGoal::INVERTED_SQUARE: { - float a = atan2f(goal.v.X.ToFloat(), goal.v.Y.ToFloat()); + float a = atan2f(goal.v.getX().ToFloat(), goal.v.getY().ToFloat()); SimRender::ConstructSquareOnGround(simContext, goal.x.ToFloat(), goal.z.ToFloat(), goal.hw.ToFloat()*2, goal.hh.ToFloat()*2, a, m_DebugOverlayShortPathLines.back(), true); break; } @@ -892,7 +892,7 @@ if (!m_DebugOverlay) return; -#define PUSH_POINT(p) STMT(xz.push_back(p.X.ToFloat()); xz.push_back(p.Y.ToFloat())) +#define PUSH_POINT(p) STMT(xz.push_back(p.getX().ToFloat()); xz.push_back(p.getY().ToFloat())) // Render the vertexes as little Pac-Man shapes to indicate quadrant direction for (size_t i = 0; i < vertexes.size(); ++i) { @@ -899,8 +899,8 @@ m_DebugOverlayShortPathLines.emplace_back(); m_DebugOverlayShortPathLines.back().m_Color = CColor(1, 1, 0, 1); - float x = vertexes[i].p.X.ToFloat(); - float z = vertexes[i].p.Y.ToFloat(); + float x = vertexes[i].p.getX().ToFloat(); + float z = vertexes[i].p.getY().ToFloat(); float a0 = 0, a1 = 0; // Get arc start/end angles depending on quadrant (if any) @@ -948,16 +948,16 @@ m_DebugOverlayShortPathLines.back().m_Color = CColor(0, 1, 1, 1); std::vector xz; Square s = edgeSquares[i]; - xz.push_back(s.p0.X.ToFloat()); - xz.push_back(s.p0.Y.ToFloat()); - xz.push_back(s.p0.X.ToFloat()); - xz.push_back(s.p1.Y.ToFloat()); - xz.push_back(s.p1.X.ToFloat()); - xz.push_back(s.p1.Y.ToFloat()); - xz.push_back(s.p1.X.ToFloat()); - xz.push_back(s.p0.Y.ToFloat()); - xz.push_back(s.p0.X.ToFloat()); - xz.push_back(s.p0.Y.ToFloat()); + xz.push_back(s.p0.getX().ToFloat()); + xz.push_back(s.p0.getY().ToFloat()); + xz.push_back(s.p0.getX().ToFloat()); + xz.push_back(s.p1.getY().ToFloat()); + xz.push_back(s.p1.getX().ToFloat()); + xz.push_back(s.p1.getY().ToFloat()); + xz.push_back(s.p1.getX().ToFloat()); + xz.push_back(s.p0.getY().ToFloat()); + xz.push_back(s.p0.getX().ToFloat()); + xz.push_back(s.p0.getY().ToFloat()); SimRender::ConstructLineOnGround(simContext, xz, m_DebugOverlayShortPathLines.back(), true); } } Index: 0ad/source/simulation2/scripting/EngineScriptConversions.cpp =================================================================== --- 0ad/source/simulation2/scripting/EngineScriptConversions.cpp (revision 24769) +++ 0ad/source/simulation2/scripting/EngineScriptConversions.cpp (working copy) @@ -145,13 +145,16 @@ JS::RootedValue p(rq.cx); if (!JS_GetProperty(rq.cx, obj, "x", &p)) return false; // TODO: report type errors - if (!FromJSVal(rq, p, out.X)) return false; + //auto x = out.getX(); + if (!FromJSVal(rq, p, out.Xref())) return false; if (!JS_GetProperty(rq.cx, obj, "y", &p)) return false; - if (!FromJSVal(rq, p, out.Y)) return false; + //auto y = out.getY(); + if (!FromJSVal(rq, p, out.Yref())) return false; if (!JS_GetProperty(rq.cx, obj, "z", &p)) return false; - if (!FromJSVal(rq, p, out.Z)) return false; + //auto z = out.getZ(); + if (!FromJSVal(rq, p, out.Zref())) return false; return true; } @@ -164,9 +167,9 @@ FAIL_VOID("Failed to get Vector3D constructor"); JS::RootedValueArray<3> args(rq.cx); - args[0].setNumber(val.X.ToDouble()); - args[1].setNumber(val.Y.ToDouble()); - args[2].setNumber(val.Z.ToDouble()); + args[0].setNumber(val.getX().ToDouble()); + args[1].setNumber(val.getY().ToDouble()); + args[2].setNumber(val.getZ().ToDouble()); JS::RootedObject objVec(rq.cx); if (!JS::Construct(rq.cx, valueVector3D, args, &objVec)) @@ -184,10 +187,10 @@ JS::RootedValue p(rq.cx); if (!JS_GetProperty(rq.cx, obj, "x", &p)) return false; // TODO: report type errors - if (!FromJSVal(rq, p, out.X)) return false; + if (!FromJSVal(rq, p, out.Xref())) return false; if (!JS_GetProperty(rq.cx, obj, "y", &p)) return false; - if (!FromJSVal(rq, p, out.Y)) return false; + if (!FromJSVal(rq, p, out.Yref())) return false; return true; } @@ -200,8 +203,8 @@ FAIL_VOID("Failed to get Vector2D constructor"); JS::RootedValueArray<2> args(rq.cx); - args[0].setNumber(val.X.ToDouble()); - args[1].setNumber(val.Y.ToDouble()); + args[0].setNumber(val.getX().ToDouble()); + args[1].setNumber(val.getY().ToDouble()); JS::RootedObject objVec(rq.cx); if (!JS::Construct(rq.cx, valueVector2D, args, &objVec)) Index: 0ad/source/simulation2/scripting/JSInterface_Simulation.cpp =================================================================== --- 0ad/source/simulation2/scripting/JSInterface_Simulation.cpp (revision 24769) +++ 0ad/source/simulation2/scripting/JSInterface_Simulation.cpp (working copy) @@ -147,16 +147,16 @@ continue; CFixedVector2D halfSize = cmpObstruction->GetStaticSize() / 2; - if (halfSize.X.IsZero() || halfSize.Y.IsZero() || std::max(halfSize.X, halfSize.Y) <= fixed::FromInt(2)) + if (halfSize.getX().IsZero() || halfSize.getY().IsZero() || std::max(halfSize.getX(), halfSize.getY()) <= fixed::FromInt(2)) continue; std::array corners = { - CFixedVector2D(-halfSize.X, -halfSize.Y), - CFixedVector2D(-halfSize.X, halfSize.Y), + CFixedVector2D(-halfSize.getX(), -halfSize.getY()), + CFixedVector2D(-halfSize.getX(), halfSize.getY()), halfSize, - CFixedVector2D(halfSize.X, -halfSize.Y) + CFixedVector2D(halfSize.getX(), -halfSize.getY()) }; - fixed angle = cmpPosition->GetRotation().Y; + fixed angle = cmpPosition->GetRotation().getY(); for (CFixedVector2D& corner : corners) corner = corner.Rotate(angle) + cmpPosition->GetPosition2D(); Index: 0ad/source/simulation2/serialization/SerializedPathfinder.h =================================================================== --- 0ad/source/simulation2/serialization/SerializedPathfinder.h (revision 24769) +++ 0ad/source/simulation2/serialization/SerializedPathfinder.h (working copy) @@ -45,10 +45,10 @@ Serializer(serialize, "type", value.type, PathGoal::INVERTED_SQUARE); serialize.NumberFixed_Unbounded("goal x", value.x); serialize.NumberFixed_Unbounded("goal z", value.z); - serialize.NumberFixed_Unbounded("goal u x", value.u.X); - serialize.NumberFixed_Unbounded("goal u z", value.u.Y); - serialize.NumberFixed_Unbounded("goal v x", value.v.X); - serialize.NumberFixed_Unbounded("goal v z", value.v.Y); + serialize.NumberFixed_Unbounded("goal u x", value.u.Xref()); + serialize.NumberFixed_Unbounded("goal u z", value.u.Yref()); + serialize.NumberFixed_Unbounded("goal v x", value.v.Xref()); + serialize.NumberFixed_Unbounded("goal v z", value.v.Yref()); serialize.NumberFixed_Unbounded("goal hw", value.hw); serialize.NumberFixed_Unbounded("goal hh", value.hh); serialize.NumberFixed_Unbounded("maxdist", value.maxdist); Index: 0ad/source/tools/atlas/GameInterface/ActorViewer.cpp =================================================================== --- 0ad/source/tools/atlas/GameInterface/ActorViewer.cpp (revision 24769) +++ 0ad/source/tools/atlas/GameInterface/ActorViewer.cpp (working copy) @@ -544,13 +544,13 @@ if (cmpPosition) { // Move the model by speed*simFrameLength forwards - float z = cmpPosition->GetPosition().Z.ToFloat(); + float z = cmpPosition->GetPosition().getZ().ToFloat(); z -= m.CurrentSpeed*simFrameLength; // Wrap at the edges, so it doesn't run off into the horizon ssize_t c = TERRAIN_TILE_SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2; if (z < c - TERRAIN_TILE_SIZE*PATCH_SIZE * 0.1f) z = c + TERRAIN_TILE_SIZE*PATCH_SIZE * 0.1f; - cmpPosition->JumpTo(cmpPosition->GetPosition().X, entity_pos_t::FromFloat(z)); + cmpPosition->JumpTo(cmpPosition->GetPosition().getX(), entity_pos_t::FromFloat(z)); } } } Index: 0ad/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp =================================================================== --- 0ad/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp (revision 24769) +++ 0ad/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp (working copy) @@ -66,13 +66,13 @@ sCinemaSplineNode ConstructCinemaNode(const SplineData& data) { sCinemaSplineNode node; - node.px = data.Position.X.ToFloat(); - node.py = data.Position.Y.ToFloat(); - node.pz = data.Position.Z.ToFloat(); + node.px = data.Position.getX().ToFloat(); + node.py = data.Position.getY().ToFloat(); + node.pz = data.Position.getZ().ToFloat(); - node.rx = data.Rotation.X.ToFloat(); - node.ry = data.Rotation.Y.ToFloat(); - node.rz = data.Rotation.Z.ToFloat(); + node.rx = data.Rotation.getX().ToFloat(); + node.ry = data.Rotation.getY().ToFloat(); + node.rz = data.Rotation.getZ().ToFloat(); node.t = data.Distance.ToFloat(); return node; @@ -406,9 +406,9 @@ // Get shift of the tool by the cursor movement CFixedVector3D pos = spline.GetAllNodes()[index].Position; CVector3D position( - pos.X.ToFloat(), - pos.Y.ToFloat(), - pos.Z.ToFloat() + pos.getX().ToFloat(), + pos.getY().ToFloat(), + pos.getZ().ToFloat() ); CVector3D axisDirection(axis & AXIS_X, axis & AXIS_Y, axis & AXIS_Z); CVector2D from, to; @@ -458,9 +458,9 @@ { const SplineData& data = spline.GetAllNodes()[i]; CVector3D position( - data.Position.X.ToFloat(), - data.Position.Y.ToFloat(), - data.Position.Z.ToFloat() + data.Position.getX().ToFloat(), + data.Position.getY().ToFloat(), + data.Position.getZ().ToFloat() ); CVector2D screen_pos; g_Game->GetView()->GetCamera()->GetScreenCoordinates(position, screen_pos.X, screen_pos.Y); @@ -521,7 +521,7 @@ const TNSpline& spline = msg->node->targetNode ? path.GetTargetSpline() : path; CFixedVector3D pos = spline.GetAllNodes()[index].Position; - CVector3D position(pos.X.ToFloat(), pos.Y.ToFloat(), pos.Z.ToFloat()); + CVector3D position(pos.getX().ToFloat(), pos.getY().ToFloat(), pos.getZ().ToFloat()); CVector3D camera = g_Game->GetView()->GetCamera()->GetOrientation().GetTranslation(); float scale = (position - camera).Length() / 10.0; Index: 0ad/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp =================================================================== --- 0ad/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp (revision 24769) +++ 0ad/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp (working copy) @@ -365,10 +365,10 @@ { bool Within(const CFixedVector3D& pos, const int centerX, const int centerZ, const int radius) { - int dx = abs(pos.X.ToInt_RoundToZero() - centerX); + int dx = abs(pos.getX().ToInt_RoundToZero() - centerX); if (dx > radius) return false; - int dz = abs(pos.Z.ToInt_RoundToZero() - centerZ); + int dz = abs(pos.getZ().ToInt_RoundToZero() - centerZ); if (dz > radius) return false; if (dx + dz <= radius) @@ -447,9 +447,9 @@ CmpPtr cmpPosition(sim, deleted.entityId); if (cmpPosition) { - cmpPosition->JumpTo(deleted.pos.X, deleted.pos.Z); - cmpPosition->SetXZRotation(deleted.rot.X, deleted.rot.Z); - cmpPosition->SetYRotation(deleted.rot.Y); + cmpPosition->JumpTo(deleted.pos.getX(), deleted.pos.getZ()); + cmpPosition->SetXZRotation(deleted.rot.getX(), deleted.rot.getZ()); + cmpPosition->SetYRotation(deleted.rot.getY()); } CmpPtr cmpOwnership(sim, deleted.entityId); @@ -471,7 +471,7 @@ const CFixedVector3D position = obj.second; CmpPtr cmpPosition(*g_Game->GetSimulation2(), id); ENSURE(cmpPosition); - cmpPosition->JumpTo(position.X, position.Z); + cmpPosition->JumpTo(position.getX(), position.getZ()); } } Index: 0ad/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp =================================================================== --- 0ad/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp (revision 24769) +++ 0ad/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp (working copy) @@ -279,13 +279,13 @@ CFixedVector3D rot = cmpPosition->GetRotation(); { XMLWriter_Element positionTag(exampleFile, "Position"); - positionTag.Attribute("x", pos.X); - positionTag.Attribute("z", pos.Z); + positionTag.Attribute("x", pos.getX()); + positionTag.Attribute("z", pos.getZ()); // TODO: height offset etc } { XMLWriter_Element orientationTag(exampleFile, "Orientation"); - orientationTag.Attribute("y", rot.Y); + orientationTag.Attribute("y", rot.getY()); // TODO: X, Z maybe } } @@ -436,7 +436,7 @@ //now rotate CFixedVector3D rotation = cmpPositionOld->GetRotation(); - cmpPositionNew->SetYRotation(rotation.Y); + cmpPositionNew->SetYRotation(rotation.getY()); } //get owner @@ -498,7 +498,7 @@ CFixedVector3D posFixed = cmpPreviewPosition->GetPosition(); posFinal = posFixed + dir; } - cmpPreviewPosition->JumpTo(posFinal.X, posFinal.Z); + cmpPreviewPosition->JumpTo(posFinal.getX(), posFinal.getZ()); } CheckObstructionAndUpdateVisual(id); @@ -665,7 +665,7 @@ else { CFixedVector3D fixed = cmpPosition->GetPosition(); - CVector3D centre = CVector3D(fixed.X.ToFloat(), fixed.Y.ToFloat(), fixed.Z.ToFloat()); + CVector3D centre = CVector3D(fixed.getX().ToFloat(), fixed.getY().ToFloat(), fixed.getZ().ToFloat()); float cx, cy; g_Game->GetView()->GetCamera()->GetScreenCoordinates(centre, cx, cy); @@ -736,7 +736,7 @@ { pivotFloating = cmpPositionPivot->CanFloat(); CFixedVector3D pivotFixed = cmpPositionPivot->GetPosition(); - pivotPos = CVector3D(pivotFixed.X.ToFloat(), pivotFixed.Y.ToFloat(), pivotFixed.Z.ToFloat()); + pivotPos = CVector3D(pivotFixed.getX().ToFloat(), pivotFixed.getY().ToFloat(), pivotFixed.getZ().ToFloat()); } // Calculate directional vector of movement for pivot object, @@ -756,7 +756,7 @@ { // Calculate this object's position CFixedVector3D posFixed = cmpPosition->GetPosition(); - CVector3D pos = CVector3D(posFixed.X.ToFloat(), posFixed.Y.ToFloat(), posFixed.Z.ToFloat()); + CVector3D pos = CVector3D(posFixed.getX().ToFloat(), posFixed.getY().ToFloat(), posFixed.getZ().ToFloat()); m_PosNew[id] = pos + dir; m_PosOld[id] = pos; } @@ -825,7 +825,7 @@ CVector3D pos = cmpPosition->GetPosition(); m_PosOld[id] = cmpPosition->GetPosition(); - m_AngleOld[id] = cmpPosition->GetRotation().Y.ToFloat(); + m_AngleOld[id] = cmpPosition->GetRotation().getY().ToFloat(); if (first) { @@ -950,7 +950,7 @@ if (!cmpPosition) return; - m_AngleOld[id] = cmpPosition->GetRotation().Y.ToFloat(); + m_AngleOld[id] = cmpPosition->GetRotation().getY().ToFloat(); CMatrix3D transform = cmpPosition->GetInterpolatedTransform(0.f); CVector3D pos = transform.GetTranslation(); @@ -1068,9 +1068,9 @@ CmpPtr cmpPosition(sim, oldObjects[i].entityID); if (cmpPosition) { - cmpPosition->JumpTo(oldObjects[i].pos.X, oldObjects[i].pos.Z); - cmpPosition->SetXZRotation(oldObjects[i].rot.X, oldObjects[i].rot.Z); - cmpPosition->SetYRotation(oldObjects[i].rot.Y); + cmpPosition->JumpTo(oldObjects[i].pos.getX(), oldObjects[i].pos.getZ()); + cmpPosition->SetXZRotation(oldObjects[i].rot.getX(), oldObjects[i].rot.getZ()); + cmpPosition->SetYRotation(oldObjects[i].rot.getY()); } CmpPtr cmpOwnership(sim, oldObjects[i].entityID);