From 7951cb1ee0423d491bd0b8fa8c4374bf59ac492e Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 28 Nov 2017 00:06:40 -1000 Subject: [PATCH] Bug fixes --- Runtime/Audio/CSfxManager.cpp | 14 ++++++++++---- Runtime/Camera/CGameCamera.cpp | 5 ++--- Runtime/Character/CGroundMovement.cpp | 10 +++++----- Runtime/Collision/CMaterialList.hpp | 10 +++++----- Runtime/World/CPhysicsActor.cpp | 1 + Runtime/World/CScriptTrigger.cpp | 16 ++++++++-------- Runtime/World/CScriptTrigger.hpp | 4 ++-- Runtime/World/CScriptWater.cpp | 2 +- amuse | 2 +- hecl | 2 +- 10 files changed, 36 insertions(+), 30 deletions(-) diff --git a/Runtime/Audio/CSfxManager.cpp b/Runtime/Audio/CSfxManager.cpp index 9af9496f6..a0365c7f8 100644 --- a/Runtime/Audio/CSfxManager.cpp +++ b/Runtime/Audio/CSfxManager.cpp @@ -177,15 +177,21 @@ u16 CSfxManager::CSfxEmitterWrapper::GetSfxId() const void CSfxManager::CSfxEmitterWrapper::UpdateEmitterSilent() { - x50_emitterHandle->setVectors(x24_parmData.x0_pos.v, x24_parmData.xc_dir.v); - x50_emitterHandle->setMaxVol(1.f / 127.f); + if (x50_emitterHandle) + { + x50_emitterHandle->setVectors(x24_parmData.x0_pos.v, x24_parmData.xc_dir.v); + x50_emitterHandle->setMaxVol(1.f / 127.f); + } x55_cachedMaxVol = x24_parmData.x26_maxVol; } void CSfxManager::CSfxEmitterWrapper::UpdateEmitter() { - x50_emitterHandle->setVectors(x24_parmData.x0_pos.v, x24_parmData.xc_dir.v); - x50_emitterHandle->setMaxVol(x55_cachedMaxVol); + if (x50_emitterHandle) + { + x50_emitterHandle->setVectors(x24_parmData.x0_pos.v, x24_parmData.xc_dir.v); + x50_emitterHandle->setMaxVol(x55_cachedMaxVol); + } } void CSfxManager::CSfxEmitterWrapper::SetReverb(float rev) diff --git a/Runtime/Camera/CGameCamera.cpp b/Runtime/Camera/CGameCamera.cpp index 9fda232c1..e1d73d8c7 100644 --- a/Runtime/Camera/CGameCamera.cpp +++ b/Runtime/Camera/CGameCamera.cpp @@ -79,8 +79,7 @@ zeus::CTransform CGameCamera::ValidateCameraTransform(const zeus::CTransform& a, if ((a.rightVector().magnitude() - 1.f) >= epsilon || (a.frontVector().magnitude() - 1.f) >= epsilon || (a.upVector().magnitude() - 1.f) >= epsilon) xfCpy.orthonormalize(); - float f2 = zeus::CVector3f::skUp.x + a.upVector().x * a.upVector().y * a.upVector().z * - zeus::CVector3f::skUp.y + zeus::CVector3f::skUp.z; + float f2 = a.basis[1].dot(zeus::CVector3f::skUp); if (std::fabs(f2) > 1.0f) f2 = (f2 >= -0.f ? -1.0f : 1.0f); if (std::fabs(f2) > 0.999f) @@ -89,7 +88,7 @@ zeus::CTransform CGameCamera::ValidateCameraTransform(const zeus::CTransform& a, if (xfCpy.upVector().z < -0.2f) xfCpy = zeus::CQuaternion::fromAxisAngle(xfCpy.frontVector(), M_PIF).toTransform() * xfCpy; - if (std::fabs(xfCpy.rightVector().z - 0.f) >= 0.000009f && std::fabs(xfCpy.upVector().z - 0.f) > 0.000009f) + if (std::fabs(xfCpy.rightVector().z) >= 0.000009f && std::fabs(xfCpy.upVector().z) > 0.000009f) { if (xfCpy.frontVector().canBeNormalized()) xfCpy = zeus::lookAt(zeus::CUnitVector3f(xfCpy.frontVector(), true), zeus::CVector3f::skZero); diff --git a/Runtime/Character/CGroundMovement.cpp b/Runtime/Character/CGroundMovement.cpp index 272cf9495..bf89c7c87 100644 --- a/Runtime/Character/CGroundMovement.cpp +++ b/Runtime/Character/CGroundMovement.cpp @@ -594,8 +594,8 @@ void CGroundMovement::MoveGroundCollider_New(CStateManager& mgr, CPhysicsActor& result.x8_collision.emplace(collisionInfo); } - if (!result.x8_collision->IsValid() || - !CGameCollision::CanBlock(result.x8_collision->GetMaterialLeft(), result.x8_collision->GetNormalLeft())) + if (!collisionInfo.IsValid() || + !CGameCollision::CanBlock(collisionInfo.GetMaterialLeft(), collisionInfo.GetNormalLeft())) { if (zOffset > 0.f) { @@ -603,7 +603,7 @@ void CGroundMovement::MoveGroundCollider_New(CStateManager& mgr, CPhysicsActor& xf.origin -= zeus::CVector3f(0.f, 0.f, zOffset); } - if (result.x8_collision->IsValid()) + if (collisionInfo.IsValid()) player.x9c5_28_slidingOnWall = true; CheckFalling(actor, mgr, dt); player.SetLastFloorPlaneNormal({}); @@ -615,8 +615,8 @@ void CGroundMovement::MoveGroundCollider_New(CStateManager& mgr, CPhysicsActor& actor.SetTranslation(actor.GetTranslation() - zeus::CVector3f(0.f, 0.f, stepDown)); if (TCastToPtr plat = mgr.ObjectById(id)) mgr.SendScriptMsg(plat.GetPtr(), actor.GetUniqueId(), EScriptObjectMessage::AddPlatformRider); - CGameCollision::SendMaterialMessage(mgr, result.x8_collision->GetMaterialLeft(), actor); - actor.SetLastFloorPlaneNormal({result.x8_collision->GetNormalLeft()}); + CGameCollision::SendMaterialMessage(mgr, collisionInfo.GetMaterialLeft(), actor); + actor.SetLastFloorPlaneNormal({collisionInfo.GetNormalLeft()}); } } diff --git a/Runtime/Collision/CMaterialList.hpp b/Runtime/Collision/CMaterialList.hpp index bb9b89d95..206373c4d 100644 --- a/Runtime/Collision/CMaterialList.hpp +++ b/Runtime/Collision/CMaterialList.hpp @@ -77,23 +77,23 @@ public: CMaterialList(u64 flags) : x0_list(flags) {} CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5, EMaterialTypes t6) : CMaterialList(t1, t2, t3, t4, t5) - { x0_list = 1ull << u64(t6); } + { x0_list |= 1ull << u64(t6); } CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5) : CMaterialList(t1, t2, t3, t4) - { x0_list = 1ull << u64(t5); } + { x0_list |= 1ull << u64(t5); } CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4) : CMaterialList(t1, t2, t3) - { x0_list = 1ull << u64(t4); } + { x0_list |= 1ull << u64(t4); } CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3) : CMaterialList(t1, t2) - { x0_list = 1ull << u64(t3); } + { x0_list |= 1ull << u64(t3); } CMaterialList(EMaterialTypes t1, EMaterialTypes t2) : CMaterialList(t1) - { x0_list = 1ull << u64(t2); } + { x0_list |= 1ull << u64(t2); } CMaterialList(EMaterialTypes t1) : x0_list(1ull << u64(t1)) diff --git a/Runtime/World/CPhysicsActor.cpp b/Runtime/World/CPhysicsActor.cpp index 6431d9560..7ba600b60 100644 --- a/Runtime/World/CPhysicsActor.cpp +++ b/Runtime/World/CPhysicsActor.cpp @@ -105,6 +105,7 @@ void CPhysicsActor::AddMotionState(const CMotionState& mst) SetTranslation(x34_transform.origin + mst.x0_translation); xfc_constantForce += mst.x1c_velocity; + x108_angularMomentum += mst.x28_angularMomentum; ComputeDerivedQuantities(); } diff --git a/Runtime/World/CScriptTrigger.cpp b/Runtime/World/CScriptTrigger.cpp index 7f2729203..8a4eedec3 100644 --- a/Runtime/World/CScriptTrigger.cpp +++ b/Runtime/World/CScriptTrigger.cpp @@ -184,7 +184,7 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr) } } - if ((x12c_flags & ETriggerFlags::DetectPlayerIfInside) != ETriggerFlags::None || x148_24_playerInside) + if ((x12c_flags & ETriggerFlags::DetectCamera) != ETriggerFlags::None || x148_24_detectCamera) { CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr); bool camInTrigger = GetTriggerBoundsWR().pointInside(cam->GetTranslation()); @@ -193,7 +193,7 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr) if (!camInTrigger) { x148_25_camSubmerged = false; - if ((x12c_flags & ETriggerFlags::DetectPlayerIfInside) != ETriggerFlags::None) + if ((x12c_flags & ETriggerFlags::DetectCamera) != ETriggerFlags::None) { sendExited = true; InhabitantExited(*cam, mgr); @@ -201,7 +201,7 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr) } else { - if ((x12c_flags & ETriggerFlags::DetectPlayerIfInside) != ETriggerFlags::None) + if ((x12c_flags & ETriggerFlags::DetectCamera) != ETriggerFlags::None) { InhabitantIdle(*cam, mgr); sendInside = true; @@ -213,10 +213,10 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr) if (camInTrigger) { x148_25_camSubmerged = true; - if ((x12c_flags & ETriggerFlags::DetectPlayerIfInside) != ETriggerFlags::None) + if ((x12c_flags & ETriggerFlags::DetectCamera) != ETriggerFlags::None) { InhabitantAdded(*cam, mgr); - SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::Activate); + //SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::Activate); } } } @@ -224,12 +224,12 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr) if (sendInside) { - SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::Activate); + //SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::Activate); } if (sendExited) { - SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::Activate); + //SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::Activate); if (x148_27_deactivateOnExited) { mgr.SendScriptMsg(GetUniqueId(), mgr.GetEditorIdForUniqueId(GetUniqueId()), @@ -318,7 +318,7 @@ void CScriptTrigger::Touch(CActor& act, CStateManager& mgr) } } - SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None); + //SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None); if (x148_26_deactivateOnEntered) { diff --git a/Runtime/World/CScriptTrigger.hpp b/Runtime/World/CScriptTrigger.hpp index 03d672fd2..9bd0c57c2 100644 --- a/Runtime/World/CScriptTrigger.hpp +++ b/Runtime/World/CScriptTrigger.hpp @@ -25,7 +25,7 @@ enum class ETriggerFlags : u32 KillOnEnter = (1 << 11), DetectMorphedPlayer = (1 << 12), UseCollisionImpulses = (1 << 13), - DetectPlayerIfInside = (1 << 14), + DetectCamera = (1 << 14), UseBooleanIntersection = (1 << 15), DetectUnmorphedPlayer = (1 << 16), BlockEnvironmentalEffects = (1 << 17) @@ -57,7 +57,7 @@ protected: union { struct { - bool x148_24_playerInside : 1; + bool x148_24_detectCamera : 1; bool x148_25_camSubmerged : 1; bool x148_26_deactivateOnEntered : 1; bool x148_27_deactivateOnExited : 1; diff --git a/Runtime/World/CScriptWater.cpp b/Runtime/World/CScriptWater.cpp index ac7f19376..13363af09 100644 --- a/Runtime/World/CScriptWater.cpp +++ b/Runtime/World/CScriptWater.cpp @@ -86,7 +86,7 @@ CScriptWater::CScriptWater(CStateManager& mgr, TUniqueId uid, std::string_view n x90_actorLights->SetCastShadows(false); x90_actorLights->SetAmbientChannelOverflow(false); x90_actorLights->SetFindNearestDynamicLights(true); - x148_24_playerInside = true; + x148_24_detectCamera = true; CalculateRenderBounds(); xe6_27_renderVisorFlags = u8(thermalCold ? 2 : 1); if (!x30_24_active) diff --git a/amuse b/amuse index b890a76e2..89233e98b 160000 --- a/amuse +++ b/amuse @@ -1 +1 @@ -Subproject commit b890a76e2048ba7ae781af0bfb8fdf2e7ab159f9 +Subproject commit 89233e98b59e6e720641af2f6d5f2d29f9c79864 diff --git a/hecl b/hecl index b8043f636..97c3a4918 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit b8043f6369bd2057112cc77df5d9ad9652995489 +Subproject commit 97c3a4918e32015988328fda625a46e925fa2764