1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-21 18:11:11 +00:00

Fix and clean up skeletal animation (#15722)

* Fix attachments lagging behind their parents (#14818)
* Fix animation blending (#14817)
* Bring back cool guy as another .x smoke test
* Add .x mesh loader unittest
* Do bounding box & matrix calculation at proper point in time
* Remove obsolete `SAnimatedMesh`
This commit is contained in:
Lars Müller 2025-06-01 23:21:35 +02:00 committed by GitHub
parent 0bb87eb1ff
commit fde6384a09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 856 additions and 1388 deletions

View file

@ -143,31 +143,25 @@ bool CB3DMeshFileLoader::readChunkNODE(SkinnedMesh::SJoint *inJoint)
os::Printer::log(logStr.c_str(), joint->Name.value_or("").c_str(), ELL_DEBUG);
#endif
f32 position[3], scale[3], rotation[4];
core::Transform transform;
{
f32 t[3], s[3], r[4];
readFloats(position, 3);
readFloats(scale, 3);
readFloats(rotation, 4);
readFloats(t, 3);
readFloats(s, 3);
readFloats(r, 4);
joint->Animatedposition = core::vector3df(position[0], position[1], position[2]);
joint->Animatedscale = core::vector3df(scale[0], scale[1], scale[2]);
joint->Animatedrotation = core::quaternion(rotation[1], rotation[2], rotation[3], rotation[0]);
// Build LocalMatrix:
core::matrix4 positionMatrix;
positionMatrix.setTranslation(joint->Animatedposition);
core::matrix4 scaleMatrix;
scaleMatrix.setScale(joint->Animatedscale);
core::matrix4 rotationMatrix;
joint->Animatedrotation.getMatrix_transposed(rotationMatrix);
joint->LocalMatrix = positionMatrix * rotationMatrix * scaleMatrix;
joint->transform = transform = {
{t[0], t[1], t[2]},
{r[1], r[2], r[3], r[0]},
{s[0], s[1], s[2]},
};
}
if (inJoint)
joint->GlobalMatrix = inJoint->GlobalMatrix * joint->LocalMatrix;
joint->GlobalMatrix = inJoint->GlobalMatrix * transform.buildMatrix();
else
joint->GlobalMatrix = joint->LocalMatrix;
joint->GlobalMatrix = transform.buildMatrix();
while (B3dStack.getLast().startposition + B3dStack.getLast().length > B3DFile->getPos()) // this chunk repeats
{