2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-05-25 02:51:43 +00:00

chore: set XSurface deformed property when applicable

This commit is contained in:
Jan Laupetin
2026-05-04 18:31:12 +02:00
parent 40e5a9de97
commit 8a791816ed
3 changed files with 27 additions and 3 deletions
+5
View File
@@ -516,6 +516,11 @@ namespace IW5
typedef tdef_align32(16) XSurfaceTri XSurfaceTri16; typedef tdef_align32(16) XSurfaceTri XSurfaceTri16;
enum XSurfaceFlag
{
XSURFACE_FLAG_DEFORMED = 0x40
};
struct XSurface struct XSurface
{ {
unsigned char tileMode; unsigned char tileMode;
@@ -752,9 +752,16 @@ namespace
// Since bone weights are sorted by weight count, the last must have the highest weight count // 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 maxWeightCount = common.m_vertex_bone_weights[xmodelToCommonVertexIndexLookup[xmodelToCommonVertexIndexLookup.size() - 1]].weightCount;
const auto modelIsRigid = maxWeightCount <= 1; const auto surfaceIsRigid = maxWeightCount <= 1;
if (modelIsRigid) #if defined(FEATURE_IW3) || defined(FEATURE_IW4)
surface.deformed = !surfaceIsRigid;
#else
if (!surfaceIsRigid)
surface.flags |= XSURFACE_FLAG_DEFORMED;
#endif
if (surfaceIsRigid)
{ {
constexpr auto maxVerticesForRigid = static_cast<size_t>(std::numeric_limits<decltype(XSurface::vertCount)>::max()); constexpr auto maxVerticesForRigid = static_cast<size_t>(std::numeric_limits<decltype(XSurface::vertCount)>::max());
if (vertexOffset + xmodelToCommonVertexIndexLookup.size() > maxVerticesForRigid) if (vertexOffset + xmodelToCommonVertexIndexLookup.size() > maxVerticesForRigid)
@@ -790,7 +797,7 @@ namespace
if (!common.m_bone_weight_data.weights.empty()) if (!common.m_bone_weight_data.weights.empty())
{ {
if (modelIsRigid) if (surfaceIsRigid)
{ {
CreateVertListData(surface, xmodelToCommonVertexIndexLookup, common); CreateVertListData(surface, xmodelToCommonVertexIndexLookup, common);
} }
@@ -423,6 +423,12 @@ namespace
if (surface.vertList) if (surface.vertList)
{ {
#if defined(FEATURE_IW3) || defined(FEATURE_IW4)
assert(!surface.deformed);
#else
assert((surface.flags & XSURFACE_FLAG_DEFORMED) == 0);
#endif
for (auto vertListIndex = 0u; vertListIndex < surface.vertListCount; vertListIndex++) for (auto vertListIndex = 0u; vertListIndex < surface.vertListCount; vertListIndex++)
{ {
const auto& vertList = surface.vertList[vertListIndex]; const auto& vertList = surface.vertList[vertListIndex];
@@ -442,6 +448,12 @@ namespace
auto vertsBlendOffset = 0u; auto vertsBlendOffset = 0u;
if (surface.vertInfo.vertsBlend) if (surface.vertInfo.vertsBlend)
{ {
#if defined(FEATURE_IW3) || defined(FEATURE_IW4)
assert(surface.deformed);
#else
assert((surface.flags & XSURFACE_FLAG_DEFORMED) > 0);
#endif
// 1 bone weight // 1 bone weight
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++) for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
{ {