Skip to content

Commit 14fe91a

Browse files
committed
Add Thing::isPositioned function
1 parent eb49be5 commit 14fe91a

File tree

3 files changed

+18
-6
lines changed
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw
  • Generals/Code/GameEngine

3 files changed

+18
-6
lines changed

Generals/Code/GameEngine/Include/Common/Thing.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ class Thing : public MemoryPoolObject
121121

122122
inline const Coord3D *getPosition() const { return &m_cachedPos; }
123123
inline Real getOrientation() const { return m_cachedAngle; }
124+
125+
Bool isPositioned() const;
126+
124127
const Coord3D *getUnitDirectionVector2D() const;
125128
void getUnitDirectionVector2D(Coord3D& dir) const;
126129
void getUnitDirectionVector3D(Coord3D& dir) const;

Generals/Code/GameEngine/Source/Common/Thing/Thing.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
#include "GameLogic/TerrainLogic.h"
4848

4949

50+
static constexpr const Real InitialThingPosX = 0.0f;
51+
static constexpr const Real InitialThingPosY = 0.0f;
52+
5053
//=============================================================================
5154
/** Constructor */
5255
//=============================================================================
@@ -67,7 +70,9 @@ Thing::Thing( const ThingTemplate *thingTemplate )
6770
m_templateName = thingTemplate->getName();
6871
#endif
6972
m_transform.Make_Identity();
70-
m_cachedPos.zero();
73+
m_cachedPos.x = InitialThingPosX;
74+
m_cachedPos.y = InitialThingPosY;
75+
m_cachedPos.z = 0.0f;
7176
m_cachedAngle = 0.0f;
7277
m_cachedDirVector.zero();
7378
m_cachedAltitudeAboveTerrain = 0;
@@ -91,6 +96,12 @@ const ThingTemplate *Thing::getTemplate() const
9196
return m_template;
9297
}
9398

99+
//=============================================================================
100+
Bool Thing::isPositioned() const
101+
{
102+
return m_cachedPos.x != InitialThingPosX || m_cachedPos.y != InitialThingPosY;
103+
}
104+
94105
//=============================================================================
95106
const Coord3D* Thing::getUnitDirectionVector2D() const
96107
{

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,15 @@ W3DTreeDraw::~W3DTreeDraw( void )
123123
//-------------------------------------------------------------------------------------------------
124124
void W3DTreeDraw::addToTreeBuffer()
125125
{
126+
DEBUG_ASSERTCRASH(isPositioned(), ("W3DTreeDraw::addToTreeBuffer - This tree was not positioned!"));
127+
126128
const W3DTreeDrawModuleData *moduleData = getW3DTreeDrawModuleData();
127129
const Drawable *draw = getDrawable();
128130

129-
DEBUG_ASSERTCRASH(!(draw->getPosition()->x == 0.0f && draw->getPosition()->y == 0.0f),
130-
("W3DTreeDraw::addToTreeBuffer - Why place tree at x:0 y:0 ?"));
131-
132131
Real scale = draw->getScale();
133132
Real scaleRandomness = draw->getTemplate()->getInstanceScaleFuzziness();
134133
scaleRandomness = 0.0f; // We use the scale fuzziness inside WB to generate random scales, so they don't change at load time. jba. [4/22/2003]
135-
TheTerrainRenderObject->addTree(draw->getID(), *draw->getPosition(),
136-
scale, draw->getOrientation(), scaleRandomness, moduleData);
134+
TheTerrainRenderObject->addTree(draw->getID(), *draw->getPosition(), scale, draw->getOrientation(), scaleRandomness, moduleData);
137135
}
138136

139137
// ------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)