Fix mesh artifacts on vanilla/TBC M2 models when using expansion overlays

Vanilla (v256) and TBC (v263) M2 files embed skin data directly, parsed
during M2Loader::load(). The code unconditionally loaded external .skin
files afterwards, which resolved to WotLK-format .skin files (48-byte
submeshes) from the base manifest — overwriting the correctly parsed
embedded skin (32-byte submeshes) and causing mesh corruption on all
character models. Guard all 13 loadSkin() call sites with version >= 264
so external .skin files are only loaded for WotLK M2s that need them.
This commit is contained in:
Kelsi 2026-02-14 13:57:54 -08:00
parent a67dca5787
commit ca3150e43d
3 changed files with 19 additions and 19 deletions

View file

@ -303,12 +303,12 @@ std::shared_ptr<PendingTile> TerrainManager::prepareTile(int x, int y) {
if (!m2Data.empty()) {
pipeline::M2Model m2Model = pipeline::M2Loader::load(m2Data);
// Try to load skin file
// Try to load skin file (only for WotLK M2s - vanilla has embedded skin)
std::string skinPath = m2Path.substr(0, m2Path.size() - 3) + "00.skin";
std::vector<uint8_t> skinData = assetManager->readFile(skinPath);
if (!skinData.empty()) {
if (!skinData.empty() && m2Model.version >= 264) {
pipeline::M2Loader::loadSkin(skinData, m2Model);
} else {
} else if (skinData.empty() && m2Model.version >= 264) {
skippedSkinNotFound++;
LOG_WARNING("M2 skin not found: ", skinPath);
}
@ -447,7 +447,7 @@ std::shared_ptr<PendingTile> TerrainManager::prepareTile(int x, int y) {
pipeline::M2Model m2Model = pipeline::M2Loader::load(m2Data);
std::string skinPath = m2Path.substr(0, m2Path.size() - 3) + "00.skin";
std::vector<uint8_t> skinData = assetManager->readFile(skinPath);
if (!skinData.empty()) {
if (!skinData.empty() && m2Model.version >= 264) {
pipeline::M2Loader::loadSkin(skinData, m2Model);
}
if (!m2Model.isValid()) continue;