diff --git a/include/ozz/animation/runtime/motion_blending_job.h b/include/ozz/animation/runtime/motion_blending_job.h index e51ae9b44..b7e7f5f71 100644 --- a/include/ozz/animation/runtime/motion_blending_job.h +++ b/include/ozz/animation/runtime/motion_blending_job.h @@ -65,7 +65,7 @@ struct OZZ_ANIMATION_DLL MotionBlendingJob { float weight = 0.f; // The motion delta transform to be blended. - const math::Transform* transform = nullptr; + const math::Transform* delta = nullptr; }; // Job input layers, can be empty or nullptr. diff --git a/samples/motion_blend/sample_motion_blend.cc b/samples/motion_blend/sample_motion_blend.cc index f306a0060..e6a8edf61 100644 --- a/samples/motion_blend/sample_motion_blend.cc +++ b/samples/motion_blend/sample_motion_blend.cc @@ -134,7 +134,7 @@ class MotionBlendSampleApplication : public ozz::sample::Application { ozz::animation::MotionBlendingJob::Layer layers[kNumLayers]; for (size_t i = 0; i < kNumLayers; ++i) { const auto& sampler = samplers_[i]; - layers[i].transform = &sampler.motion_sampler.delta; + layers[i].delta = &sampler.motion_sampler.delta; layers[i].weight = sampler.weight; } diff --git a/src/animation/runtime/motion_blending_job.cc b/src/animation/runtime/motion_blending_job.cc index c0dc5c5d2..5e5b915b3 100644 --- a/src/animation/runtime/motion_blending_job.cc +++ b/src/animation/runtime/motion_blending_job.cc @@ -39,7 +39,7 @@ bool MotionBlendingJob::Validate() const { // Validates layers. for (const Layer& layer : layers) { - valid &= layer.transform != nullptr; + valid &= layer.delta != nullptr; } return valid; @@ -65,16 +65,16 @@ bool MotionBlendingJob::Run() const { // Decomposes translation into a normalized vector and a length, to limit // lerp error while interpolating vector length. - const float len = Length(layer.transform->translation); + const float len = Length(layer.delta->translation); dl = dl + len * weight; const float denom = (len == 0.f) ? 0.f : weight / len; - dt = dt + layer.transform->translation * denom; + dt = dt + layer.delta->translation * denom; // Accumulates weighted rotation (NLerp). Makes sure quaternions are on the // same hemisphere to lerp the shortest arc (using -Q otherwise). const float signed_weight = - std::copysign(weight, Dot(dr, layer.transform->rotation)); - dr = dr + layer.transform->rotation * signed_weight; + std::copysign(weight, Dot(dr, layer.delta->rotation)); + dr = dr + layer.delta->rotation * signed_weight; } // Normalizes (weights) and fills output. diff --git a/test/animation/runtime/motion_blending_job_tests.cc b/test/animation/runtime/motion_blending_job_tests.cc index 1b5bf67d0..8d6a73c4b 100644 --- a/test/animation/runtime/motion_blending_job_tests.cc +++ b/test/animation/runtime/motion_blending_job_tests.cc @@ -46,10 +46,10 @@ TEST(Validate, MotionBlendingJob) { EXPECT_FALSE(job.Validate()); ozz::math::Transform transforms[2]; - layers[0].transform = &transforms[0]; + layers[0].delta = &transforms[0]; EXPECT_FALSE(job.Validate()); - layers[1].transform = &transforms[1]; + layers[1].delta = &transforms[1]; EXPECT_TRUE(job.Validate()); } @@ -86,8 +86,8 @@ TEST(Run, MotionBlendingJob) { transforms[1].rotation = {-0.f, -.70710677f, -0.f, -.70710677f}; MotionBlendingJob::Layer layers[2]; - layers[0].transform = &transforms[0]; - layers[1].transform = &transforms[1]; + layers[0].delta = &transforms[0]; + layers[1].delta = &transforms[1]; job.layers = layers; // 0 weights