Loading anim/include/anim/animation.hpp +9 −0 Original line number Diff line number Diff line Loading @@ -518,6 +518,15 @@ namespace anim { auto low_key = static_cast<Keyframe<quat>*>(low->get()); auto high_key = static_cast<Keyframe<quat>*>(high->get()); double param = (low_key->interpolation == InterpolationType::SIMPLIFIED) ? ease(rt, low_key->transition) : rt; // if (param < 0 || param > 1) { // ASSUMPTION(false); // } // auto q1 = normalized(low_key->value); // auto q2 = normalized(high_key->value); // if (dot(q1, q2) < 0) { // q2 = -q2; // } // auto q = slerp(q1, q2, param); auto q = slerp(low_key->value, high_key->value, param); auto euler = glm::eulerAngles(q); result = make_value<ValueQUAT>(q); Loading anim/src/animator.cpp +15 −6 Original line number Diff line number Diff line Loading @@ -32,6 +32,12 @@ void Animator::release() // it->second.code({}); } // quat nlerp(quat a, quat b, float t) { // if (dot(a, b) < 0.0f) // b = -b; // return normalize(a * (1.0f - t) + b * t); // } void Animator::next_round() { // static auto& parent = com::Folder::root()->subfolders()[2]; Loading @@ -58,12 +64,12 @@ void Animator::next_round() } } if (select_animation_a) { blending_factor_alpha = max(0.f, blending_factor_alpha - 0.02); } else { blending_factor_alpha = min(1.f, blending_factor_alpha + 0.02); } // if (select_animation_a) { // blending_factor_alpha = max(0.f, blending_factor_alpha - 0.02); // } // else { // blending_factor_alpha = min(1.f, blending_factor_alpha + 0.02); // } std::unordered_map<const com::Reflection::Function*, std::vector<com::Reflection::ValuePtr>> values; auto blend_folder = com::Folder::root()->find<com::Folder>(ANIM_FOLDER_NAME)->find<com::Folder>("blended"); Loading Loading @@ -101,6 +107,9 @@ void Animator::next_round() case com::Reflection::TypeID::QUAT: { quat a = com::as<com::Reflection::ValueQUAT>(values_to_blend[0])->value; quat b = com::as<com::Reflection::ValueQUAT>(values_to_blend[1])->value; // if (dot(a, b) < 0.0f) { // b = -b; // quaternion sign correction // } quat result = slerp(a, b, blending_factor_alpha); parameter->code({ com::make_value<ValueQUAT>(result) }); break; Loading Loading
anim/include/anim/animation.hpp +9 −0 Original line number Diff line number Diff line Loading @@ -518,6 +518,15 @@ namespace anim { auto low_key = static_cast<Keyframe<quat>*>(low->get()); auto high_key = static_cast<Keyframe<quat>*>(high->get()); double param = (low_key->interpolation == InterpolationType::SIMPLIFIED) ? ease(rt, low_key->transition) : rt; // if (param < 0 || param > 1) { // ASSUMPTION(false); // } // auto q1 = normalized(low_key->value); // auto q2 = normalized(high_key->value); // if (dot(q1, q2) < 0) { // q2 = -q2; // } // auto q = slerp(q1, q2, param); auto q = slerp(low_key->value, high_key->value, param); auto euler = glm::eulerAngles(q); result = make_value<ValueQUAT>(q); Loading
anim/src/animator.cpp +15 −6 Original line number Diff line number Diff line Loading @@ -32,6 +32,12 @@ void Animator::release() // it->second.code({}); } // quat nlerp(quat a, quat b, float t) { // if (dot(a, b) < 0.0f) // b = -b; // return normalize(a * (1.0f - t) + b * t); // } void Animator::next_round() { // static auto& parent = com::Folder::root()->subfolders()[2]; Loading @@ -58,12 +64,12 @@ void Animator::next_round() } } if (select_animation_a) { blending_factor_alpha = max(0.f, blending_factor_alpha - 0.02); } else { blending_factor_alpha = min(1.f, blending_factor_alpha + 0.02); } // if (select_animation_a) { // blending_factor_alpha = max(0.f, blending_factor_alpha - 0.02); // } // else { // blending_factor_alpha = min(1.f, blending_factor_alpha + 0.02); // } std::unordered_map<const com::Reflection::Function*, std::vector<com::Reflection::ValuePtr>> values; auto blend_folder = com::Folder::root()->find<com::Folder>(ANIM_FOLDER_NAME)->find<com::Folder>("blended"); Loading Loading @@ -101,6 +107,9 @@ void Animator::next_round() case com::Reflection::TypeID::QUAT: { quat a = com::as<com::Reflection::ValueQUAT>(values_to_blend[0])->value; quat b = com::as<com::Reflection::ValueQUAT>(values_to_blend[1])->value; // if (dot(a, b) < 0.0f) { // b = -b; // quaternion sign correction // } quat result = slerp(a, b, blending_factor_alpha); parameter->code({ com::make_value<ValueQUAT>(result) }); break; Loading