Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly load custom models on scene transition #2779

Merged

Conversation

briaguya-ai
Copy link
Contributor

@briaguya-ai briaguya-ai commented Apr 29, 2023

this feels like a bad way to fix #2778 but it works
edit: as of 8e15348 i feel this is a good short/medium term solution. long term we should dig into where the logic in this PR should live #2779 (review)

i figure if nothing else it might be helpful when trying to come up with a fix we actually like

out.mp4

Build Artifacts

@briaguya-ai briaguya-ai added the do not merge Not ready or not valid changes label Apr 29, 2023
@NEstelami
Copy link
Contributor

When the skeleton is being loaded by the game it's always loading the vanilla one because it's not checking if we're in HD mode.

To properly fix the issue, ResourceMgr_LoadSkeletonByName needs to be updated to:

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 isHD = CVarGetInteger("gAltAssets", 0);

    if (isHD)
        pathStr = Ship::Resource::gAltAssetPrefix + pathStr;

    SkeletonHeader* skelHeader = (SkeletonHeader*)GetResourceDataByName(pathStr.c_str(), false);

    // If there isn't an HD model, load the regular one
    if (isHD && 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...
    if (skelAnime != nullptr) {
        auto stringPath = std::string(path);
        Ship::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime);
    }


    return skelHeader;
}

soh/soh/OTRGlobals.cpp Outdated Show resolved Hide resolved
Co-authored-by: Nicholas Estelami <NEstelami@users.noreply.github.com>
@briaguya-ai briaguya-ai changed the title hack that makes it so custom models still work on scene transition fix: properly load custom models on scene transition Apr 29, 2023
@briaguya-ai briaguya-ai removed the do not merge Not ready or not valid changes label Apr 29, 2023
Copy link
Contributor Author

@briaguya-ai briaguya-ai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably do a bit more investigation and make it so we don't need this checking code on the SoH side of things at some point, but for now this is minimally invasive and fixes the issue so I say let's :shipit:

Copy link
Contributor

@leggettc18 leggettc18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed working with a few scene transitions and the tplink model

@leggettc18 leggettc18 merged commit 7d0515c into HarbourMasters:develop-spock May 4, 2023
7 checks passed
@briaguya-ai briaguya-ai deleted the fix-skeleton-unloading branch May 4, 2023 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants