mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-12 16:15:20 +02: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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user