diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index 397031000..cf25985ec 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -4,7 +4,7 @@ #define MP1_USE_BOO 0 #endif #ifndef MP1_VARIABLE_DELTA_TIME -#define MP1_VARIABLE_DELTA_TIME 0 +#define MP1_VARIABLE_DELTA_TIME 1 #endif #include "IMain.hpp" diff --git a/Runtime/MP1/World/CPuffer.cpp b/Runtime/MP1/World/CPuffer.cpp index e45164bff..9ee687305 100644 --- a/Runtime/MP1/World/CPuffer.cpp +++ b/Runtime/MP1/World/CPuffer.cpp @@ -31,6 +31,7 @@ CPuffer::CPuffer(TUniqueId uid, std::string_view name, const CEntityInfo& info, CreateShadow(false); x460_knockBackController.SetImpulseDurationIdx(1); x574_cloudEffect.Lock(); + x450_bodyController->SetRestrictedFlyerMoveSpeed(hoverSpeed); } void CPuffer::Accept(IVisitor& visitor) { visitor.Visit(this); } @@ -65,8 +66,7 @@ void CPuffer::Think(float dt, CStateManager& mgr) { x450_bodyController->GetCommandMgr().ClearLocomotionCmds(); if (moveVector.canBeNormalized()) { - //zeus::CVector3f vec = x5c0_move * (1.f - (dt / 0.5f)) + (moveVector * (dt / 0.5f)); - x5c0_move = moveVector.normalized(); + x5c0_move = (x5c0_move * (1.f - (dt / 0.5f)) + (moveVector * (dt / 0.5f))).normalized(); x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(x5c0_move, x568_face, 1.f)); } } @@ -114,9 +114,29 @@ void CPuffer::sub8025bfa4(CStateManager& mgr) { if (x5d4_gasLocators.empty()) { for (u32 i = 0; i < 14; ++i) - x5d4_gasLocators.push_back(GetScaledLocatorTransform(GasLocators[i]).frontVector()); + x5d4_gasLocators.push_back(GetScaledLocatorTransform(GasLocators[i]).basis[1]); } - if (moveVector.canBeNormalized()) {} + if (moveVector.canBeNormalized()) { + zeus::CVector3f moveNorm = -moveVector.normalized(); + for (u32 i = 0; i < 14; ++i) { + zeus::CVector3f tmp = GetTransform().rotate(x5d4_gasLocators[i]); + bool enable = std::cos(zeus::degToRad(45.f)) < moveNorm.dot(tmp); + printf("%s -> %i\n", GesJetLocators[i], enable); + if ((x5d0_enabledParticles & (1 << i)) != enable) { + GetModelData()->GetAnimationData()->SetParticleEffectState(GesJetLocators[i], enable, mgr); + } + if (enable) + x5d0_enabledParticles |= (1 << i); + else + x5d0_enabledParticles &= ~(1 << i); + } + } else { + for (u32 i = 0; i < 14; ++i) { + if ((x5d0_enabledParticles & (1 << i))) + GetModelData()->GetAnimationData()->SetParticleEffectState(GesJetLocators[i], false, mgr); + } + x5d0_enabledParticles = 0; + } } } // namespace urde::MP1 diff --git a/Runtime/MP1/World/CPuffer.hpp b/Runtime/MP1/World/CPuffer.hpp index 533fa3e81..1dfdfad21 100644 --- a/Runtime/MP1/World/CPuffer.hpp +++ b/Runtime/MP1/World/CPuffer.hpp @@ -21,7 +21,7 @@ class CPuffer : public CPatterned { CAssetId x5bc_cloudSteam; zeus::CVector3f x5c0_move; TUniqueId x5cc_ = kInvalidUniqueId; - s32 x5d0_ = 0; + s32 x5d0_enabledParticles = 0; rstl::reserved_vector x5d4_gasLocators; void sub8025bfa4(CStateManager&); diff --git a/Runtime/World/CScriptPlayerActor.cpp b/Runtime/World/CScriptPlayerActor.cpp index 8257f1dc1..21712affb 100644 --- a/Runtime/World/CScriptPlayerActor.cpp +++ b/Runtime/World/CScriptPlayerActor.cpp @@ -378,7 +378,7 @@ void CScriptPlayerActor::Render(const CStateManager& mgr) const { CBooModel::SetReflectionCube(m_reflectionCube); bool phazonSuit = x2e8_suitRes.GetCharacterNodeId() == 3; - if (phazonSuit && false) { + if (phazonSuit) { // Draw into alpha buffer CModelFlags flags = xb4_drawFlags; flags.x4_color = zeus::skWhite; @@ -399,7 +399,7 @@ void CScriptPlayerActor::Render(const CStateManager& mgr) const { x314_beamModelData->Render(mgr, modelXf, x90_actorLights.get(), flags); } - if (phazonSuit && false) { + if (phazonSuit) { zeus::CVector3f vecFromCam = GetBoundingBox().center() - mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTranslation(); float radius = zeus::clamp(0.25f, (6.f - vecFromCam.magnitude()) / 6.f, 2.f); diff --git a/Runtime/World/CVisorFlare.cpp b/Runtime/World/CVisorFlare.cpp index 115d2d5be..bcb2c4da6 100644 --- a/Runtime/World/CVisorFlare.cpp +++ b/Runtime/World/CVisorFlare.cpp @@ -1,21 +1,25 @@ #include "Runtime/World/CVisorFlare.hpp" -#include "Runtime/CSimplePool.hpp" +#include "Runtime/Camera/CCameraManager.hpp" +#include "Runtime/Camera/CGameCamera.hpp" +#include "Runtime/World/CPlayer.hpp" #include "Runtime/GameGlobalObjects.hpp" +#include "Runtime/CStateManager.hpp" +#include "Runtime/CSimplePool.hpp" namespace urde { std::optional CVisorFlare::LoadFlareDef(CInputStream& in) { u32 propCount = in.readUint32Big(); if (propCount != 4) - return {}; + return std::nullopt; CAssetId txtrId = in.readUint32Big(); float f1 = in.readFloatBig(); float f2 = in.readFloatBig(); zeus::CColor color = zeus::CColor::ReadRGBABig(in); if (!txtrId.IsValid()) - return {}; + return std::nullopt; TToken tex = g_SimplePool->GetObj(SObjectTag{FOURCC('TXTR'), txtrId}); @@ -27,14 +31,67 @@ CVisorFlare::CVisorFlare(EBlendMode blendMode, bool b1, float f1, float f2, floa : x0_blendMode(blendMode) , x4_flareDefs(flares) , x14_b1(b1) -, x18_f1(std::max(f1, 0.0001f)) +, x18_f1(std::max(f1, FLT_EPSILON)) , x1c_f2(f2) , x20_f3(f3) , x2c_w1(w1) , x30_w2(w2) {} -void CVisorFlare::Update(float dt, const zeus::CVector3f& pos, const CActor* act, CStateManager& mgr) {} +void CVisorFlare::Update(float dt, const zeus::CVector3f& pos, const CActor* act, CStateManager& mgr) { + const CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetCurrentVisor(); -void CVisorFlare::Render(const zeus::CVector3f& pos, const CStateManager& mgr) const {} + if ((visor == CPlayerState::EPlayerVisor::Combat || (x2c_w1 != 1 && visor == CPlayerState::EPlayerVisor::Thermal)) && + mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed) { + + zeus::CVector3f camPos = mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTranslation(); + zeus::CVector3f camDiff = pos - camPos; + const float mag = (camDiff.magnitude()); + rstl::reserved_vector near; + mgr.BuildNearList(near, camPos, camDiff * (1.f / mag), mag, + CMaterialFilter::MakeInclude({EMaterialTypes::Occluder}), act); + TUniqueId id; + CRayCastResult result = mgr.RayWorldIntersection( + id, camPos, camDiff, mag, + CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::SeeThrough}), near); + + if (result.IsValid()) { + x28_ -= mag; + } else { + x28_ += mag; + } + x28_ = zeus::clamp(0.f, x28_, x18_f1); + x24_ = 1.f - (x28_ / x18_f1); + + const CGameCamera* curCam = mgr.GetCameraManager()->GetCurrentCamera(mgr); + x24_ *= std::max(0.f, 1.f - (4.f * x1c_f2 * (1.f - (pos - curCam->GetTranslation()).dot(curCam->GetTransform().basis[1])))); + + if (x2c_w1 == 2) { + mgr.SetThermalColdScale2(mgr.GetThermalColdScale2() + x24_); + } + + printf("%08X %f %f\n", act->GetEditorId().id, x24_, x28_); + } +} + +void CVisorFlare::Render(const zeus::CVector3f& pos, const CStateManager& mgr) const { + if (zeus::close_enough(x28_, x18_f1) && + mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed) { + int iVar; + const auto visor = mgr.GetPlayerState()->GetActiveVisor(mgr); + if (visor == CPlayerState::EPlayerVisor::Thermal) { + iVar = x2c_w1; + } else if (visor == CPlayerState::EPlayerVisor::XRay) { + return; + } else { + iVar = x30_w2; + } + if (iVar != 0) + return; + CGraphics::DisableAllLights(); + // g_Renderer->SetDepthReadWrite(false, false); + //const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr); + //zeus::CVector3f camPos = cam->GetTranslation(); + } +} } // namespace urde diff --git a/Runtime/World/CVisorFlare.hpp b/Runtime/World/CVisorFlare.hpp index 0f2fecc67..ff70aff6e 100644 --- a/Runtime/World/CVisorFlare.hpp +++ b/Runtime/World/CVisorFlare.hpp @@ -30,7 +30,7 @@ public: x0_tex.Lock(); } - TToken GetTexture() const; + TToken GetTexture() const { return x0_tex; } zeus::CColor GetColor() const { return x10_color; } float GetScale() const; float GetPosition() const; diff --git a/hecl b/hecl index 57bfd8cb3..1f18d2503 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 57bfd8cb3fefb3e57caddef46b636d762ec642a1 +Subproject commit 1f18d2503af136d68fa64c06f3a8fae473315695 diff --git a/specter b/specter index 2a50903a4..1c2c58f29 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 2a50903a4130d415aa3f8f4f8e53c3d72c398c08 +Subproject commit 1c2c58f296a54c085854785d73c1ebdd548c5dca