mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-13 05:41:43 +00:00
fix: only omit default armature if it can be omitted for all lods
This commit is contained in:
committed by
Jan Laupetin
parent
f3859e6952
commit
618592e411
@@ -180,7 +180,7 @@ namespace
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasDefaultArmature(const XModel* model, const unsigned lod)
|
bool HasDefaultArmatureForLod(const XModel* model, const unsigned lod)
|
||||||
{
|
{
|
||||||
if (model->numRootBones != 1 || model->numBones != 1)
|
if (model->numRootBones != 1 || model->numBones != 1)
|
||||||
return false;
|
return false;
|
||||||
@@ -213,6 +213,17 @@ namespace
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HasDefaultArmatureForAllLods(const XModel* model)
|
||||||
|
{
|
||||||
|
for (auto lod = 0u; lod < model->numLods; lod++)
|
||||||
|
{
|
||||||
|
if (!HasDefaultArmatureForLod(model, lod))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void OmitDefaultArmature(XModelCommon& common)
|
void OmitDefaultArmature(XModelCommon& common)
|
||||||
{
|
{
|
||||||
common.m_bones.clear();
|
common.m_bones.clear();
|
||||||
@@ -557,7 +568,9 @@ namespace
|
|||||||
AddXModelVertices(out, model, lod);
|
AddXModelVertices(out, model, lod);
|
||||||
AddXModelFaces(out, model, lod);
|
AddXModelFaces(out, model, lod);
|
||||||
|
|
||||||
if (!CanOmitDefaultArmature() || !HasDefaultArmature(model, lod))
|
// Keep armature handling consistent across all LODs so dumped GLTF/GLB round-trips
|
||||||
|
// preserve the same bone layout when re-imported.
|
||||||
|
if (!CanOmitDefaultArmature() || !HasDefaultArmatureForAllLods(model))
|
||||||
{
|
{
|
||||||
AddXModelBones(out, context, model);
|
AddXModelBones(out, context, model);
|
||||||
AddXModelVertexBoneWeights(out, model, lod);
|
AddXModelVertexBoneWeights(out, model, lod);
|
||||||
|
|||||||
Reference in New Issue
Block a user