From ad6af7baea242b1596fc83b88cc823ca51dfb302 Mon Sep 17 00:00:00 2001 From: CanerKaraca23 <37447503+CanerKaraca23@users.noreply.github.com> Date: Sat, 4 Apr 2026 11:15:05 +0000 Subject: [PATCH] Fix rotation logic for rollback bed - Added `#include "utils/frameextention.h"` to resolve missing dependencies. - Updated `UpdateRotation` to apply the rotation logic. - Implemented `ResetRotation` and `RestoreBackup` logic using the original matrix backup to allow absolute rotations using `SetRotationXAbsolute`. - Ensured `RwMatrixUpdate` runs even on the exact tick the rotation reaches its target. --- src/features/rollbackbed.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/features/rollbackbed.cpp b/src/features/rollbackbed.cpp index 275a1bec..8c8dd4b8 100755 --- a/src/features/rollbackbed.cpp +++ b/src/features/rollbackbed.cpp @@ -3,6 +3,7 @@ #include "utils/modelinfomgr.h" #include "utils/datamgr.h" #include "utils/audiomgr.h" +#include "utils/frameextention.h" using namespace plugin; @@ -11,8 +12,6 @@ bool RollbackBed::UpdateRotation(CVehicle *pVeh, RwFrame *pFrame, float targetRo RollbackBedData &data = m_VehData.Get(pVeh); if (data.bInit && pFrame) { - // TODO FIX - // MatrixUtil::SetRotationX(&pFrame->modelling, curRot); float target = data.bExpanded ? targetRot : 0.0f; float delta = target - curRot; float step = CTimer::ms_fTimeStep * std::abs(targetRot) / 360.0f * speed; @@ -24,6 +23,23 @@ bool RollbackBed::UpdateRotation(CVehicle *pVeh, RwFrame *pFrame, float targetRo else { curRot = target; + } + + auto ext = RwFrameExtension::Get(pFrame); + if (ext && ext->pOrigMatrix) + { + MatrixUtil::RestoreBackup(&pFrame->modelling, ext->pOrigMatrix); + } + else + { + MatrixUtil::ResetRotation(&pFrame->modelling); + } + + MatrixUtil::SetRotationXAbsolute(&pFrame->modelling, curRot); + RwMatrixUpdate(&pFrame->modelling); + + if (curRot == target) + { return true; } }