Skip to content

Fix rollback bed rotation animation#232

Open
CanerKaraca23 wants to merge 1 commit intouser-grinch:mainfrom
CanerKaraca23:fix-rollback-bed-rotation-10533123094874995208
Open

Fix rollback bed rotation animation#232
CanerKaraca23 wants to merge 1 commit intouser-grinch:mainfrom
CanerKaraca23:fix-rollback-bed-rotation-10533123094874995208

Conversation

@CanerKaraca23
Copy link
Copy Markdown
Contributor

Fixes a bug in src/features/rollbackbed.cpp where the rollback bed rotation failed to apply due to commented-out logic and an incorrect sequence that returned early before RwMatrixUpdate was called. The new implementation retrieves the original matrix via RwFrameExtension and accurately applies the target rotation.

- 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.
Copilot AI review requested due to automatic review settings May 8, 2026 19:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes rollback bed frame rotation updates by reintroducing matrix manipulation and ensuring the frame’s modelling matrix is updated after applying the desired X rotation.

Changes:

  • Replaced previously commented-out bed rotation logic with active rotation application.
  • Added restoration/reset of the frame modelling matrix prior to applying rotation (via RwFrameExtension backup if available).
  • Ensured RwMatrixUpdate is called after applying the rotation.
Comments suppressed due to low confidence (1)

src/features/rollbackbed.cpp:22

  • step becomes 0 when targetRot is 0 (the default in RollbackBedData), and if curRot is non-zero (e.g., after config reload or state desync) the curRot += step * ... path will never make progress, so the rotation will never converge back to target. Consider handling the step <= 0/targetRot == 0 case explicitly (snap to target or use a minimum step).
        float target = data.bExpanded ? targetRot : 0.0f;
        float delta = target - curRot;
        float step = CTimer::ms_fTimeStep * std::abs(targetRot) / 360.0f * speed;

        if (std::abs(delta) > step)
        {
            curRot += step * (delta > 0.0f ? 1.0f : -1.0f);
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +28 to +36
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants