diff options
Diffstat (limited to 'src/blu_cat/gra/skeletal_model.cpp')
-rw-r--r-- | src/blu_cat/gra/skeletal_model.cpp | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/src/blu_cat/gra/skeletal_model.cpp b/src/blu_cat/gra/skeletal_model.cpp index b58982d..4b44910 100644 --- a/src/blu_cat/gra/skeletal_model.cpp +++ b/src/blu_cat/gra/skeletal_model.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2022-2024 Frederico de Oliveira Linhares + * Copyright 2022-2025 Frederico de Oliveira Linhares * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -192,47 +192,50 @@ SkeletalModel::tick(float delta) for(int i{0}; i < current_animation->bone_transforms.size(); i++) { - BluCat::GRA::BoneTransform *bone_transform = ¤t_animation->bone_transforms[i]; + BluCat::GRA::BoneTransform *bone_transform = + ¤t_animation->bone_transforms[i]; auto position{bone_transform->positions.interpolate( - this->animation_time, - [](glm::vec3 frame) - { - return glm::translate(glm::mat4(1.0f), frame); - }, - [](glm::vec3 previous_frame, glm::vec3 next_frame, float scale_factor) - { - glm::vec3 final_position{glm::mix( - previous_frame, next_frame, scale_factor)}; - return glm::translate(glm::mat4(1.0f), final_position); - })}; + this->animation_time, + [](glm::vec3 frame) + { + return glm::translate(glm::mat4(1.0f), frame); + }, + [](glm::vec3 previous_frame, glm::vec3 next_frame, float scale_factor) + { + glm::vec3 final_position{glm::mix( + previous_frame, next_frame, scale_factor)}; + return glm::translate(glm::mat4(1.0f), final_position); + })}; auto rotation{bone_transform->rotations.interpolate( - this->animation_time, - [](glm::quat frame) - { - return glm::toMat4(glm::normalize(frame)); - }, - [](glm::quat previous_frame, glm::quat next_frame, float scale_factor) - { - return glm::toMat4(glm::slerp( - previous_frame, next_frame, scale_factor)); - })}; + this->animation_time, + [](glm::quat frame) + { + return glm::toMat4(glm::normalize(frame)); + }, + [](glm::quat previous_frame, glm::quat next_frame, float scale_factor) + { + return glm::toMat4(glm::slerp( + previous_frame, next_frame, scale_factor)); + })}; auto scale{bone_transform->scales.interpolate( - this->animation_time, - [](glm::vec3 frame) - { - return glm::scale(glm::mat4(1.0f), frame); - }, - [](glm::vec3 previous_frame, glm::vec3 next_frame, float scale_factor) - { - glm::vec3 scale{glm::mix( - previous_frame, next_frame, scale_factor)}; - return glm::scale(glm::mat4(1.0f), scale); - })}; - - this->bone_transforms[i] = position * rotation * scale; + this->animation_time, + [](glm::vec3 frame) + { + return glm::scale(glm::mat4(1.0f), frame); + }, + [](glm::vec3 previous_frame, glm::vec3 next_frame, float scale_factor) + { + glm::vec3 scale{glm::mix( + previous_frame, next_frame, scale_factor)}; + return glm::scale(glm::mat4(1.0f), scale); + })}; + + this->bone_transforms[i] = + this->skeletal_mesh->bones[i].offset_matrix * + (position * rotation * scale); } } |