From 326aa1295e9cd97ace57398481f8c2f96ec61677 Mon Sep 17 00:00:00 2001 From: Unreal Karaulov Date: Sat, 30 Dec 2023 14:38:19 +0300 Subject: [PATCH] Hotfix missing model/sprite renderer in some cases Hotfix missing model/sprite renderer in some cases --- src/editor/BspRenderer.cpp | 67 +++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/src/editor/BspRenderer.cpp b/src/editor/BspRenderer.cpp index ac183d4a..3d694f75 100644 --- a/src/editor/BspRenderer.cpp +++ b/src/editor/BspRenderer.cpp @@ -1741,21 +1741,80 @@ void BspRenderer::refreshEnt(int entIdx) std::string lowerpath = toLowerCase(fgdClass->sprite); std::string newModelPath; - if (lowerpath.ends_with(".spr")) + if (lowerpath.ends_with(".mdl")) { if (FindPathInAssets(map, fgdClass->sprite, newModelPath)) { - renderEnts[entIdx].spr = AddNewSpriteToRender(newModelPath); + renderEnts[entIdx].mdl = AddNewModelToRender(newModelPath, body + sequence * 100 + skin * 1000); + renderEnts[entIdx].mdl->UpdateModelMeshList(); } else { FindPathInAssets(map, fgdClass->sprite, newModelPath, true); - renderEnts[entIdx].spr = NULL; + renderEnts[entIdx].mdl = NULL; } } else { - renderEnts[entIdx].spr = NULL; + renderEnts[entIdx].mdl = NULL; + if (lowerpath.ends_with(".spr")) + { + if (FindPathInAssets(map, fgdClass->sprite, newModelPath)) + { + renderEnts[entIdx].spr = AddNewSpriteToRender(newModelPath); + } + else + { + FindPathInAssets(map, fgdClass->sprite, newModelPath, true); + renderEnts[entIdx].spr = NULL; + } + } + else + { + renderEnts[entIdx].spr = NULL; + } + } + } + else + { + FgdClass* fgdClass = g_app->fgd->getFgdClass(ent->keyvalues["classname"]); + if (fgdClass && !fgdClass->model.empty()) + { + std::string lowerpath = toLowerCase(fgdClass->model); + std::string newModelPath; + if (lowerpath.ends_with(".mdl")) + { + if (FindPathInAssets(map, fgdClass->model, newModelPath)) + { + renderEnts[entIdx].mdl = AddNewModelToRender(newModelPath, body + sequence * 100 + skin * 1000); + renderEnts[entIdx].mdl->UpdateModelMeshList(); + } + else + { + FindPathInAssets(map, fgdClass->model, newModelPath, true); + renderEnts[entIdx].mdl = NULL; + } + } + else + { + renderEnts[entIdx].mdl = NULL; + if (lowerpath.ends_with(".spr")) + { + if (FindPathInAssets(map, fgdClass->model, newModelPath)) + { + renderEnts[entIdx].spr = AddNewSpriteToRender(newModelPath); + } + else + { + FindPathInAssets(map, fgdClass->model, newModelPath, true); + renderEnts[entIdx].spr = NULL; + } + } + else + { + renderEnts[entIdx].spr = NULL; + } + } } } }