summaryrefslogtreecommitdiffstats
path: root/scene/animation/root_motion_view.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-02-09 23:43:08 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-02-09 23:43:08 +0100
commit929ee61170ec4d431d6d2cfeddccdec2a59a11b7 (patch)
treea566a042a4dcb5f410f5a08bb2f92fc4645a1bf4 /scene/animation/root_motion_view.cpp
parent1a5f28df20523e31854217138a46f188b6e4f668 (diff)
parent7b18ad7d9825ec425375f6e46d031cfc79660453 (diff)
downloadredot-engine-929ee61170ec4d431d6d2cfeddccdec2a59a11b7.tar.gz
Merge pull request #72931 from TokageItLab/improve-root-motion-for-rot-and-pos
Add root motion accumulator to fix broken RootMotionView
Diffstat (limited to 'scene/animation/root_motion_view.cpp')
-rw-r--r--scene/animation/root_motion_view.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp
index 3d8d451c70..fc758b9456 100644
--- a/scene/animation/root_motion_view.cpp
+++ b/scene/animation/root_motion_view.cpp
@@ -88,6 +88,7 @@ void RootMotionView::_notification(int p_what) {
case NOTIFICATION_INTERNAL_PROCESS:
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
Transform3D transform;
+ Basis diff;
if (has_node(path)) {
Node *node = get_node(path);
@@ -103,9 +104,9 @@ void RootMotionView::_notification(int p_what) {
set_process_internal(true);
set_physics_process_internal(false);
}
-
transform.origin = tree->get_root_motion_position();
transform.basis = tree->get_root_motion_rotation(); // Scale is meaningless.
+ diff = tree->get_root_motion_rotation_accumulator();
}
}
@@ -115,8 +116,10 @@ void RootMotionView::_notification(int p_what) {
first = false;
- accumulated.origin += transform.origin;
accumulated.basis *= transform.basis;
+ transform.origin = (diff.inverse() * accumulated.basis).xform(transform.origin);
+ accumulated.origin += transform.origin;
+
accumulated.origin.x = Math::fposmod(accumulated.origin.x, cell_size);
if (zero_y) {
accumulated.origin.y = 0;