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.
This commit is contained in:
Kelsi 2026-05-05 22:26:10 -07:00
parent 92787901d8
commit 47bfe35b26

View file

@ -241,11 +241,12 @@ void EditorViewport::rebuildObjects(const std::vector<PlacedObject>& 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<PlacedObject>& 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;