Loading anim/include/anim/partial_blender.hpp +55 −7 Original line number Diff line number Diff line Loading @@ -14,23 +14,65 @@ struct PartialBlender : public IAnimationPlayer { std::optional<std::unordered_map<const com::Reflection::Function*, scalar>> track_weights; }; PartialBlender(std::string const &name) PartialBlender(std::string const &name, IAnimationPlayer* base_animation, IAnimationPlayer* partial_animation) : IAnimationPlayer{ name } , base_animation{nullptr} , partial_animation{nullptr} , base_animation{base_animation} , partial_animation{partial_animation} // PartialBlender(std::string const &name) // : IAnimationPlayer{ name } // , base_animation{nullptr} // , partial_animation{nullptr} { // reconstruct_parameters(); move_back(base_animation); move_back(partial_animation); base_animation->update(0.0_s); partial_animation->update(0.0_s); reconstruct_parameters(); std::set<std::string> track_names = { "mixamorig:Hips_rotation", "mixamorig:Hips_translation", "mixamorig:RightUpLeg_rotation", "mixamorig:RightUpLeg_translation", "mixamorig:RightLeg_rotation", "mixamorig:RightLeg_translation", "mixamorig:RightFoot_rotation", "mixamorig:RightFoot_translation", "mixamorig:RightToeBase_rotation", "mixamorig:RightToeBase_translation", "mixamorig:RightToe_End_rotation", "mixamorig:RightToe_End_translation", "mixamorig:LeftUpLeg_rotation", "mixamorig:LeftUpLeg_translation", "mixamorig:LeftLeg_rotation", "mixamorig:LeftLeg_translation", "mixamorig:LeftFoot_rotation", "mixamorig:LeftFoot_translation", "mixamorig:LeftToeBase_rotation", "mixamorig:LeftToeBase_translation", "mixamorig:LeftToe_End_rotation", "mixamorig:LeftToe_End_translation" }; auto partial = dynamic_cast<Animation*>(partial_animation); for (auto& file : partial->items()) { if (auto track = dynamic_cast<AnimationTrack*>(file)) { if (!track_names.contains(track->name())) { m_track_weights[&(track->target()->reflection()->functions().at(track->getPropertySetterName()))] = 1.0_s; } } } } void move_base_animation(anim::IAnimationPlayer* animation) { base_animation = animation; move_back(base_animation); copy_back(base_animation, "base_animation"); base_animation->update(0.0_s); } void move_partial_animation(anim::IAnimationPlayer* animation) { partial_animation = animation; move_back(partial_animation); copy_back(partial_animation, "partial_animation"); partial_animation->update(0.0_s); } Loading Loading @@ -70,7 +112,12 @@ struct PartialBlender : public IAnimationPlayer { // auto weighted_partial_value = MultiplyValue(value, m_weight); // m_values[parameter] = AddValues(weighted_base_value, weighted_partial_value); m_values[parameter] = interpolator.interpolate(m_values[parameter], value, m_weight); auto track_weight = 0.0_s; if (m_track_weights.contains(parameter)) { track_weight = m_track_weights.at(parameter); } // track_weight = 1.0_s; m_values[parameter] = interpolator.interpolate(m_values[parameter], value, m_weight * track_weight); } } Loading @@ -85,6 +132,7 @@ struct PartialBlender : public IAnimationPlayer { scalar m_weight = 0.0_s; private: std::unordered_map<const com::Reflection::Function*, scalar> m_track_weights; IAnimationPlayer* base_animation; IAnimationPlayer* partial_animation; Loading Loading
anim/include/anim/partial_blender.hpp +55 −7 Original line number Diff line number Diff line Loading @@ -14,23 +14,65 @@ struct PartialBlender : public IAnimationPlayer { std::optional<std::unordered_map<const com::Reflection::Function*, scalar>> track_weights; }; PartialBlender(std::string const &name) PartialBlender(std::string const &name, IAnimationPlayer* base_animation, IAnimationPlayer* partial_animation) : IAnimationPlayer{ name } , base_animation{nullptr} , partial_animation{nullptr} , base_animation{base_animation} , partial_animation{partial_animation} // PartialBlender(std::string const &name) // : IAnimationPlayer{ name } // , base_animation{nullptr} // , partial_animation{nullptr} { // reconstruct_parameters(); move_back(base_animation); move_back(partial_animation); base_animation->update(0.0_s); partial_animation->update(0.0_s); reconstruct_parameters(); std::set<std::string> track_names = { "mixamorig:Hips_rotation", "mixamorig:Hips_translation", "mixamorig:RightUpLeg_rotation", "mixamorig:RightUpLeg_translation", "mixamorig:RightLeg_rotation", "mixamorig:RightLeg_translation", "mixamorig:RightFoot_rotation", "mixamorig:RightFoot_translation", "mixamorig:RightToeBase_rotation", "mixamorig:RightToeBase_translation", "mixamorig:RightToe_End_rotation", "mixamorig:RightToe_End_translation", "mixamorig:LeftUpLeg_rotation", "mixamorig:LeftUpLeg_translation", "mixamorig:LeftLeg_rotation", "mixamorig:LeftLeg_translation", "mixamorig:LeftFoot_rotation", "mixamorig:LeftFoot_translation", "mixamorig:LeftToeBase_rotation", "mixamorig:LeftToeBase_translation", "mixamorig:LeftToe_End_rotation", "mixamorig:LeftToe_End_translation" }; auto partial = dynamic_cast<Animation*>(partial_animation); for (auto& file : partial->items()) { if (auto track = dynamic_cast<AnimationTrack*>(file)) { if (!track_names.contains(track->name())) { m_track_weights[&(track->target()->reflection()->functions().at(track->getPropertySetterName()))] = 1.0_s; } } } } void move_base_animation(anim::IAnimationPlayer* animation) { base_animation = animation; move_back(base_animation); copy_back(base_animation, "base_animation"); base_animation->update(0.0_s); } void move_partial_animation(anim::IAnimationPlayer* animation) { partial_animation = animation; move_back(partial_animation); copy_back(partial_animation, "partial_animation"); partial_animation->update(0.0_s); } Loading Loading @@ -70,7 +112,12 @@ struct PartialBlender : public IAnimationPlayer { // auto weighted_partial_value = MultiplyValue(value, m_weight); // m_values[parameter] = AddValues(weighted_base_value, weighted_partial_value); m_values[parameter] = interpolator.interpolate(m_values[parameter], value, m_weight); auto track_weight = 0.0_s; if (m_track_weights.contains(parameter)) { track_weight = m_track_weights.at(parameter); } // track_weight = 1.0_s; m_values[parameter] = interpolator.interpolate(m_values[parameter], value, m_weight * track_weight); } } Loading @@ -85,6 +132,7 @@ struct PartialBlender : public IAnimationPlayer { scalar m_weight = 0.0_s; private: std::unordered_map<const com::Reflection::Function*, scalar> m_track_weights; IAnimationPlayer* base_animation; IAnimationPlayer* partial_animation; Loading