mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-12-19 08:51:50 +00:00
Merge pull request #617 from Laupetin/fix/rigid-models-written-as-animated
fix: always writing rigid models as animated
This commit is contained in:
@@ -725,14 +725,33 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto maxVertices = std::numeric_limits<decltype(XSurface::vertCount)>::max();
|
ReorderVerticesByWeightCount(xmodelToCommonVertexIndexLookup, surface, common);
|
||||||
if (vertexOffset + xmodelToCommonVertexIndexLookup.size() > maxVertices)
|
|
||||||
|
// Since bone weights are sorted by weight count, the last must have the highest weight count
|
||||||
|
const auto maxWeightCount = common.m_vertex_bone_weights[xmodelToCommonVertexIndexLookup[xmodelToCommonVertexIndexLookup.size() - 1]].weightCount;
|
||||||
|
const auto modelIsRigid = maxWeightCount <= 1;
|
||||||
|
|
||||||
|
if (modelIsRigid)
|
||||||
{
|
{
|
||||||
con::error("Lod exceeds limit of {} vertices", maxVertices);
|
constexpr auto maxVerticesForRigid = static_cast<size_t>(std::numeric_limits<decltype(XSurface::vertCount)>::max());
|
||||||
|
if (vertexOffset + xmodelToCommonVertexIndexLookup.size() > maxVerticesForRigid)
|
||||||
|
{
|
||||||
|
con::error("Lod exceeds limit of {} vertices for rigid models", maxVerticesForRigid);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
constexpr auto maxVerticesForAnimated =
|
||||||
|
std::min(static_cast<size_t>(std::numeric_limits<decltype(XSurface::vertCount)>::max()),
|
||||||
|
static_cast<size_t>(std::numeric_limits<std::remove_extent_t<decltype(XSurfaceVertexInfo::vertCount)>>::max()));
|
||||||
|
|
||||||
ReorderVerticesByWeightCount(xmodelToCommonVertexIndexLookup, surface, common);
|
if (vertexOffset + xmodelToCommonVertexIndexLookup.size() > maxVerticesForAnimated)
|
||||||
|
{
|
||||||
|
con::error("Lod exceeds limit of {} vertices for animated models", maxVerticesForAnimated);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
surface.baseVertIndex = static_cast<uint16_t>(vertexOffset);
|
surface.baseVertIndex = static_cast<uint16_t>(vertexOffset);
|
||||||
surface.vertCount = static_cast<uint16_t>(xmodelToCommonVertexIndexLookup.size());
|
surface.vertCount = static_cast<uint16_t>(xmodelToCommonVertexIndexLookup.size());
|
||||||
@@ -748,11 +767,7 @@ namespace
|
|||||||
|
|
||||||
if (!common.m_bone_weight_data.weights.empty())
|
if (!common.m_bone_weight_data.weights.empty())
|
||||||
{
|
{
|
||||||
// Since bone weights are sorted by weight count, the last must have the highest weight count
|
if (modelIsRigid)
|
||||||
const auto maxWeightCount =
|
|
||||||
common.m_vertex_bone_weights[xmodelToCommonVertexIndexLookup[xmodelToCommonVertexIndexLookup.size() - 1]].weightCount;
|
|
||||||
|
|
||||||
if (maxWeightCount == 0) // XModel is rigid
|
|
||||||
{
|
{
|
||||||
CreateVertListData(surface, xmodelToCommonVertexIndexLookup, common);
|
CreateVertListData(surface, xmodelToCommonVertexIndexLookup, common);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user