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:
parent
f99a1a7c7c
commit
a37bdbf8b7
6 changed files with 3535 additions and 4 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue