Skip to content

Commit

Permalink
Merge pull request HarbourMasters#3487 from HarbourMasters/develop-ma…
Browse files Browse the repository at this point in the history
…cready

develop-macready -> develop
  • Loading branch information
garrettjoecox authored Dec 4, 2023
2 parents 6297df9 + fbc397a commit a8c1888
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 27 deletions.
15 changes: 8 additions & 7 deletions soh/soh/OTRGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ extern "C" void Graph_ProcessFrame(void (*run_one_game_iter)(void)) {
OTRGlobals::Instance->context->GetWindow()->MainLoop(run_one_game_iter);
}

extern bool ShouldClearTextureCacheAtEndOfFrame;
extern bool ToggleAltAssetsAtEndOfFrame;

extern "C" void Graph_StartFrame() {
#ifndef __WIIU__
Expand Down Expand Up @@ -1278,10 +1278,7 @@ extern "C" void Graph_StartFrame() {
}
#endif
case KbScancode::LUS_KB_TAB: {
// Toggle HD Assets
CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0));
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnAssetAltChange>();
ShouldClearTextureCacheAtEndOfFrame = true;
ToggleAltAssetsAtEndOfFrame = true;
break;
}
}
Expand Down Expand Up @@ -1351,10 +1348,14 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
}
}

if (ShouldClearTextureCacheAtEndOfFrame) {
if (ToggleAltAssetsAtEndOfFrame) {
ToggleAltAssetsAtEndOfFrame = false;

// Actually update the CVar now before runing the alt asset update listeners
CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0));
gfx_texture_cache_clear();
LUS::SkeletonPatcher::UpdateSkeletons();
ShouldClearTextureCacheAtEndOfFrame = false;
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnAssetAltChange>();
}

// OTRTODO: FIGURE OUT END FRAME POINT
Expand Down
2 changes: 1 addition & 1 deletion soh/soh/SohGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "Enhancements/game-interactor/GameInteractor.h"
#include "Enhancements/cosmetics/authenticGfxPatches.h"

bool ShouldClearTextureCacheAtEndOfFrame = false;
bool ToggleAltAssetsAtEndOfFrame = false;
bool isBetaQuestEnabled = false;

extern "C" {
Expand Down
8 changes: 5 additions & 3 deletions soh/soh/SohMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "Enhancements/randomizer/randomizer_item_tracker.h"
#include "Enhancements/randomizer/randomizer_settings_window.h"

extern bool ShouldClearTextureCacheAtEndOfFrame;
extern bool ToggleAltAssetsAtEndOfFrame;
extern bool isBetaQuestEnabled;

extern "C" PlayState* gPlayState;
Expand Down Expand Up @@ -919,8 +919,10 @@ void DrawEnhancementsMenu() {
{
if (ImGui::BeginMenu("Mods")) {
if (UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", "gAltAssets", false, false)) {
ShouldClearTextureCacheAtEndOfFrame = true;
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnAssetAltChange>();
// The checkbox will flip the alt asset CVar, but we instead want it to change at the end of the game frame
// We toggle it back while setting the flag to update the CVar later
CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0));
ToggleAltAssetsAtEndOfFrame = true;
}
UIWidgets::Tooltip("Toggle between standard assets and alternate assets. Usually mods will indicate if this setting has to be used or not.");
UIWidgets::PaddedEnhancementCheckbox("Disable Bomb Billboarding", "gDisableBombBillboarding", true, false);
Expand Down
41 changes: 25 additions & 16 deletions soh/soh/resource/importer/SkeletonLimbFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
skeletonLimb->limbData.lodLimb.sibling = skeletonLimb->siblingIndex;

if (skeletonLimb->dListPtr != "") {
auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str());
skeletonLimb->limbData.lodLimb.dLists[0] = (Gfx*)(dList ? dList->GetRawPointer() : nullptr);
skeletonLimb->dListPtr = "__OTR__" + skeletonLimb->dListPtr;
skeletonLimb->limbData.lodLimb.dLists[0] = (Gfx*)skeletonLimb->dListPtr.c_str();
} else {
skeletonLimb->limbData.lodLimb.dLists[0] = nullptr;
}

if (skeletonLimb->dList2Ptr != "") {
auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dList2Ptr.c_str());
skeletonLimb->limbData.lodLimb.dLists[1] = (Gfx*)(dList ? dList->GetRawPointer() : nullptr);
skeletonLimb->dList2Ptr = "__OTR__" + skeletonLimb->dList2Ptr;
skeletonLimb->limbData.lodLimb.dLists[1] = (Gfx*)skeletonLimb->dList2Ptr.c_str();
} else {
skeletonLimb->limbData.lodLimb.dLists[1] = nullptr;
}
Expand All @@ -153,8 +153,8 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
skeletonLimb->limbData.standardLimb.dList = nullptr;

