Fix rollback bed rotation animation#232
Open
CanerKaraca23 wants to merge 1 commit intouser-grinch:mainfrom
Open
Fix rollback bed rotation animation#232CanerKaraca23 wants to merge 1 commit intouser-grinch:mainfrom
CanerKaraca23 wants to merge 1 commit intouser-grinch:mainfrom
Conversation
- 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.
Contributor
There was a problem hiding this comment.
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
RwFrameExtensionbackup if available). - Ensured
RwMatrixUpdateis called after applying the rotation.
Comments suppressed due to low confidence (1)
src/features/rollbackbed.cpp:22
stepbecomes 0 whentargetRotis 0 (the default inRollbackBedData), and ifcurRotis non-zero (e.g., after config reload or state desync) thecurRot += step * ...path will never make progress, so the rotation will never converge back totarget. Consider handling thestep <= 0/targetRot == 0case explicitly (snap totargetor 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a bug in
src/features/rollbackbed.cppwhere the rollback bed rotation failed to apply due to commented-out logic and an incorrect sequence that returned early beforeRwMatrixUpdatewas called. The new implementation retrieves the original matrix viaRwFrameExtensionand accurately applies the target rotation.