From 92e236b1fe4d4197aea61233a8f08140f419cc39 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Sun, 3 May 2026 17:19:48 +0200 Subject: [PATCH] chore: only allocate 3 floats per bone for applicable games --- src/ObjLoading/XModel/LoaderXModel.cpp.template | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ObjLoading/XModel/LoaderXModel.cpp.template b/src/ObjLoading/XModel/LoaderXModel.cpp.template index b23fbd2b..018ada36 100644 --- a/src/ObjLoading/XModel/LoaderXModel.cpp.template +++ b/src/ObjLoading/XModel/LoaderXModel.cpp.template @@ -323,8 +323,12 @@ namespace { xmodel.parentList = m_memory.Alloc(xmodel.numBones - xmodel.numRootBones); - // For some reason Treyarch games allocate for a vec4 here. it is treated as a vec3 though? +#if defined(FEATURE_IW3) || defined(FEATURE_T5) || defined(FEATURE_T6) + // For some reason some games allocate for a vec4 here. it is treated as a vec3 though? xmodel.trans = m_memory.Alloc((xmodel.numBones - xmodel.numRootBones) * 4u); +#else + xmodel.trans = m_memory.Alloc((xmodel.numBones - xmodel.numRootBones) * 3u); +#endif xmodel.quats = m_memory.Alloc(xmodel.numBones - xmodel.numRootBones); } else @@ -373,7 +377,11 @@ namespace // Viewhands seem to have nulled trans for some reason? if (jXModel.type.value_or(JsonXModelType::RIGID) == JsonXModelType::VIEWHANDS) { +#if defined(FEATURE_IW3) || defined(FEATURE_T5) || defined(FEATURE_T6) memset(xmodel.trans, 0, sizeof(float) * 4 * (xmodel.numBones - xmodel.numRootBones)); +#else + memset(xmodel.trans, 0, sizeof(float) * 3 * (xmodel.numBones - xmodel.numRootBones)); +#endif } return true;