From 186acae5d8df1111a55002012d1267c9d1853713 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 23 Jun 2018 16:39:53 -1000 Subject: [PATCH] Initial CScriptPlatform collision --- Runtime/Audio/CSfxManager.cpp | 8 +++++--- Runtime/AutoMapper/CAutoMapper.cpp | 14 ++++---------- Runtime/AutoMapper/CAutoMapper.hpp | 8 ++++++++ Runtime/MP1/CFrontEndUI.cpp | 2 +- Runtime/World/CPhysicsActor.cpp | 2 +- Runtime/World/CPhysicsActor.hpp | 2 +- Runtime/World/CScriptPlatform.cpp | 14 ++++++++++++++ Runtime/World/CScriptPlatform.hpp | 2 ++ Runtime/World/CScriptSpawnPoint.cpp | 1 + specter | 2 +- 10 files changed, 38 insertions(+), 17 deletions(-) diff --git a/Runtime/Audio/CSfxManager.cpp b/Runtime/Audio/CSfxManager.cpp index 99df8c5b1..61a2cff92 100644 --- a/Runtime/Audio/CSfxManager.cpp +++ b/Runtime/Audio/CSfxManager.cpp @@ -98,17 +98,19 @@ u16 CSfxManager::CSfxWrapper::GetSfxId() const void CSfxManager::CSfxWrapper::UpdateEmitterSilent() { - x1c_voiceHandle->setVolume(1.f / 127.f); + if (x1c_voiceHandle) + x1c_voiceHandle->setVolume(1.f / 127.f); } void CSfxManager::CSfxWrapper::UpdateEmitter() { - x1c_voiceHandle->setVolume(x20_vol); + if (x1c_voiceHandle) + x1c_voiceHandle->setVolume(x20_vol); } void CSfxManager::CSfxWrapper::SetReverb(float rev) { - if (IsAuxProcessingEnabled() && UseAcoustics()) + if (x1c_voiceHandle && IsAuxProcessingEnabled() && UseAcoustics()) x1c_voiceHandle->setReverbVol(rev); } diff --git a/Runtime/AutoMapper/CAutoMapper.cpp b/Runtime/AutoMapper/CAutoMapper.cpp index 71f920d5c..0f2332338 100644 --- a/Runtime/AutoMapper/CAutoMapper.cpp +++ b/Runtime/AutoMapper/CAutoMapper.cpp @@ -42,8 +42,8 @@ void CAutoMapper::SAutoMapperRenderState::InterpolateWithClamp(const SAutoMapper { float easeB = eases[int(b.x44_viewportEase)]; float easeA = 1.f - easeB; - zeus::CVector2i vpA = a.m_getViewportSize(); - zeus::CVector2i vpB = b.m_getViewportSize(); + zeus::CVector2i vpA = a.GetViewportSize(); + zeus::CVector2i vpB = b.GetViewportSize(); out.x0_viewportSize = zeus::CVector2i(vpB.x * easeB + vpA.x * easeA, vpB.y * easeB + vpA.y * easeA); } @@ -1451,14 +1451,8 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo alphaInterp = 1.f; } - float aspect; - if (xa8_renderStates[0].m_getViewportSize) - { - zeus::CVector2i vp = xa8_renderStates[0].m_getViewportSize(); - aspect = vp.x / float(vp.y); - } - else - aspect = xa8_renderStates[0].x0_viewportSize.x / float(xa8_renderStates[0].x0_viewportSize.y); + zeus::CVector2i vp = xa8_renderStates[0].GetViewportSize(); + float aspect = vp.x / float(vp.y); if (aspect > 1.78f) aspect = 1.78f; float yScale = xa8_renderStates[0].x18_camDist / diff --git a/Runtime/AutoMapper/CAutoMapper.hpp b/Runtime/AutoMapper/CAutoMapper.hpp index dc3f3145c..4a94a4f78 100644 --- a/Runtime/AutoMapper/CAutoMapper.hpp +++ b/Runtime/AutoMapper/CAutoMapper.hpp @@ -85,6 +85,14 @@ public: x54_depth2Ease = Ease::None; x58_alphaEase = Ease::None; } + + zeus::CVector2i GetViewportSize() const + { + if (m_getViewportSize) + return m_getViewportSize(); + else + return x0_viewportSize; + } }; struct SAutoMapperHintStep diff --git a/Runtime/MP1/CFrontEndUI.cpp b/Runtime/MP1/CFrontEndUI.cpp index da57e8e09..e8f4f82f3 100644 --- a/Runtime/MP1/CFrontEndUI.cpp +++ b/Runtime/MP1/CFrontEndUI.cpp @@ -2006,7 +2006,7 @@ CFrontEndUI::CFrontEndUI() m->ResetGameState(); g_GameState->SetCurrentWorldId(g_ResFactory->TranslateOriginalToNew(g_DefaultWorldTag.id)); - g_GameState->CurrentWorldState().SetAreaId(4); + g_GameState->CurrentWorldState().SetAreaId(6); g_GameState->GameOptions().ResetToDefaults(); g_GameState->WriteBackupBuf(); diff --git a/Runtime/World/CPhysicsActor.cpp b/Runtime/World/CPhysicsActor.cpp index c8e533ccd..e86602329 100644 --- a/Runtime/World/CPhysicsActor.cpp +++ b/Runtime/World/CPhysicsActor.cpp @@ -54,7 +54,7 @@ float CPhysicsActor::GetWeight() const { return 24.525002f * xe8_mass; } void CPhysicsActor::SetPrimitiveOffset(const zeus::CVector2f& offset) { x1e8_primitiveOffset = offset; } -zeus::CVector3f CPhysicsActor::GetPrimitiveOffset() { return x1e8_primitiveOffset; } +zeus::CVector3f CPhysicsActor::GetPrimitiveOffset() const { return x1e8_primitiveOffset; } void CPhysicsActor::MoveCollisionPrimitive(const zeus::CVector3f& offset) { x1e8_primitiveOffset = offset; } diff --git a/Runtime/World/CPhysicsActor.hpp b/Runtime/World/CPhysicsActor.hpp index 12fa1b13a..245a93e09 100644 --- a/Runtime/World/CPhysicsActor.hpp +++ b/Runtime/World/CPhysicsActor.hpp @@ -134,7 +134,7 @@ public: float GetMass() const { return xe8_mass; } void SetPrimitiveOffset(const zeus::CVector2f& offset); - zeus::CVector3f GetPrimitiveOffset(); + zeus::CVector3f GetPrimitiveOffset() const; void MoveCollisionPrimitive(const zeus::CVector3f& offset); void SetBoundingBox(const zeus::CAABox& box); zeus::CAABox GetMotionVolume(float dt) const; diff --git a/Runtime/World/CScriptPlatform.cpp b/Runtime/World/CScriptPlatform.cpp index 88ff4bfa9..4e95652ad 100644 --- a/Runtime/World/CScriptPlatform.cpp +++ b/Runtime/World/CScriptPlatform.cpp @@ -196,6 +196,20 @@ std::experimental::optional CScriptPlatform::GetTouchBounds() cons return {CPhysicsActor::GetBoundingBox()}; } +zeus::CTransform CScriptPlatform::GetPrimitiveTransform() const +{ + zeus::CTransform ret = GetTransform(); + ret.origin += GetPrimitiveOffset(); + return ret; +} + +const CCollisionPrimitive* CScriptPlatform::GetCollisionPrimitive() const +{ + if (!x314_treeGroup) + return CPhysicsActor::GetCollisionPrimitive(); + return x314_treeGroup.get(); +} + bool CScriptPlatform::IsRider(TUniqueId id) const { for (const SRiders& rider : x318_riders) diff --git a/Runtime/World/CScriptPlatform.hpp b/Runtime/World/CScriptPlatform.hpp index d2576c5a4..e009d529f 100644 --- a/Runtime/World/CScriptPlatform.hpp +++ b/Runtime/World/CScriptPlatform.hpp @@ -71,6 +71,8 @@ public: void PreThink(float, CStateManager&); void Think(float, CStateManager&); std::experimental::optional GetTouchBounds() const; + zeus::CTransform GetPrimitiveTransform() const; + const CCollisionPrimitive* GetCollisionPrimitive() const; bool IsRider(TUniqueId id) const; bool IsSlave(TUniqueId id) const; std::vector& GetX328() { return x328_slaves1; } diff --git a/Runtime/World/CScriptSpawnPoint.cpp b/Runtime/World/CScriptSpawnPoint.cpp index 62f38c4e1..6c3589daa 100644 --- a/Runtime/World/CScriptSpawnPoint.cpp +++ b/Runtime/World/CScriptSpawnPoint.cpp @@ -17,6 +17,7 @@ CScriptSpawnPoint::CScriptSpawnPoint(TUniqueId uid, std::string_view name, const x64_itemCounts[int(CPlayerState::EItemType::XRayVisor)] = 1; x64_itemCounts[int(CPlayerState::EItemType::GrappleBeam)] = 1; x64_itemCounts[int(CPlayerState::EItemType::BoostBall)] = 1; + x64_itemCounts[int(CPlayerState::EItemType::ChargeBeam)] = 1; x10c_24_firstSpawn = defaultSpawn; x10c_25_morphed = morphed; } diff --git a/specter b/specter index 1b3e19f74..550955b07 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 1b3e19f74ccb55d4c20a8caf2f9c2a4ca06de335 +Subproject commit 550955b07c86724ba27000ed230713f8e4f2f711