feat: players interpolation & add hud.set_allow_pause(...)

This commit is contained in:
MihailRis
2025-01-17 01:44:46 +03:00
parent 036e13a2ca
commit 2fa71b3bf0
25 changed files with 232 additions and 41 deletions
+21 -7
View File
@@ -6,9 +6,8 @@
#include "graphics/commons/Model.hpp"
#include "graphics/render/ModelBatch.hpp"
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/ext/matrix_transform.hpp>
#include <glm/gtx/norm.hpp>
#include <glm/gtx/matrix_decompose.hpp>
using namespace rigging;
@@ -69,7 +68,7 @@ SkeletonConfig::SkeletonConfig(
}
size_t SkeletonConfig::update(
size_t index, Skeleton& skeleton, Bone* node, glm::mat4 matrix
size_t index, Skeleton& skeleton, Bone* node, const glm::mat4& matrix
) const {
auto boneMatrix = skeleton.pose.matrices[index];
auto boneOffset = node->getOffset();
@@ -90,17 +89,32 @@ size_t SkeletonConfig::update(
return count;
}
void SkeletonConfig::update(Skeleton& skeleton, glm::mat4 matrix) const {
update(0, skeleton, root.get(), matrix);
void SkeletonConfig::update(
Skeleton& skeleton, const glm::mat4& matrix, const glm::vec3& position
) const {
if (skeleton.interpolation.isEnabled()) {
const auto& interpolation = skeleton.interpolation;
glm::vec3 scale, translation, skew;
glm::quat rotation;
glm::vec4 perspective;
glm::decompose(matrix, scale, rotation, translation, skew, perspective);
auto delta = interpolation.getCurrent() - position;
auto interpolatedMatrix = glm::translate(matrix, delta);
update(0, skeleton, root.get(), interpolatedMatrix);
} else {
update(0, skeleton, root.get(), matrix);
}
}
void SkeletonConfig::render(
const Assets& assets,
ModelBatch& batch,
Skeleton& skeleton,
const glm::mat4& matrix
const glm::mat4& matrix,
const glm::vec3& position
) const {
update(skeleton, matrix);
update(skeleton, matrix, position);
if (!skeleton.visible) {
return;