diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index 83b6873..2310727 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -243,6 +243,9 @@ RwBool _rpD3D9VertexDeclarationInstColor(RwUInt8* mem, const RwRGBA* color, RwIn return alpha != 255; } +// Unreachable stub +RwBool RwMatrixDestroy(RwMatrix* mpMat) { assert(!"Unreachable!"); return TRUE; } + struct AlphaObjectInfo { RpAtomic* pAtomic; diff --git a/SilentPatchSA/VehicleSA.cpp b/SilentPatchSA/VehicleSA.cpp index a94a60c..abd9d37 100644 --- a/SilentPatchSA/VehicleSA.cpp +++ b/SilentPatchSA/VehicleSA.cpp @@ -18,9 +18,6 @@ static void* varVehicleRender = AddressByVersion(0x6D0E60, 0x6D1680, 0x70 WRAPPER void CVehicle::Render() { VARJMP(varVehicleRender); } static void* varIsLawEnforcementVehicle = AddressByVersion(0x6D2370, 0x6D2BA0, 0x70D8C0); WRAPPER bool CVehicle::IsLawEnforcementVehicle() { VARJMP(varIsLawEnforcementVehicle); } -static void* varSetComponentRotation = AddressByVersion(0x6DBA30, 0, 0); -WRAPPER void CVehicle::SetComponentRotation( RwFrame* component, int axis, float angle, bool absolute ) { VARJMP(varSetComponentRotation); } - void (CAutomobile::*CAutomobile::orgPreRender)(); static int32_t random(int32_t from, int32_t to) @@ -139,6 +136,31 @@ void CVehicle::CustomCarPlate_BeforeRenderingStart(CVehicleModelInfo* pModelInfo } } +void CVehicle::SetComponentRotation( RwFrame* component, int axis, float angle, bool absolute ) +{ + if ( component == nullptr ) return; + + CMatrix matrix( RwFrameGetMatrix(component) ); + if ( absolute ) + { + if ( axis == 0 ) matrix.SetRotateXOnly(angle); + else if ( axis == 1 ) matrix.SetRotateYOnly(angle); + else if ( axis == 2 ) matrix.SetRotateZOnly(angle); + } + else + { + const CVector pos = matrix.GetPos(); + matrix.SetTranslateOnly(0.0f, 0.0f, 0.0f); + + if ( axis == 0 ) matrix.RotateX(angle); + else if ( axis == 1 ) matrix.RotateY(angle); + else if ( axis == 2 ) matrix.RotateZ(angle); + + matrix.GetPos() += pos; + } + matrix.UpdateRW(); +} + void CHeli::Render() { double dRotorsSpeed, dMovingRotorSpeed; diff --git a/SilentPatchSA/VehicleSA.h b/SilentPatchSA/VehicleSA.h index 9a5a1cd..4005eeb 100644 --- a/SilentPatchSA/VehicleSA.h +++ b/SilentPatchSA/VehicleSA.h @@ -144,8 +144,8 @@ public: //void CustomCarPlate_AfterRenderingStop(CVehicleModelInfo* pModelInfo); bool IsLawEnforcementVehicle(); - void SetComponentRotation( RwFrame* component, int axis, float angle, bool absolute ); + static void SetComponentRotation( RwFrame* component, int axis, float angle, bool absolute ); static void SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha); };