if (!skeletonLimb->dListPtr.empty()) {
const auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str());
skeletonLimb->limbData.standardLimb.dList = (Gfx*)(dList ? dList->GetRawPointer() : nullptr);
skeletonLimb->dListPtr = "__OTR__" + skeletonLimb->dListPtr;
skeletonLimb->limbData.standardLimb.dList = (Gfx*)skeletonLimb->dListPtr.c_str();
}
} else if (skeletonLimb->limbType == LUS::LimbType::Curve) {
skeletonLimb->limbData.skelCurveLimb.firstChildIdx = skeletonLimb->childIndex;
Expand All @@ -163,13 +163,13 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
skeletonLimb->limbData.skelCurveLimb.dList[1] = nullptr;

if (!skeletonLimb->dListPtr.empty()) {
const auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str());
skeletonLimb->limbData.skelCurveLimb.dList[0] = (Gfx*)(dList ? dList->GetRawPointer() : nullptr);
skeletonLimb->dListPtr = "__OTR__" + skeletonLimb->dListPtr;
skeletonLimb->limbData.skelCurveLimb.dList[0] = (Gfx*)skeletonLimb->dListPtr.c_str();
}

if (!skeletonLimb->dList2Ptr.empty()) {
const auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dList2Ptr.c_str());
skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)(dList ? dList->GetRawPointer() : nullptr);
skeletonLimb->dList2Ptr = "__OTR__" + skeletonLimb->dList2Ptr;
skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)skeletonLimb->dList2Ptr.c_str();
}
} else if (skeletonLimb->limbType == LUS::LimbType::Skin) {
skeletonLimb->limbData.skinLimb.jointPos.x = skeletonLimb->transX;
Expand All @@ -189,14 +189,23 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
}

if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_DList) {
auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->skinDList.c_str());
skeletonLimb->limbData.skinLimb.segment = res ? res->GetRawPointer() : nullptr;
if (skeletonLimb->skinDList != "") {
skeletonLimb->skinDList = "__OTR__" + skeletonLimb->skinDList;
skeletonLimb->limbData.skinLimb.segment = (Gfx*)skeletonLimb->skinDList.c_str();
} else {
skeletonLimb->limbData.skinLimb.segment = nullptr;
}
} else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_4) {
skeletonLimb->skinAnimLimbData.totalVtxCount = skeletonLimb->skinVtxCnt;
skeletonLimb->skinAnimLimbData.limbModifCount = skeletonLimb->skinLimbModifCount;
skeletonLimb->skinAnimLimbData.limbModifications = skeletonLimb->skinLimbModifArray.data();
auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->skinDList2.c_str());
skeletonLimb->skinAnimLimbData.dlist = (Gfx*)(res ? res->GetRawPointer() : nullptr);

if (skeletonLimb->skinDList2 != "") {
skeletonLimb->skinDList2 = "__OTR__" + skeletonLimb->skinDList2;
skeletonLimb->skinAnimLimbData.dlist = (Gfx*)skeletonLimb->skinDList2.c_str();
} else {
skeletonLimb->skinAnimLimbData.dlist = nullptr;
}

for (size_t i = 0; i < skeletonLimb->skinLimbModifArray.size(); i++) {
skeletonLimb->skinAnimLimbData.limbModifications[i].vtxCount = skeletonLimb->skinLimbModifVertexArrays[i].size();
Expand Down Expand Up @@ -254,8 +263,8 @@ void SkeletonLimbFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shar
limbData.lodLimb.jointPos.z = skelLimb->transZ;

if (skelLimb->dListPtr != "") {
auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess((const char*)skelLimb->dListPtr.c_str());
limbData.lodLimb.dLists[0] = (Gfx*)(res ? res->GetRawPointer() : nullptr);
skelLimb->dListPtr = "__OTR__" + skelLimb->dListPtr;
limbData.lodLimb.dLists[0] = (Gfx*)skelLimb->dListPtr.c_str();
} else {
limbData.lodLimb.dLists[0] = nullptr;
}
Expand Down

0 comments on commit a8c1888

Please sign in to comment.