Skip to content

Conversation

@briaguya0
Copy link
Contributor

@briaguya0 briaguya0 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

@briaguya0 briaguya0 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;
}

Co-authored-by: Nicholas Estelami <[email protected]>
@briaguya0 briaguya0 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
@briaguya0 briaguya0 removed the do not merge Not ready or not valid changes label Apr 29, 2023
Copy link
Contributor Author

@briaguya0 briaguya0 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
@briaguya0 briaguya0 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.

3 participants