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

Restore .x models to working state (#15550)

* Add "lava flan" (.x model) smoke test

* Fix double finalize in `.x` mesh loader

* Use reserve instead of resize again

The weights are added indirectly via `AnimatedMesh->addWeight`
This commit is contained in:
Lars Müller 2024-12-18 20:29:35 +01:00 committed by GitHub
parent f99a1a7c7c
commit a37bdbf8b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 3535 additions and 4 deletions

View file

@ -56,8 +56,9 @@ IAnimatedMesh *CXMeshFileLoader::createMesh(io::IReadFile *file)
AnimatedMesh = new SkinnedMeshBuilder();
SkinnedMesh *res = nullptr;
if (load(file)) {
AnimatedMesh->finalize();
res = AnimatedMesh->finalize();
} else {
AnimatedMesh->drop();
AnimatedMesh = 0;
@ -89,7 +90,7 @@ IAnimatedMesh *CXMeshFileLoader::createMesh(io::IReadFile *file)
delete Meshes[i];
Meshes.clear();
return AnimatedMesh->finalize();
return res;
}
bool CXMeshFileLoader::load(io::IReadFile *file)
@ -962,15 +963,16 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
u32 i;
const u32 jointStart = joint->Weights.size();
joint->Weights.resize(jointStart + nWeights);
joint->Weights.reserve(jointStart + nWeights);
mesh.WeightJoint.reallocate(mesh.WeightJoint.size() + nWeights);
mesh.WeightNum.reallocate(mesh.WeightNum.size() + nWeights);
for (i = 0; i < nWeights; ++i) {
mesh.WeightJoint.push_back(*n);
mesh.WeightNum.push_back(joint->Weights.size());
mesh.WeightNum.push_back(joint->Weights.size()); // id of weight
// Note: This adds a weight to joint->Weights
SkinnedMesh::SWeight *weight = AnimatedMesh->addWeight(joint);
weight->buffer_id = 0;