Skip to content

Commit 62ca883

Browse files
AhmedAmrNabilAhmedSobhy01
authored andcommitted
fix(animation): use findBone instead of manual reading from animation channels
1 parent 9fc45d6 commit 62ca883

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/common/animation/animation.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ namespace our {
3333
channels[nodeName] = BoneAnimation(nodeName, channel);
3434
}
3535
}
36-
BoneAnimation& findBone(const std::string& name) {
36+
const BoneAnimation* findBone(const std::string& name) const {
3737
auto it = channels.find(name);
3838
if (it != channels.end()) {
39-
return it->second;
39+
return &it->second;
4040
}
41-
throw std::runtime_error("BoneAnimation not found: " + name);
41+
return nullptr;
4242
}
4343
};
4444
} // namespace our

src/common/animation/animator.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ namespace our {
3636

3737
// animated local transform, fallback to bind pose
3838
glm::mat4 localTransform = node.localTransform;
39-
auto it = currentAnimation->channels.find(node.name);
40-
if (it != currentAnimation->channels.end()) {
41-
localTransform = it->second.interpolate(currentTime);
39+
if (const BoneAnimation* boneAnim = currentAnimation->findBone(node.name); boneAnim) {
40+
localTransform = boneAnim->interpolate(currentTime);
4241
}
4342

4443
// accumulate from parent

0 commit comments

Comments
 (0)