fix: properly load custom models on scene transition (#2779)

* hack that makes it so custom models still work on scene transition

* Update soh/soh/OTRGlobals.cpp

Co-authored-by: Nicholas Estelami <NEstelami@users.noreply.github.com>

* naming/formatting

---------

Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: Nicholas Estelami <NEstelami@users.noreply.github.com>
This commit is contained in:
briaguya 2023-05-03 21:54:23 -04:00 committed by GitHub
parent f81b042843
commit 7d0515c501
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 5 deletions

View File

@ -1,4 +1,4 @@
#include "OTRGlobals.h"
#include "OTRGlobals.h"
#include "OTRAudio.h"
#include <iostream>
#include <algorithm>
@ -1392,9 +1392,26 @@ extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path) {
return (AnimationHeaderCommon*)GetResourceDataByName(path, false);
}
extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime)
{
SkeletonHeader* skelHeader = (SkeletonHeader*)GetResourceDataByName(path, false);
extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime) {
std::string pathStr = std::string(path);
static const std::string sOtr = "__OTR__";
if (pathStr.starts_with(sOtr)) {
pathStr = pathStr.substr(sOtr.length());
}
bool isAlt = CVarGetInteger("gAltAssets", 0);
if (isAlt) {
pathStr = Ship::Resource::gAltAssetPrefix + pathStr;
}
SkeletonHeader* skelHeader = (SkeletonHeader*)GetResourceDataByName(pathStr.c_str(), false);
// If there isn't an alternate model, load the regular one
if (isAlt && skelHeader == NULL) {
skelHeader = (SkeletonHeader*)GetResourceDataByName(path, false);
}
// This function is only called when a skeleton is initialized.
// Therefore we can take this oppurtunity to take note of the Skeleton that is created...
@ -1403,7 +1420,6 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel
Ship::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime);
}
return skelHeader;
}