mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
cleanup
This commit is contained in:
parent
abc2e54c07
commit
a687a7a6e7
2 changed files with 72 additions and 63 deletions
|
@ -163,9 +163,7 @@ IMesh *CAnimatedMeshSceneNode::getMeshForCurrentFrame()
|
|||
|
||||
SkinnedMesh *skinnedMesh = static_cast<SkinnedMesh *>(Mesh);
|
||||
|
||||
skinnedMesh->animateMesh(getFrameNr());
|
||||
|
||||
// skinnedMesh->transferJointsToMesh(JointChildSceneNodes);
|
||||
skinnedMesh->transferJointsToMesh(JointChildSceneNodes);
|
||||
|
||||
// Update the skinned mesh for the current joint transforms.
|
||||
skinnedMesh->skinMesh();
|
||||
|
@ -174,8 +172,6 @@ IMesh *CAnimatedMeshSceneNode::getMeshForCurrentFrame()
|
|||
|
||||
Box = skinnedMesh->getBoundingBox();
|
||||
|
||||
setAutomaticCulling(EAC_OFF);
|
||||
|
||||
return skinnedMesh;
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +234,6 @@ void CAnimatedMeshSceneNode::render()
|
|||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
|
||||
// for debug purposes only:
|
||||
// DebugDataVisible = ~0;
|
||||
if (DebugDataVisible && PassCount == 1) {
|
||||
video::SMaterial debug_mat;
|
||||
debug_mat.AntiAliasing = video::EAAM_OFF;
|
||||
|
@ -513,19 +508,16 @@ void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh *mesh)
|
|||
// get materials and bounding box
|
||||
Box = Mesh->getBoundingBox();
|
||||
|
||||
IMesh *m = Mesh->getMesh(0);
|
||||
if (m) {
|
||||
Materials.clear();
|
||||
Materials.reallocate(m->getMeshBufferCount());
|
||||
Materials.reallocate(Mesh->getMeshBufferCount());
|
||||
|
||||
for (u32 i = 0; i < m->getMeshBufferCount(); ++i) {
|
||||
IMeshBuffer *mb = m->getMeshBuffer(i);
|
||||
for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i) {
|
||||
IMeshBuffer *mb = Mesh->getMeshBuffer(i);
|
||||
if (mb)
|
||||
Materials.push_back(mb->getMaterial());
|
||||
else
|
||||
Materials.push_back(video::SMaterial());
|
||||
}
|
||||
}
|
||||
|
||||
// clean up joint nodes
|
||||
if (JointsUsed) {
|
||||
|
@ -563,13 +555,14 @@ void CAnimatedMeshSceneNode::setRenderFromIdentity(bool enable)
|
|||
//! updates the joint positions of this mesh
|
||||
void CAnimatedMeshSceneNode::animateJoints()
|
||||
{
|
||||
if (Mesh && Mesh->getMeshType() == EAMT_SKINNED) {
|
||||
if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED)
|
||||
return;
|
||||
|
||||
checkJoints();
|
||||
const f32 frame = getFrameNr(); // old?
|
||||
|
||||
SkinnedMesh *skinnedMesh = static_cast<SkinnedMesh *>(Mesh);
|
||||
|
||||
skinnedMesh->animateMesh(frame);
|
||||
skinnedMesh->animateMesh(getFrameNr());
|
||||
skinnedMesh->recoverJointsFromMesh(JointChildSceneNodes);
|
||||
|
||||
//-----------------------------------------
|
||||
|
@ -596,7 +589,7 @@ void CAnimatedMeshSceneNode::animateJoints()
|
|||
|
||||
// Code is slow, needs to be fixed up
|
||||
|
||||
const core::quaternion RotationStart(PretransitingSave[n].getRotationRadians());
|
||||
const core::quaternion RotationStart(PretransitingSave[n].getRotationDegrees() * core::DEGTORAD);
|
||||
const core::quaternion RotationEnd(JointChildSceneNodes[n]->getRotation() * core::DEGTORAD);
|
||||
|
||||
core::quaternion QRotation;
|
||||
|
@ -616,7 +609,6 @@ void CAnimatedMeshSceneNode::animateJoints()
|
|||
// TransitingBlend));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAnimatedMeshSceneNode::checkJoints()
|
||||
|
|
|
@ -636,11 +636,25 @@ void SkinnedMesh::recoverJointsFromMesh(std::vector<IBoneSceneNode *> &jointChil
|
|||
for (u32 i = 0; i < AllJoints.size(); ++i) {
|
||||
IBoneSceneNode *node = jointChildSceneNodes[i];
|
||||
SJoint *joint = AllJoints[i];
|
||||
if (std::holds_alternative<SJoint::Transform>(joint->transform)) {
|
||||
auto transform = std::get<SJoint::Transform>(joint->transform);
|
||||
node->setPosition(transform.translation);
|
||||
{
|
||||
core::vector3df euler;
|
||||
auto rot = transform.rotation;
|
||||
// Invert to be consistent with setRotationDegrees
|
||||
rot.makeInverse();
|
||||
rot.toEuler(euler);
|
||||
node->setRotation(euler * core::RADTODEG);
|
||||
}
|
||||
node->setScale(transform.scale);
|
||||
} else {
|
||||
node->setPosition(joint->LocalAnimatedMatrix.getTranslation());
|
||||
node->setRotation(joint->LocalAnimatedMatrix.getRotationDegrees());
|
||||
node->setScale(joint->LocalAnimatedMatrix.getScale());
|
||||
}
|
||||
|
||||
node->updateAbsolutePosition(); // WTF
|
||||
// node->updateAbsolutePosition(); // WTF
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -650,10 +664,13 @@ void SkinnedMesh::transferJointsToMesh(const std::vector<IBoneSceneNode *> &join
|
|||
const IBoneSceneNode *const node = jointChildSceneNodes[i];
|
||||
SJoint *joint = AllJoints[i];
|
||||
|
||||
if (std::holds_alternative<SJoint::Transform>(joint->transform)) {
|
||||
joint->LocalAnimatedMatrix = core::matrix4();
|
||||
joint->LocalAnimatedMatrix.setRotationDegrees(node->getRotation());
|
||||
joint->LocalAnimatedMatrix.setTranslation(node->getPosition());
|
||||
joint->LocalAnimatedMatrix *= core::matrix4().setScale(node->getScale());
|
||||
}
|
||||
}
|
||||
// Make sure we recalc the next frame
|
||||
LastAnimatedFrame = -1;
|
||||
SkinnedLastFrame = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue