2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-12 19:47:27 +00:00

fix: not being able to write xmodel_export with omitted default armature

This commit is contained in:
Jan Laupetin
2025-08-09 13:36:09 +01:00
parent f68fdae191
commit 0cc47ce12c
2 changed files with 14 additions and 8 deletions

View File

@@ -18,16 +18,16 @@ protected:
auto vertexOffset = 0u; auto vertexOffset = 0u;
for (const auto& vertex : xmodel.m_vertices) for (const auto& vertex : xmodel.m_vertices)
{ {
XModelVertexBoneWeights weights{0, 0}; XModelVertexBoneWeights weights{.weightOffset = 0, .weightCount = 0};
if (vertexOffset < xmodel.m_vertex_bone_weights.size()) if (vertexOffset < xmodel.m_vertex_bone_weights.size())
weights = xmodel.m_vertex_bone_weights[vertexOffset]; weights = xmodel.m_vertex_bone_weights[vertexOffset];
m_vertex_merger.Add(VertexMergerPos{vertex.coordinates[0], m_vertex_merger.Add(VertexMergerPos{.x = vertex.coordinates[0],
vertex.coordinates[1], .y = vertex.coordinates[1],
vertex.coordinates[2], .z = vertex.coordinates[2],
&xmodel.m_bone_weight_data.weights[weights.weightOffset], .weights = &xmodel.m_bone_weight_data.weights[weights.weightOffset],
weights.weightCount}); .weightCount = weights.weightCount});
vertexOffset++; vertexOffset++;
} }

View File

@@ -532,6 +532,12 @@ namespace
} }
} }
bool CanOmitDefaultArmature()
{
return ObjWriting::Configuration.ModelOutputFormat != ObjWriting::Configuration_t::ModelOutputFormat_e::XMODEL_EXPORT
&& ObjWriting::Configuration.ModelOutputFormat != ObjWriting::Configuration_t::ModelOutputFormat_e::XMODEL_BIN;
}
void PopulateXModelWriter(XModelCommon& out, const AssetDumpingContext& context, const unsigned lod, const XModel* model) void PopulateXModelWriter(XModelCommon& out, const AssetDumpingContext& context, const unsigned lod, const XModel* model)
{ {
DistinctMapper<Material*> materialMapper(model->numsurfs); DistinctMapper<Material*> materialMapper(model->numsurfs);
@@ -543,7 +549,7 @@ namespace
AddXModelVertices(out, model, lod); AddXModelVertices(out, model, lod);
AddXModelFaces(out, model, lod); AddXModelFaces(out, model, lod);
if (!HasDefaultArmature(model, lod)) if (!CanOmitDefaultArmature() || !HasDefaultArmature(model, lod))
{ {
AddXModelBones(out, context, model); AddXModelBones(out, context, model);
AddXModelVertexBoneWeights(out, model, lod); AddXModelVertexBoneWeights(out, model, lod);