From 5f6ad2157d7eaa589d5fe0192d02bad7236527a5 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 25 Jun 2017 12:17:09 +0200 Subject: [PATCH] Sweeper animations Fixed Phoenix anims --- SilentPatchSA/VehicleSA.cpp | 45 ++++++++++++++++++++++++++++++++++--- SilentPatchSA/VehicleSA.h | 3 ++- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/SilentPatchSA/VehicleSA.cpp b/SilentPatchSA/VehicleSA.cpp index 5c86d3d..a94a60c 100644 --- a/SilentPatchSA/VehicleSA.cpp +++ b/SilentPatchSA/VehicleSA.cpp @@ -260,7 +260,12 @@ void CAutomobile::PreRender() if ( FLAUtils::GetExtendedID( &m_nModelIndex ) == 603 ) { - ProcessPhoenixBlower(); + ProcessPhoenixBlower( 603 ); + } + + if ( FLAUtils::GetExtendedID( &m_nModelIndex ) == 574 ) + { + ProcessSweeper(); } } @@ -300,10 +305,20 @@ void CAutomobile::ResetFrames() } } -void CAutomobile::ProcessPhoenixBlower() +void CAutomobile::ProcessPhoenixBlower( int32_t modelID ) { if ( m_pCarNode[20] == nullptr ) return; + RpClump* pOrigClump = reinterpret_cast(ms_modelInfoPtrs[ modelID ]->pRwObject); + if ( pOrigClump != nullptr ) + { + RwFrame* origFrame = GetFrameFromName( RpClumpGetFrame(pOrigClump), GetFrameNodeName(m_pCarNode[20]) ); + if ( origFrame != nullptr ) + { + *RwFrameGetMatrix(m_pCarNode[20]) = *RwFrameGetMatrix(origFrame); + } + } + float finalAngle = 0.0f; if ( m_fGasPedal > 0.0f ) { @@ -324,5 +339,29 @@ void CAutomobile::ProcessPhoenixBlower() } } - SetComponentRotation( m_pCarNode[20], 0, finalAngle, true ); + SetComponentRotation( m_pCarNode[20], 0, finalAngle, false ); +} + +void CAutomobile::ProcessSweeper() +{ + if ( !m_nVehicleFlags.bEngineOn ) return; + + 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 * 0.5f; + if ( m_pCarNode[20] != nullptr ) + { + SetComponentRotation( m_pCarNode[20], 2, angle, false ); + } + if ( m_pCarNode[21] != nullptr ) + { + SetComponentRotation( m_pCarNode[21], 2, -angle, false ); + } } diff --git a/SilentPatchSA/VehicleSA.h b/SilentPatchSA/VehicleSA.h index 9b00fd8..9a5a1cd 100644 --- a/SilentPatchSA/VehicleSA.h +++ b/SilentPatchSA/VehicleSA.h @@ -170,7 +170,8 @@ public: void Fix_SilentPatch(); void ResetFrames(); - void ProcessPhoenixBlower(); + void ProcessPhoenixBlower( int32_t modelID ); + void ProcessSweeper(); static void (CAutomobile::*orgPreRender)(); };