Only animate Sweeper brushes when needed

This commit is contained in:
Silent 2017-09-09 20:04:48 +02:00
parent 36d9f1a29a
commit 88de5b8f00
3 changed files with 34 additions and 13 deletions

View file

@ -96,6 +96,22 @@ public:
{ if ( m_pCoords ) m_pCoords->SetRotateZOnly(fHeading); else m_transform.m_heading = fHeading; } { if ( m_pCoords ) m_pCoords->SetRotateZOnly(fHeading); else m_transform.m_heading = fHeading; }
}; };
enum // nStatus
{
STATUS_PLAYER = 0,
STATUS_PLAYER_PLAYBACKFROMBUFFER = 1,
STATUS_SIMPLE = 2,
STATUS_PHYSICS = 3,
STATUS_ABANDONED = 4,
STATUS_WRECKED = 5,
STATUS_PLAYER_REMOTE = 8,
STATUS_PLAYER_DISABLED = 9,
STATUS_TRAILER = 10,
STATUS_SIMPLE_TRAILER = 11,
STATUS_GHOST = 12,
};
// TODO: May not be the best place to put it? // TODO: May not be the best place to put it?
class NOVMT CEntity : public CPlaceable class NOVMT CEntity : public CPlaceable
{ {
@ -175,11 +191,13 @@ public:
char numLodChildrenRendered; // 0x35 char numLodChildrenRendered; // 0x35
//********* BEGIN CEntityInfo **********// //********* BEGIN CEntityInfo **********//
BYTE nType : 3; // what type is the entity // 0x36 (2 == Vehicle) uint8_t nType : 3; // what type is the entity // 0x36 (2 == Vehicle)
BYTE nStatus : 5; // control status // 0x36 uint8_t nStatus : 5; // control status // 0x36
//********* END CEntityInfo ************// //********* END CEntityInfo ************//
public: public:
uint8_t GetStatus() const { return nStatus; }
bool IsVisible(); bool IsVisible();
}; };

View file

@ -377,17 +377,20 @@ void CAutomobile::ProcessSweeper()
{ {
if ( !m_nVehicleFlags.bEngineOn ) return; if ( !m_nVehicleFlags.bEngineOn ) return;
if ( m_pCarNode[20] == nullptr ) if ( GetStatus() == STATUS_PLAYER || GetStatus() == STATUS_PHYSICS || GetStatus() == STATUS_SIMPLE )
{ {
m_pCarNode[20] = GetFrameFromName( RpClumpGetFrame(m_pRwObject), "misca" ); if ( m_pCarNode[20] == nullptr )
} {
if ( m_pCarNode[21] == nullptr ) m_pCarNode[20] = GetFrameFromName( RpClumpGetFrame(m_pRwObject), "misca" );
{ }
m_pCarNode[21] = GetFrameFromName( RpClumpGetFrame(m_pRwObject), "miscb" ); if ( m_pCarNode[21] == nullptr )
} {
m_pCarNode[21] = GetFrameFromName( RpClumpGetFrame(m_pRwObject), "miscb" );
}
const float angle = CTimer::m_fTimeStep * SWEEPER_BRUSH_SPEED; const float angle = CTimer::m_fTimeStep * SWEEPER_BRUSH_SPEED;
SetComponentRotation( m_pCarNode[20], ROT_AXIS_Z, angle, false ); SetComponentRotation( m_pCarNode[20], ROT_AXIS_Z, angle, false );
SetComponentRotation( m_pCarNode[21], ROT_AXIS_Z, -angle, false ); SetComponentRotation( m_pCarNode[21], ROT_AXIS_Z, -angle, false );
}
} }

View file

@ -152,7 +152,7 @@ public:
bool IsLawEnforcementVehicle(); bool IsLawEnforcementVehicle();
static void SetComponentRotation( RwFrame* component, eRotAxis axis, float angle, bool absolute ); static void SetComponentRotation( RwFrame* component, eRotAxis axis, float angle, bool absolute = true );
static void SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha); static void SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha);
}; };