mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-02 08:29:36 +00:00
fix: never omit default armature
This commit is contained in:
@@ -180,47 +180,6 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HasDefaultArmature(const XModel* model, const unsigned lod)
|
||||
{
|
||||
if (model->numRootBones != 1 || model->numBones != 1)
|
||||
return false;
|
||||
|
||||
XSurface* surfs;
|
||||
unsigned surfCount;
|
||||
if (!GetSurfaces(model, lod, surfs, surfCount))
|
||||
return true;
|
||||
|
||||
for (auto surfIndex = 0u; surfIndex < surfCount; surfIndex++)
|
||||
{
|
||||
const auto& surface = surfs[surfIndex];
|
||||
|
||||
if (surface.vertListCount != 1 || surface.vertInfo.vertsBlend)
|
||||
return false;
|
||||
|
||||
const auto& vertList = surface.vertList[0];
|
||||
#ifdef FEATURE_IW3
|
||||
if (vertList.boneOffset != 0 || vertList.triOffset != 0 || vertList.vertCount != surface.vertCount)
|
||||
#else
|
||||
if (vertList.boneOffset != 0 || vertList.triOffset != 0 || vertList.triCount != surface.triCount || vertList.vertCount != surface.vertCount)
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OmitDefaultArmature(XModelCommon& common)
|
||||
{
|
||||
common.m_bones.clear();
|
||||
common.m_bone_weight_data.weights.clear();
|
||||
common.m_vertex_bone_weights.resize(common.m_vertices.size());
|
||||
for (auto& vertexWeights : common.m_vertex_bone_weights)
|
||||
{
|
||||
vertexWeights.weightOffset = 0u;
|
||||
vertexWeights.weightCount = 0u;
|
||||
}
|
||||
}
|
||||
|
||||
void AddXModelBones(XModelCommon& out, const AssetDumpingContext& context, const XModel* model)
|
||||
{
|
||||
for (auto boneNum = 0u; boneNum < model->numBones; boneNum++)
|
||||
@@ -536,12 +495,6 @@ 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)
|
||||
{
|
||||
DistinctMapper<Material*> materialMapper(model->numsurfs);
|
||||
@@ -553,15 +506,8 @@ namespace
|
||||
AddXModelVertices(out, model, lod);
|
||||
AddXModelFaces(out, model, lod);
|
||||
|
||||
if (!CanOmitDefaultArmature() || !HasDefaultArmature(model, lod))
|
||||
{
|
||||
AddXModelBones(out, context, model);
|
||||
AddXModelVertexBoneWeights(out, model, lod);
|
||||
}
|
||||
else
|
||||
{
|
||||
OmitDefaultArmature(out);
|
||||
}
|
||||
AddXModelBones(out, context, model);
|
||||
AddXModelVertexBoneWeights(out, model, lod);
|
||||
}
|
||||
|
||||
void DumpObjMtl(const XModelCommon& common, const AssetDumpingContext& context, const XAssetInfo<XModel>& asset)
|
||||
|
||||
Reference in New Issue
Block a user