Fix rollback bed rotation animation - #232
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.
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.
| 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); |
|
is this tested? |
Nope, i already replied on Discord server, thanks for reviewing, you will continue to maintain the project from now on? |
not always, i'im not completely taking over. i'll just be accepting and reviewing PRs and contibute every once in a while |
Btw, is repo is up-to-date with the Grinch's local work? I think he have some changes that not pushed to GitHub. |
|
don't think so, @user-grinch can upload his changes to a separate branch and i'll merge them with main later on. shouldn't be an issue |
Thanks, i don't remember i have seen you on Discord before, what is your plans for the project? There is much bug reports. |
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.