From eecbef158dd5703c747440125f9f1e96ac61edca Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Sun, 20 Jul 2025 13:29:37 +0200 Subject: [PATCH] chore: replace dirty hack for viewhands with xmodel typee reading --- src/ObjLoading/XModel/LoaderXModel.cpp.template | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ObjLoading/XModel/LoaderXModel.cpp.template b/src/ObjLoading/XModel/LoaderXModel.cpp.template index 2e30b730..493bfc80 100644 --- a/src/ObjLoading/XModel/LoaderXModel.cpp.template +++ b/src/ObjLoading/XModel/LoaderXModel.cpp.template @@ -258,7 +258,7 @@ namespace } bool ApplyCommonBonesToXModel( - const JsonXModelLod& jLod, XModel& xmodel, unsigned lodNumber, const XModelCommon& common, AssetRegistration& registration) + const JsonXModel& jXModel, const JsonXModelLod& jLod, XModel& xmodel, unsigned lodNumber, const XModelCommon& common, AssetRegistration& registration) { if (common.m_bones.empty()) return true; @@ -343,8 +343,8 @@ namespace } } - // TODO: Dirty hack, this is not necessarly always related to the name - if (strstr(xmodel.name, "viewhands")) + // Viewhands seem to have nulled trans for some reason? + if (jXModel.type.value_or(JsonXModelType::RIGID) == JsonXModelType::VIEWHANDS) { memset(xmodel.trans, 0, sizeof(float) * 4 * (xmodel.numBones - xmodel.numRootBones)); } @@ -762,7 +762,12 @@ namespace return true; } - bool LoadLod(const JsonXModelLod& jLod, XModel& xmodel, unsigned lodNumber, AssetCreationContext& context, AssetRegistration& registration) + bool LoadLod(const JsonXModel& jXModel, + const JsonXModelLod& jLod, + XModel& xmodel, + unsigned lodNumber, + AssetCreationContext& context, + AssetRegistration& registration) { const auto file = m_search_path.Open(jLod.file); if (!file.IsOpen()) @@ -786,7 +791,7 @@ namespace if (lodNumber == 0u) { - if (!ApplyCommonBonesToXModel(jLod, xmodel, lodNumber, *common, registration)) + if (!ApplyCommonBonesToXModel(jXModel, jLod, xmodel, lodNumber, *common, registration)) return false; } else @@ -964,7 +969,7 @@ namespace xmodel.numLods = static_cast(jXModel.lods.size()); for (const auto& jLod : jXModel.lods) { - if (!LoadLod(jLod, xmodel, lodNumber++, context, registration)) + if (!LoadLod(jXModel, jLod, xmodel, lodNumber++, context, registration)) return false; }