This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +13
-34
lines changed Expand file tree Collapse file tree 4 files changed +13
-34
lines changed Original file line number Diff line number Diff line change @@ -54,12 +54,12 @@ void AnimationClip::SetLoop(bool looping) {
54
54
loop_ = looping;
55
55
}
56
56
57
- Scalar AnimationClip::GetPlaybackSpeed () const {
58
- return playback_speed_ ;
57
+ Scalar AnimationClip::GetPlaybackTimeScale () const {
58
+ return playback_time_scale_ ;
59
59
}
60
60
61
- void AnimationClip::SetPlaybackSpeed (Scalar playback_speed) {
62
- playback_speed_ = playback_speed;
61
+ void AnimationClip::SetPlaybackTimeScale (Scalar playback_speed) {
62
+ playback_time_scale_ = playback_speed;
63
63
}
64
64
65
65
Scalar AnimationClip::GetWeight () const {
@@ -82,7 +82,7 @@ void AnimationClip::Advance(Scalar delta_time) {
82
82
if (!playing_ || delta_time <= 0 ) {
83
83
return ;
84
84
}
85
- delta_time *= playback_speed_ ;
85
+ delta_time *= playback_time_scale_ ;
86
86
playback_time_ += delta_time;
87
87
88
88
// / Handle looping behavior.
Original file line number Diff line number Diff line change @@ -38,11 +38,11 @@ class AnimationClip final {
38
38
39
39
void SetLoop (bool looping);
40
40
41
- Scalar GetPlaybackSpeed () const ;
41
+ Scalar GetPlaybackTimeScale () const ;
42
42
43
43
// / @brief Sets the animation playback speed. Negative values make the clip
44
44
// / play in reverse.
45
- void SetPlaybackSpeed (Scalar playback_speed);
45
+ void SetPlaybackTimeScale (Scalar playback_speed);
46
46
47
47
Scalar GetWeight () const ;
48
48
@@ -74,7 +74,7 @@ class AnimationClip final {
74
74
std::vector<ChannelBinding> bindings_;
75
75
76
76
Scalar playback_time_ = 0 ;
77
- Scalar playback_speed_ = 1 ; // Seconds multiplier, can be negative.
77
+ Scalar playback_time_scale_ = 1 ; // Seconds multiplier, can be negative.
78
78
Scalar weight_ = 1 ;
79
79
bool playing_ = false ;
80
80
bool loop_ = false ;
Original file line number Diff line number Diff line change @@ -26,8 +26,8 @@ AnimationClip& AnimationPlayer::AddAnimation(
26
26
// Record all of the unique default transforms that this AnimationClip
27
27
// will mutate.
28
28
for (const auto & binding : clip.bindings_ ) {
29
- default_target_transforms_.insert (DefaultTransform{
30
- . node = binding.node , . transform = binding.node ->GetLocalTransform ()});
29
+ default_target_transforms_.insert (
30
+ { binding.node , binding.node ->GetLocalTransform ()});
31
31
}
32
32
33
33
clips_.push_back (std::move (clip));
@@ -52,8 +52,8 @@ void AnimationPlayer::Update() {
52
52
}
53
53
54
54
void AnimationPlayer::Reset () {
55
- for (auto & default_transform : default_target_transforms_) {
56
- default_transform. node ->SetLocalTransform (default_transform. transform );
55
+ for (auto & [node, transform] : default_target_transforms_) {
56
+ node->SetLocalTransform (transform);
57
57
}
58
58
}
59
59
Original file line number Diff line number Diff line change @@ -38,28 +38,7 @@ class AnimationPlayer final {
38
38
void Reset ();
39
39
40
40
private:
41
- struct DefaultTransform {
42
- Node* node;
43
- Matrix transform;
44
-
45
- struct Hash {
46
- std::size_t operator ()(const DefaultTransform& o) const {
47
- return fml::HashCombine (o.node );
48
- }
49
- };
50
-
51
- struct Equal {
52
- bool operator ()(const DefaultTransform& lhs,
53
- const DefaultTransform& rhs) const {
54
- return lhs.node == rhs.node ;
55
- }
56
- };
57
- };
58
-
59
- std::unordered_set<DefaultTransform,
60
- DefaultTransform::Hash,
61
- DefaultTransform::Equal>
62
- default_target_transforms_;
41
+ std::unordered_map<Node*, Matrix> default_target_transforms_;
63
42
64
43
std::vector<AnimationClip> clips_;
65
44
You can’t perform that action at this time.
0 commit comments