From 88de5b8f00f70d69914de34e9180d1129f934d82 Mon Sep 17 00:00:00 2001 From: Silent Date: Sat, 9 Sep 2017 20:04:48 +0200 Subject: [PATCH] Only animate Sweeper brushes when needed --- SilentPatchSA/GeneralSA.h | 22 ++++++++++++++++++++-- SilentPatchSA/VehicleSA.cpp | 23 +++++++++++++---------- SilentPatchSA/VehicleSA.h | 2 +- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/SilentPatchSA/GeneralSA.h b/SilentPatchSA/GeneralSA.h index fde3d95..cb680c2 100644 --- a/SilentPatchSA/GeneralSA.h +++ b/SilentPatchSA/GeneralSA.h @@ -96,6 +96,22 @@ public: { 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? class NOVMT CEntity : public CPlaceable { @@ -175,11 +191,13 @@ public: char numLodChildrenRendered; // 0x35 //********* BEGIN CEntityInfo **********// - BYTE nType : 3; // what type is the entity // 0x36 (2 == Vehicle) - BYTE nStatus : 5; // control status // 0x36 + uint8_t nType : 3; // what type is the entity // 0x36 (2 == Vehicle) + uint8_t nStatus : 5; // control status // 0x36 //********* END CEntityInfo ************// public: + uint8_t GetStatus() const { return nStatus; } + bool IsVisible(); }; diff --git a/SilentPatchSA/VehicleSA.cpp b/SilentPatchSA/VehicleSA.cpp index 6e70f2e..61231d5 100644 --- a/SilentPatchSA/VehicleSA.cpp +++ b/SilentPatchSA/VehicleSA.cpp @@ -377,17 +377,20 @@ void CAutomobile::ProcessSweeper() { 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[21] == nullptr ) - { - m_pCarNode[21] = GetFrameFromName( RpClumpGetFrame(m_pRwObject), "miscb" ); - } + if ( m_pCarNode[20] == nullptr ) + { + m_pCarNode[20] = GetFrameFromName( RpClumpGetFrame(m_pRwObject), "misca" ); + } + 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[21], ROT_AXIS_Z, -angle, false ); + SetComponentRotation( m_pCarNode[20], ROT_AXIS_Z, angle, false ); + SetComponentRotation( m_pCarNode[21], ROT_AXIS_Z, -angle, false ); + } } diff --git a/SilentPatchSA/VehicleSA.h b/SilentPatchSA/VehicleSA.h index 0a09740..a36412b 100644 --- a/SilentPatchSA/VehicleSA.h +++ b/SilentPatchSA/VehicleSA.h @@ -152,7 +152,7 @@ public: 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); };