mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
clean some remaining things up
This commit is contained in:
parent
d1a46a8da5
commit
cddd1a54f1
4 changed files with 17 additions and 29 deletions
|
@ -306,8 +306,6 @@ public:
|
|||
std::optional<std::string> Name;
|
||||
|
||||
//! Local transformation to be set by loaders. Mutated by animation.
|
||||
//! If a matrix is used, this joint **must not** be animated,
|
||||
//! because then the unique decomposition into translation, rotation and scale need not exist!
|
||||
using VariantTransform = std::variant<core::Transform, core::matrix4>;
|
||||
VariantTransform transform{core::Transform{}};
|
||||
|
||||
|
@ -316,7 +314,10 @@ public:
|
|||
return transform;
|
||||
|
||||
if (std::holds_alternative<core::matrix4>(transform)) {
|
||||
// .x lets animations override matrix transforms entirely.
|
||||
// .x lets animations override matrix transforms entirely,
|
||||
// which is what we implement here.
|
||||
// .gltf does not allow animation of nodes using matrix transforms.
|
||||
// Note that a decomposition into a TRS transform need not exist!
|
||||
core::Transform trs;
|
||||
keys.updateTransform(frame, trs);
|
||||
return {trs};
|
||||
|
|
|
@ -15,18 +15,6 @@ struct Transform {
|
|||
quaternion rotation;
|
||||
vector3df scale{1};
|
||||
|
||||
// Tries to decompose the matrix, if there is one.
|
||||
static Transform decompose(const core::matrix4 &mat)
|
||||
{
|
||||
auto scale = mat.getScale();
|
||||
return {
|
||||
mat.getTranslation(),
|
||||
quaternion(mat.getRotationRadians(scale)),
|
||||
scale,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Transform interpolate(Transform to, f32 time) const
|
||||
{
|
||||
core::quaternion interpolated_rotation;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "CAnimatedMeshSceneNode.h"
|
||||
#include "CBoneSceneNode.h"
|
||||
#include "EDebugSceneTypes.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "ISceneManager.h"
|
||||
#include "S3DVertex.h"
|
||||
|
@ -282,14 +281,15 @@ void CAnimatedMeshSceneNode::render()
|
|||
if (DebugDataVisible & scene::EDS_SKELETON) {
|
||||
if (Mesh->getMeshType() == EAMT_SKINNED) {
|
||||
// draw skeleton
|
||||
|
||||
/*for (auto *joint : ((SkinnedMesh *)Mesh)->getAllJoints()) {
|
||||
for (const auto *childJoint : joint->Children) {
|
||||
driver->draw3DLine(joint->GlobalAnimatedMatrix.getTranslation(),
|
||||
childJoint->GlobalAnimatedMatrix.getTranslation(),
|
||||
const auto &joints = (static_cast<SkinnedMesh *>(Mesh))->getAllJoints();
|
||||
for (u16 i = 0; i < PerJoint.GlobalMatrices.size(); ++i) {
|
||||
const auto translation = PerJoint.GlobalMatrices[i].getTranslation();
|
||||
if (auto pjid = joints[i]->ParentJointID) {
|
||||
const auto parent_translation = PerJoint.GlobalMatrices[*pjid].getTranslation();
|
||||
driver->draw3DLine(parent_translation, translation,
|
||||
video::SColor(255, 51, 66, 255));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "matrix4.h"
|
||||
#include "os.h"
|
||||
#include "vector3d.h"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
@ -62,7 +61,7 @@ void SkinnedMesh::setAnimationSpeed(f32 fps)
|
|||
using VariantTransform = SkinnedMesh::SJoint::VariantTransform;
|
||||
std::vector<VariantTransform> SkinnedMesh::animateMesh(f32 frame)
|
||||
{
|
||||
assert(HasAnimation);
|
||||
_IRR_DEBUG_BREAK_IF(!HasAnimation);
|
||||
std::vector<VariantTransform> result;
|
||||
result.reserve(AllJoints.size());
|
||||
for (auto *joint : AllJoints)
|
||||
|
@ -73,7 +72,7 @@ std::vector<VariantTransform> SkinnedMesh::animateMesh(f32 frame)
|
|||
core::aabbox3df SkinnedMesh::calculateBoundingBox(
|
||||
const std::vector<core::matrix4> &global_transforms)
|
||||
{
|
||||
assert(global_transforms.size() == AllJoints.size());
|
||||
_IRR_DEBUG_BREAK_IF(global_transforms.size() != AllJoints.size());
|
||||
core::aabbox3df result = StaticPartsBox;
|
||||
// skeletal animation
|
||||
for (u16 i = 0; i < AllJoints.size(); ++i) {
|
||||
|
@ -444,7 +443,7 @@ void SkinnedMesh::topoSortJoints()
|
|||
|
||||
for (u16 i = 0; i < n; ++i) {
|
||||
if (auto pjid = AllJoints[i]->ParentJointID)
|
||||
assert(*pjid < i);
|
||||
_IRR_DEBUG_BREAK_IF(*pjid >= i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,19 +517,19 @@ SkinnedMesh::SJoint *SkinnedMeshBuilder::addJoint(SJoint *parent)
|
|||
|
||||
void SkinnedMeshBuilder::addPositionKey(SJoint *joint, f32 frame, core::vector3df pos)
|
||||
{
|
||||
assert(joint);
|
||||
_IRR_DEBUG_BREAK_IF(!joint);
|
||||
joint->keys.position.pushBack(frame, pos);
|
||||
}
|
||||
|
||||
void SkinnedMeshBuilder::addScaleKey(SJoint *joint, f32 frame, core::vector3df scale)
|
||||
{
|
||||
assert(joint);
|
||||
_IRR_DEBUG_BREAK_IF(!joint);
|
||||
joint->keys.scale.pushBack(frame, scale);
|
||||
}
|
||||
|
||||
void SkinnedMeshBuilder::addRotationKey(SJoint *joint, f32 frame, core::quaternion rot)
|
||||
{
|
||||
assert(joint);
|
||||
_IRR_DEBUG_BREAK_IF(!joint);
|
||||
joint->keys.rotation.pushBack(frame, rot);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue