From 47bfe35b26abde93406ed15268d3ccf313ef8dbb Mon Sep 17 00:00:00 2001 From: Kelsi Date: Tue, 5 May 2026 22:26:10 -0700 Subject: [PATCH] fix(editor): always load M2 skin file for NPC models WotLK M2 models store geometry in separate .skin files. The NPC renderer was only loading skin files when M2Loader::load() returned invalid (empty vertices). But some M2 files have vertices in the header yet need the skin file for indices, batches, and submeshes. Now always attempts to load the skin file regardless of initial isValid() state. This fixes creature models not rendering even when the M2 and skin files exist on disk. Also improved debug logging to show vertex/index counts when models fail to load, making it easier to diagnose remaining issues. --- tools/editor/editor_viewport.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/editor/editor_viewport.cpp b/tools/editor/editor_viewport.cpp index 7622d22c..00d454e0 100644 --- a/tools/editor/editor_viewport.cpp +++ b/tools/editor/editor_viewport.cpp @@ -241,11 +241,12 @@ void EditorViewport::rebuildObjects(const std::vector& objects, } else { auto data = assetManager_->readFile(npc.modelPath); if (data.empty()) { - LOG_DEBUG("NPC model not found (showing marker): ", npc.modelPath); + LOG_DEBUG("NPC model file not found: ", npc.modelPath); continue; } auto model = pipeline::M2Loader::load(data); - if (!model.isValid()) { + // Always try loading skin file (WotLK M2s need it for geometry) + { std::string skinPath = npc.modelPath; auto dotPos = skinPath.rfind('.'); if (dotPos != std::string::npos) @@ -254,7 +255,11 @@ void EditorViewport::rebuildObjects(const std::vector& objects, if (!skinData.empty()) pipeline::M2Loader::loadSkin(skinData, model); } - if (!model.isValid()) continue; + if (!model.isValid()) { + LOG_DEBUG("NPC model invalid after skin load: ", npc.modelPath, + " (verts=", model.vertices.size(), " idx=", model.indices.size(), ")"); + continue; + } if (model.boundRadius < 1.0f) model.boundRadius = 50.0f; // Validate vertex data bool ok = true;