Merge branch 'main' into dev
This commit is contained in:
@@ -412,7 +412,7 @@ void Entities::render(
|
||||
const auto& size = transform.size;
|
||||
if (!frustum || frustum->isBoxVisible(pos - size, pos + size)) {
|
||||
const auto* rigConfig = skeleton.config;
|
||||
rigConfig->render(assets, batch, skeleton, transform.combined, pos);
|
||||
rigConfig->render(assets, batch, skeleton, transform.rot, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-15
@@ -1,14 +1,14 @@
|
||||
#include "rigging.hpp"
|
||||
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
#include <glm/gtx/matrix_decompose.hpp>
|
||||
|
||||
#include "assets/Assets.hpp"
|
||||
#include "coders/json.hpp"
|
||||
#include "data/dv_util.hpp"
|
||||
#include "graphics/commons/Model.hpp"
|
||||
#include "graphics/render/ModelBatch.hpp"
|
||||
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
#include <glm/gtx/matrix_decompose.hpp>
|
||||
|
||||
using namespace rigging;
|
||||
|
||||
void ModelReference::refresh(const Assets& assets) {
|
||||
@@ -122,21 +122,26 @@ size_t SkeletonConfig::update(
|
||||
return count;
|
||||
}
|
||||
|
||||
static glm::mat4 build_matrix(const glm::mat3& rot, const glm::vec3& pos) {
|
||||
glm::mat4 combined(1.0f);
|
||||
combined = glm::translate(combined, pos);
|
||||
combined = combined * glm::mat4(rot);
|
||||
return combined;
|
||||
}
|
||||
|
||||
void SkeletonConfig::update(
|
||||
Skeleton& skeleton, const glm::mat4& matrix, const glm::vec3& position
|
||||
Skeleton& skeleton, const glm::mat3& rotation, 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);
|
||||
update(
|
||||
0,
|
||||
skeleton,
|
||||
root.get(),
|
||||
build_matrix(rotation, interpolation.getCurrent())
|
||||
);
|
||||
} else {
|
||||
update(0, skeleton, root.get(), matrix);
|
||||
update(0, skeleton, root.get(), rotation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,10 +149,10 @@ void SkeletonConfig::render(
|
||||
const Assets& assets,
|
||||
ModelBatch& batch,
|
||||
Skeleton& skeleton,
|
||||
const glm::mat4& matrix,
|
||||
const glm::mat3& rotation,
|
||||
const glm::vec3& position
|
||||
) const {
|
||||
update(skeleton, matrix, position);
|
||||
update(skeleton, rotation, position);
|
||||
|
||||
if (!skeleton.visible) {
|
||||
return;
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace rigging {
|
||||
|
||||
void update(
|
||||
Skeleton& skeleton,
|
||||
const glm::mat4& matrix,
|
||||
const glm::mat3& rotation,
|
||||
const glm::vec3& position
|
||||
) const;
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace rigging {
|
||||
const Assets& assets,
|
||||
ModelBatch& batch,
|
||||
Skeleton& skeleton,
|
||||
const glm::mat4& matrix,
|
||||
const glm::mat3& rotation,
|
||||
const glm::vec3& position
|
||||
) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user