From e0e88a88bcf4ac26069b9dd5cd1b15a9bffdf521 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 2 May 2021 18:43:26 -0400 Subject: [PATCH 1/7] Add line break to GITHUB_ENV append --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d11b07796..e2b9ac4a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ string(TIMESTAMP CURRENT_YEAR "%Y") # Add version information to CI environment variables if(DEFINED ENV{GITHUB_ENV}) - file(APPEND "$ENV{GITHUB_ENV}" "METAFORCE_VERSION=${METAFORCE_WC_DESCRIBE}") + file(APPEND "$ENV{GITHUB_ENV}" "METAFORCE_VERSION=${METAFORCE_WC_DESCRIBE}\n") endif() message(STATUS "Metaforce version set to ${METAFORCE_WC_DESCRIBE}") project(metaforce LANGUAGES C CXX ASM VERSION ${METAFORCE_VERSION_STRING}) From 5e0604f10177e991955fa6095ea173cbf3706299 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 6 May 2021 10:51:54 -0700 Subject: [PATCH 2/7] Correct Light radius calculation --- Runtime/Graphics/CLight.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Runtime/Graphics/CLight.cpp b/Runtime/Graphics/CLight.cpp index e56b05498..6ff1c39c6 100644 --- a/Runtime/Graphics/CLight.cpp +++ b/Runtime/Graphics/CLight.cpp @@ -8,19 +8,22 @@ constexpr zeus::CVector3f kDefaultPosition(0.f, 0.f, 0.f); constexpr zeus::CVector3f kDefaultDirection(0.f, -1.f, 0.f); float CLight::CalculateLightRadius() const { - if (x28_distL < FLT_EPSILON && x2c_distQ < FLT_EPSILON) - return FLT_MAX; - - float intens = GetIntensity(); - - if (x2c_distQ > FLT_EPSILON) { - if (intens <= FLT_EPSILON) - return 0.f; - return std::sqrt(intens / (0.0588235f * x2c_distQ)); + if (FLT_EPSILON > x28_distL && FLT_EPSILON > x2c_distQ) { + return 0.f; } - if (x28_distL > FLT_EPSILON) - return intens / (0.0588235f * x28_distL); + float intensity = GetIntensity(); + if (x2c_distQ <= FLT_EPSILON) { + constexpr float mulVal = std::min(0.05882353f, 0.2f); // Yes, retro really did do this + if (x28_distL > FLT_EPSILON) { + return intensity / (mulVal * x28_distL); + } + } else { + constexpr float mulVal = std::min(0.05882353f, 0.2f); // See above comment + if (intensity > FLT_EPSILON) { + return std::sqrt(intensity / (mulVal * x2c_distQ)); + } + } return 0.f; } From 847211f81fd1ccc99ea0722d66213a0440f8e9ea Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 6 May 2021 10:52:35 -0700 Subject: [PATCH 3/7] Remove unnecessary switch from CLight constructor --- Runtime/Graphics/CLight.cpp | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/Runtime/Graphics/CLight.cpp b/Runtime/Graphics/CLight.cpp index 6ff1c39c6..4ebf58ca7 100644 --- a/Runtime/Graphics/CLight.cpp +++ b/Runtime/Graphics/CLight.cpp @@ -62,29 +62,7 @@ CLight::CLight(const zeus::CVector3f& pos, const zeus::CVector3f& dir, const zeu CLight::CLight(ELightType type, const zeus::CVector3f& pos, const zeus::CVector3f& dir, const zeus::CColor& color, float cutoff) -: x0_pos(pos) -, xc_dir(dir) -, x18_color(color) -, x1c_type(type) -, x20_spotCutoff(cutoff) { - switch (type) { - case ELightType::Spot: { - const float cosCutoff = std::cos(zeus::degToRad(cutoff)); - x30_angleC = 0.f; - x34_angleL = -cosCutoff / (1.0f - cosCutoff); - x38_angleQ = 1.f / (1.0f - cosCutoff); - break; - } - case ELightType::Directional: { - x24_distC = 1.f; - x28_distL = 0.f; - x2c_distQ = 0.f; - break; - } - default: - break; - } -} +: x0_pos(pos), xc_dir(dir), x18_color(color), x1c_type(type), x20_spotCutoff(cutoff) {} zeus::CColor CLight::GetNormalIndependentLightingAtPoint(const zeus::CVector3f& point) const { if (x1c_type == ELightType::LocalAmbient) From bd050e8ac0df6b9d676ffb4304b8e1e589e0f528 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 6 May 2021 10:53:19 -0700 Subject: [PATCH 4/7] Start renaming CThardus functions --- Runtime/MP1/World/CThardus.cpp | 39 +++++++++++++++++----------------- Runtime/MP1/World/CThardus.hpp | 10 ++++----- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/Runtime/MP1/World/CThardus.cpp b/Runtime/MP1/World/CThardus.cpp index 2bf1e2167..8c8492d13 100644 --- a/Runtime/MP1/World/CThardus.cpp +++ b/Runtime/MP1/World/CThardus.cpp @@ -129,7 +129,7 @@ CThardus::CThardus(TUniqueId uid, std::string_view name, const CEntityInfo& info SetMass(100000.f); } -void CThardus::sub801dbf34(float dt, CStateManager& mgr) { +void CThardus::UpdateRockThermalState(float dt, CStateManager& mgr) { if (x7c4_ == 0) { x93a_ = false; return; @@ -267,7 +267,7 @@ void CThardus::sub801dcfa4(CStateManager& mgr) { x90c_rockHealths[j] = hInfo->GetHP(); } } else if (!rock->IsUsingPhazonModel()) { - sub801dae2c(mgr, j); + BreakRock(mgr, j); DoFaint(mgr); } else { rock->SetActive(false); @@ -277,7 +277,7 @@ void CThardus::sub801dcfa4(CStateManager& mgr) { DoFlinch(mgr); const bool isThermalActive = mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Thermal; if (isThermalActive || (!isThermalActive && x7c4_ != 3)) { - sub801dc444(mgr, GetTranslation(), x6d8_); + SetRockParticle(mgr, GetTranslation(), x6d8_); } ProcessSoundEvent(x758_, 1.f, 0, 0.1f, 1000.f, 0.16f, 1.f, zeus::skZero3f, GetTranslation(), mgr.GetNextAreaId(), mgr, true); @@ -315,7 +315,7 @@ void CThardus::Think(float dt, CStateManager& mgr) { } } - sub801dbf34(dt, mgr); + UpdateRockThermalState(dt, mgr); if (!sub801dc2c8()) { // NOTE: (phil), yes this is what's actually happening @@ -385,7 +385,8 @@ void CThardus::Think(float dt, CStateManager& mgr) { if (auto* act = static_cast(mgr.ObjectById(x610_destroyableRocks[i]))) { if (!x688_ && !x93c_ && !x909_ && !x93d_) { bool found = act->GetName().find("Neck_1"sv) != std::string::npos; - if (!found || !x6b0_destroyedRocks[x648_currentRock] || x648_currentRock == x610_destroyableRocks.size() - 1) { + if (!found || !x6b0_destroyedRocks[x648_currentRock] || + x648_currentRock == x610_destroyableRocks.size() - 1) { if (!x6b0_destroyedRocks[i]) { if (!found || x6b0_destroyedRocks[i]) { act->RemoveMaterial(EMaterialTypes::Orbit, mgr); @@ -494,7 +495,7 @@ void CThardus::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMa x420_curDamageRemTime = x424_damageWaitTime; } else if (TCastToConstPtr(mgr.GetObjectById(colAct->GetLastTouchedObject()))) { if (x644_ == 1 && x93c_) { - sub801dae2c(mgr, x648_currentRock); + BreakRock(mgr, x648_currentRock); } } } @@ -632,7 +633,7 @@ void CThardus::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMa rock->TakeDamage(zeus::skZero3f, 0.f); const bool thermalInactive = mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Thermal; if (thermalInactive || x7c4_ != 3) { - sub801dc444(mgr, proj->GetTranslation(), x6d0_); + SetRockParticle(mgr, proj->GetTranslation(), x6d0_); } if (!rock->IsUsingPhazonModel()) { ProcessSoundEvent(x75c_, 1.f, 0, 0.1f, 1000.f, 0.16f, 1.f, zeus::skZero3f, rock->GetTranslation(), @@ -806,7 +807,7 @@ void CThardus::PathFind(CStateManager& mgr, EStateMsg msg, float arg) { CPatterned::PathFind(mgr, EStateMsg::Activate, arg); ++x660_; } - x650_ = sub801dc60c(arg, mgr); + x650_ = GetTargetVector(arg, mgr); } else if (msg == EStateMsg::Deactivate) { x8d4_ = false; } @@ -893,7 +894,7 @@ void CThardus::LoopedAttack(CStateManager& mgr, EStateMsg msg, float arg) { offset, zeus::CQuaternion(GetTransform().buildMatrix3f()).toTransform() * zeus::CVector3f{0.f, 1.f, 0.f}, 100.f, CMaterialFilter::MakeInclude({EMaterialTypes::Wall, EMaterialTypes::Floor, EMaterialTypes::Ceiling})); if (result.IsInvalid()) { - zeus::CVector2f vec = sub801dac30(mgr); + zeus::CVector2f vec = GetSteeringVector(mgr); if (vec != zeus::skZero2f) { x650_ = vec; } @@ -907,7 +908,7 @@ void CThardus::LoopedAttack(CStateManager& mgr, EStateMsg msg, float arg) { } } else if (x658_ == 0) { zeus::CVector3f dir = (mgr.GetPlayer().GetTranslation() - GetTranslation()).normalized(); - zeus::CVector2f vec = sub801dac30(mgr); + zeus::CVector2f vec = GetSteeringVector(mgr); if (vec != zeus::skZero2f) { x650_ = vec; } else { @@ -1286,7 +1287,7 @@ void CThardus::FindNonDestroyableActors(const std::unique_ptr rockCol = mgr.ObjectById(x5f0_rockColliders->GetCollisionDescFromIndex(rockIndex).GetCollisionActorId()); if (TCastToPtr rock = mgr.ObjectById(x610_destroyableRocks[rockIndex])) { @@ -1305,7 +1306,7 @@ void CThardus::sub801dae2c(CStateManager& mgr, u32 rockIndex) { light->SetActive(true); if (mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Thermal || (mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Thermal && x7c4_ != 3)) { - sub801dc444(mgr, GetTranslation(), x6d4_); + SetRockParticle(mgr, GetTranslation(), x6d4_); } x90c_rockHealths[rockIndex] = hp; sub801dbc5c(mgr, rock); @@ -1315,7 +1316,7 @@ void CThardus::sub801dae2c(CStateManager& mgr, u32 rockIndex) { } } -void CThardus::sub801dc444(CStateManager& mgr, const zeus::CVector3f& pos, CAssetId particle) { +void CThardus::SetRockParticle(CStateManager& mgr, const zeus::CVector3f& pos, CAssetId particle) { u32 w = x6f4_; ++x6f4_; std::string particleName = fmt::format(FMT_STRING("ROCK_EFFECT{}-{}"), particle.Value(), w); @@ -1445,7 +1446,7 @@ zeus::CVector3f CThardus::sub801de550(CStateManager& mgr) { unkVec.push_back(lastIdx); } - //zeus::CVector2f plVec = mgr.GetPlayer().GetTranslation().toVec2f(); + // zeus::CVector2f plVec = mgr.GetPlayer().GetTranslation().toVec2f(); float maxDist = 0.f; float curDist = 0.f; @@ -1491,7 +1492,7 @@ zeus::CVector3f CThardus::sub801de434(CStateManager& mgr) { ->GetTranslation(); } -zeus::CVector2f CThardus::sub801dac30(CStateManager& mgr) const { +zeus::CVector2f CThardus::GetSteeringVector(CStateManager& mgr) const { zeus::CVector2f ret; zeus::CVector3f pos = GetTranslation(); for (const auto& repulsor : x664_repulsors) { @@ -1506,7 +1507,8 @@ zeus::CVector2f CThardus::sub801dac30(CStateManager& mgr) const { } if (ret != zeus::skZero2f) { - ret = x45c_steeringBehaviors.Arrival2D(*this, x764_startTransform.origin.toVec2f()); + ret = x45c_steeringBehaviors.Arrival2D(*this, x764_startTransform.origin.toVec2f()) * zeus::CVector2f(1.f) + + ret * zeus::CVector2f(0.f); } return ret; } @@ -1548,7 +1550,6 @@ void CThardus::BouncePlayer(float intensity, CStateManager& mgr) { if (intensity <= 0.f) { return; } - zeus::CVector3f posDiff = GetTranslation() - mgr.GetPlayer().GetTranslation(); CPlayer::ESurfaceRestraints restraints = mgr.GetPlayer().GetSurfaceRestraint(); if (restraints != CPlayer::ESurfaceRestraints::Air && !mgr.GetPlayer().IsInWaterMovement()) { @@ -1570,7 +1571,7 @@ void CThardus::sub801dbc40() { x938_ = false; } -zeus::CVector2f CThardus::sub801dc60c(float arg, CStateManager& mgr) { +zeus::CVector2f CThardus::GetTargetVector(float arg, CStateManager& mgr) { zeus::CVector2f ret; if (GetSearchPath() != nullptr) { if (GetSearchPath()->GetResult() == CPathFindSearch::EResult::Success) { @@ -1582,7 +1583,7 @@ zeus::CVector2f CThardus::sub801dc60c(float arg, CStateManager& mgr) { } if (x8d4_ || (!x8d4_ && x7f0_pathFindSearch.OnPath(GetTranslation()) != CPathFindSearch::EResult::Success)) { - zeus::CVector2f vec = sub801dac30(mgr); + zeus::CVector2f vec = GetSteeringVector(mgr); if (vec != zeus::skZero2f) { return vec; } diff --git a/Runtime/MP1/World/CThardus.hpp b/Runtime/MP1/World/CThardus.hpp index e48179da3..c8488f6bf 100644 --- a/Runtime/MP1/World/CThardus.hpp +++ b/Runtime/MP1/World/CThardus.hpp @@ -137,7 +137,7 @@ class CThardus : public CPatterned { void GatherWaypoints(CScriptWaypoint* wp, CStateManager& mgr, rstl::reserved_vector& uids); void sub801dec80() { x68c_ = 20000; } void FindNonDestroyableActors(const std::unique_ptr& colMgr); - void sub801dbf34(float dt, CStateManager& mgr); + void UpdateRockThermalState(float dt, CStateManager& mgr); bool sub801dc2c8() const { return (x610_destroyableRocks.size() - 1) == x648_currentRock; } void sub801de9f8(CStateManager& mgr); void sub801dd608(CStateManager& mgr); @@ -152,9 +152,9 @@ class CThardus : public CPatterned { x944_ = 0.f; } } - void sub801dae2c(CStateManager& mgr, u32 rockIndex); + void BreakRock(CStateManager& mgr, u32 rockIndex); - void sub801dc444(CStateManager& mgr, const zeus::CVector3f& pos, CAssetId particle); + void SetRockParticle(CStateManager& mgr, const zeus::CVector3f& pos, CAssetId particle); void sub801dbc5c(CStateManager& mgr, CDestroyableRock* rock); void sub801dbbdc(CStateManager& mgr, CDestroyableRock* rock); bool sub801dc2c8() { return x648_currentRock == (x610_destroyableRocks.size() - 1); } @@ -168,7 +168,7 @@ class CThardus : public CPatterned { void RenderFlare(const CStateManager& mgr, float t); zeus::CVector3f sub801de550(CStateManager& mgr); zeus::CVector3f sub801de434(CStateManager& mgr); - zeus::CVector2f sub801dc60c(float f1, CStateManager& mgr); + zeus::CVector2f GetTargetVector(float arg, CStateManager& mgr); void sub801dbc40(); std::optional m_flareFilter; @@ -185,7 +185,7 @@ class CThardus : public CPatterned { void _DoSuckState(CStateManager& mgr) { x330_stateMachineState.SetState(mgr, *this, GetStateMachine(), "Suck"sv); } - zeus::CVector2f sub801dac30(CStateManager& mgr) const; + zeus::CVector2f GetSteeringVector(CStateManager& mgr) const; void UpdateHealthInfo(CStateManager& mgr); void BouncePlayer(float f1, CStateManager& mgr); From a3628bebff59510d5d9140c631bf3129fe46ed4b Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 6 May 2021 11:27:29 -0700 Subject: [PATCH 5/7] CElementGen: Disable RecreatePipelines logic for the time being --- Runtime/Particle/CElementGen.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index 66840121a..64a0ed9c0 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -227,6 +227,7 @@ CElementGen::~CElementGen() { bool CElementGen::Update(double t) { s32 oldMax = x90_MAXP; + s32 oldMBSP = x270_MBSP; CParticleGlobals::SParticleSystem* prevSystem = CParticleGlobals::instance()->m_currentParticleSystem; CParticleGlobals::SParticleSystem thisSystem{FOURCC('PART'), this}; CParticleGlobals::instance()->m_currentParticleSystem = &thisSystem; @@ -242,13 +243,14 @@ bool CElementGen::Update(double t) { bool ret = InternalUpdate(t); CParticleGlobals::instance()->m_currentParticleSystem = prevSystem; - if (oldMax < x90_MAXP) { - _RecreatePipelines(); + if (oldMax < x90_MAXP || oldMBSP < x270_MBSP) { + //_RecreatePipelines(); } return ret; } + void CElementGen::_RecreatePipelines() { - size_t maxInsts = x26c_30_MBLR ? (x270_MBSP * x90_MAXP) : x90_MAXP; + size_t maxInsts = x26c_30_MBLR ? 2560 * 2 : 2560;//x26c_30_MBLR ? (x270_MBSP * x90_MAXP) : x90_MAXP; maxInsts = (maxInsts == 0 ? 256 : maxInsts); CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) { From 5918daf818cf6ad1472e8d36770f88c1af0c6e2a Mon Sep 17 00:00:00 2001 From: Luke Street Date: Thu, 6 May 2021 14:35:02 -0400 Subject: [PATCH 6/7] CElementGen: Add activeParticleCount sanity check --- Runtime/Particle/CElementGen.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index 64a0ed9c0..beb6f1dae 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -358,6 +358,11 @@ void CElementGen::AccumulateBounds(const zeus::CVector3f& pos, float size) { void CElementGen::UpdateAdvanceAccessParameters(u32 activeParticleCount, s32 particleFrame) { CGenDescription* desc = x28_loadedGenDesc; + if (activeParticleCount >= x60_advValues.size()) { + Log.report(logvisor::Fatal, FMT_STRING("activeParticleCount ({}) >= advValues size ({})"), + activeParticleCount, x60_advValues.size()); + } + std::array& arr = x60_advValues[activeParticleCount]; CParticleGlobals::instance()->m_particleAccessParameters = &arr; From 2012a7a713e0b3c1db20a6b88ef3f5201c47e97c Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 7 May 2021 00:11:08 -0700 Subject: [PATCH 7/7] Change mac bundle id --- ci/build-dmg.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build-dmg.sh b/ci/build-dmg.sh index 864f29428..1da19d33c 100755 --- a/ci/build-dmg.sh +++ b/ci/build-dmg.sh @@ -7,5 +7,5 @@ for i in visigen hecl metaforce crashpad_handler; do done macdeployqt Metaforce.app -sign-for-notarization="$CODESIGN_IDENT" -no-strip create-dmg Metaforce.app --identity="$CODESIGN_IDENT" "$GITHUB_WORKSPACE" -xcrun altool -t osx -f "$GITHUB_WORKSPACE"/*.dmg --primary-bundle-id com.axiodl.URDE --notarize-app \ +xcrun altool -t osx -f "$GITHUB_WORKSPACE"/*.dmg --primary-bundle-id com.axiodl.Metaforce --notarize-app \ -u "$ASC_USERNAME" -p "$ASC_PASSWORD" --team-id "$ASC_TEAM_ID" \ No newline at end of file