19 : animation_(
std::move(animation)) {
20 BindToTarget(bind_target);
46 Seek(SecondsF::zero());
58 return playback_time_scale_;
62 playback_time_scale_ = playback_speed;
70 weight_ = std::max(0.0f, weight);
74 return playback_time_;
78 playback_time_ = std::clamp(time, SecondsF::zero(), animation_->GetEndTime());
82 if (!playing_ || delta_time <= SecondsF::zero()) {
85 delta_time *= playback_time_scale_;
86 playback_time_ += delta_time;
90 auto end_time = animation_->GetEndTime();
91 if (end_time == SecondsF::zero()) {
92 playback_time_ = SecondsF::zero();
96 (playback_time_ < SecondsF::zero() || playback_time_ > end_time)) {
100 playback_time_ = std::clamp(playback_time_, SecondsF::zero(), end_time);
101 }
else if ( playback_time_ > end_time) {
104 SecondsF(std::fmod(std::abs(playback_time_.count()), end_time.count()));
105 }
else if ( playback_time_ < SecondsF::zero()) {
109 SecondsF(std::fmod(std::abs(playback_time_.count()), end_time.count()));
114 std::unordered_map<Node*, AnimationTransforms>& transform_decomps,
115 Scalar weight_multiplier)
const {
116 for (
auto& binding : bindings_) {
117 auto transforms = transform_decomps.find(binding.node);
118 if (transforms == transform_decomps.end()) {
121 binding.channel.resolver->Apply(transforms->second, playback_time_,
122 weight_ * weight_multiplier);
126 void AnimationClip::BindToTarget(
Node* node) {
127 const auto& channels = animation_->GetChannels();
129 bindings_.reserve(channels.size());
131 for (
const auto& channel : channels) {
132 Node* channel_target;
133 if (channel.bind_target.node_name == node->
GetName()) {
134 channel_target = node;
135 }
else if (
auto result =
137 channel_target = result.get();
142 ChannelBinding{.channel = channel, .node = channel_target});