1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-30 19:22:14 +00:00
This commit is contained in:
Lars Müller 2025-09-29 18:14:15 +00:00 committed by GitHub
commit 2920681524
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 9 deletions

View file

@ -400,7 +400,7 @@ IBoneSceneNode *CAnimatedMeshSceneNode::getJointNode(const c8 *jointName)
return 0; return 0;
} }
return PerJoint.SceneNodes[*number]; return PerJoint.SceneNodes[*number].get();
} }
//! Returns a pointer to a child node, which has the same transformation as //! Returns a pointer to a child node, which has the same transformation as
@ -419,7 +419,7 @@ IBoneSceneNode *CAnimatedMeshSceneNode::getJointNode(u32 jointID)
return 0; return 0;
} }
return PerJoint.SceneNodes[jointID]; return PerJoint.SceneNodes[jointID].get();
} }
//! Gets joint count. //! Gets joint count.
@ -441,8 +441,8 @@ bool CAnimatedMeshSceneNode::removeChild(ISceneNode *child)
if (ISceneNode::removeChild(child)) { if (ISceneNode::removeChild(child)) {
if (JointsUsed) { // stop weird bugs caused while changing parents as the joints are being created if (JointsUsed) { // stop weird bugs caused while changing parents as the joints are being created
for (u32 i = 0; i < PerJoint.SceneNodes.size(); ++i) { for (u32 i = 0; i < PerJoint.SceneNodes.size(); ++i) {
if (PerJoint.SceneNodes[i] == child) { if (PerJoint.SceneNodes[i].get() == child) {
PerJoint.SceneNodes[i] = 0; // remove link to child PerJoint.SceneNodes[i].reset(); // remove link to child
break; break;
} }
} }
@ -551,13 +551,13 @@ void CAnimatedMeshSceneNode::addJoints()
const auto *joint = joints[i]; const auto *joint = joints[i];
ISceneNode *parent = this; ISceneNode *parent = this;
if (joint->ParentJointID) if (joint->ParentJointID)
parent = PerJoint.SceneNodes.at(*joint->ParentJointID); // exists because of topo. order parent = PerJoint.SceneNodes.at(*joint->ParentJointID).get(); // exists because of topo. order
assert(parent); assert(parent);
const auto *matrix = std::get_if<core::matrix4>(&joint->transform); const auto *matrix = std::get_if<core::matrix4>(&joint->transform);
PerJoint.SceneNodes.push_back(new CBoneSceneNode( PerJoint.SceneNodes.push_back(irr_ptr<CBoneSceneNode>(new CBoneSceneNode(
parent, SceneManager, 0, i, joint->Name, parent, SceneManager, 0, i, joint->Name,
matrix ? core::Transform{} : std::get<core::Transform>(joint->transform), matrix ? core::Transform{} : std::get<core::Transform>(joint->transform),
matrix ? *matrix : std::optional<core::matrix4>{})); matrix ? *matrix : std::optional<core::matrix4>{})));
} }
} }
@ -610,7 +610,7 @@ void CAnimatedMeshSceneNode::checkJoints()
if (!JointsUsed) { if (!JointsUsed) {
for (u32 i = 0; i < PerJoint.SceneNodes.size(); ++i) for (u32 i = 0; i < PerJoint.SceneNodes.size(); ++i)
removeChild(PerJoint.SceneNodes[i]); removeChild(PerJoint.SceneNodes[i].get());
addJoints(); addJoints();
JointsUsed = true; JointsUsed = true;

View file

@ -10,6 +10,7 @@
#include "SkinnedMesh.h" #include "SkinnedMesh.h"
#include "Transform.h" #include "Transform.h"
#include "irr_ptr.h"
#include "matrix4.h" #include "matrix4.h"
namespace scene namespace scene
@ -172,7 +173,7 @@ private:
std::function<void(f32)> OnAnimateCallback; std::function<void(f32)> OnAnimateCallback;
struct PerJointData { struct PerJointData {
std::vector<CBoneSceneNode *> SceneNodes; std::vector<irr_ptr<CBoneSceneNode>> SceneNodes;
std::vector<core::matrix4> GlobalMatrices; std::vector<core::matrix4> GlobalMatrices;
std::vector<std::optional<core::Transform>> PreTransSaves; std::vector<std::optional<core::Transform>> PreTransSaves;
void setN(u16 n) { void setN(u16 n) {