1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Refactor: Merge [IC]SkinnedMesh into SkinnedMesh (#15511)

This commit is contained in:
Lars Müller 2024-12-06 18:03:44 +01:00 committed by GitHub
parent 810f39767c
commit 3e10d9ccf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 326 additions and 646 deletions

View file

@ -7,7 +7,7 @@
#include "ISceneManager.h"
#include "S3DVertex.h"
#include "os.h"
#include "CSkinnedMesh.h"
#include "SkinnedMesh.h"
#include "IDummyTransformationSceneNode.h"
#include "IBoneSceneNode.h"
#include "IMaterialRenderer.h"
@ -165,7 +165,7 @@ IMesh *CAnimatedMeshSceneNode::getMeshForCurrentFrame()
// As multiple scene nodes may be sharing the same skinned mesh, we have to
// re-animate it every frame to ensure that this node gets the mesh that it needs.
CSkinnedMesh *skinnedMesh = static_cast<CSkinnedMesh *>(Mesh);
SkinnedMesh *skinnedMesh = static_cast<SkinnedMesh *>(Mesh);
if (JointMode == EJUOR_CONTROL) // write to mesh
skinnedMesh->transferJointsToMesh(JointChildSceneNodes);
@ -299,8 +299,8 @@ void CAnimatedMeshSceneNode::render()
if (Mesh->getMeshType() == EAMT_SKINNED) {
// draw skeleton
for (u32 g = 0; g < ((ISkinnedMesh *)Mesh)->getAllJoints().size(); ++g) {
ISkinnedMesh::SJoint *joint = ((ISkinnedMesh *)Mesh)->getAllJoints()[g];
for (u32 g = 0; g < ((SkinnedMesh *)Mesh)->getAllJoints().size(); ++g) {
auto *joint = ((SkinnedMesh *)Mesh)->getAllJoints()[g];
for (u32 n = 0; n < joint->Children.size(); ++n) {
driver->draw3DLine(joint->GlobalAnimatedMatrix.getTranslation(),
@ -404,7 +404,7 @@ IBoneSceneNode *CAnimatedMeshSceneNode::getJointNode(const c8 *jointName)
checkJoints();
ISkinnedMesh *skinnedMesh = (ISkinnedMesh *)Mesh;
auto *skinnedMesh = (SkinnedMesh *)Mesh;
const std::optional<u32> number = skinnedMesh->getJointNumber(jointName);
@ -446,7 +446,7 @@ u32 CAnimatedMeshSceneNode::getJointCount() const
if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED)
return 0;
ISkinnedMesh *skinnedMesh = (ISkinnedMesh *)Mesh;
auto *skinnedMesh = (SkinnedMesh *)Mesh;
return skinnedMesh->getJointCount();
}
@ -596,7 +596,7 @@ void CAnimatedMeshSceneNode::animateJoints(bool CalculateAbsolutePositions)
checkJoints();
const f32 frame = getFrameNr(); // old?
CSkinnedMesh *skinnedMesh = static_cast<CSkinnedMesh *>(Mesh);
SkinnedMesh *skinnedMesh = static_cast<SkinnedMesh *>(Mesh);
skinnedMesh->transferOnlyJointsHintsToMesh(JointChildSceneNodes);
skinnedMesh->animateMesh(frame, 1.0f);
@ -671,8 +671,8 @@ void CAnimatedMeshSceneNode::checkJoints()
JointChildSceneNodes.clear();
// Create joints for SkinnedMesh
((CSkinnedMesh *)Mesh)->addJoints(JointChildSceneNodes, this, SceneManager);
((CSkinnedMesh *)Mesh)->recoverJointsFromMesh(JointChildSceneNodes);
((SkinnedMesh *)Mesh)->addJoints(JointChildSceneNodes, this, SceneManager);
((SkinnedMesh *)Mesh)->recoverJointsFromMesh(JointChildSceneNodes);
JointsUsed = true;
JointMode = EJUOR_READ;