From 33dbdce2f113ea63162124d1e5eb13c743537f8a Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 6 Feb 2012 18:49:37 -0500 Subject: [PATCH 1/3] Really fix those bizarre panic links Looks like Cyan never actually stopped simulating, so we simulate through adding objects to the scene and positioning them. This is a bad thing(TM), so now we suspend/resume the simulation on plAgeLoadedMsg. --- Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp index e68d1544..b8d89793 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp @@ -56,6 +56,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnSceneObject/plCoordinateInterface.h" #include "pnNetCommon/plSDLTypes.h" #include "plMessage/plCollideMsg.h" +#include "plMessage/plAgeLoadedMsg.h" #include "plModifier/plDetectorLog.h" @@ -358,6 +359,7 @@ void plSimulationMgr::Init() { gTheInstance->RegisterAs(kSimulationMgr_KEY); gTheInstance->GetKey()->RefObject(); + plgDispatch::Dispatch()->RegisterForExactType(plAgeLoadedMsg::Index(), gTheInstance->GetKey()); } else { @@ -377,6 +379,7 @@ void plSimulationMgr::Shutdown() // UnRef to match our Ref in Init(). Unless something strange is // going on, this should destroy the instance and set gTheInstance to nil. // gTheInstance->GetKey()->UnRefObject(); + plgDispatch::Dispatch()->UnRegisterForExactType(plAgeLoadedMsg::Index(), gTheInstance->GetKey()); gTheInstance->UnRegister(); // this will destroy the instance gTheInstance = nil; } @@ -756,6 +759,13 @@ void plSimulationMgr::ISendUpdates() hsBool plSimulationMgr::MsgReceive(plMessage *msg) { + // Suspend/resume the simulation based on whether or not we're in an age... + if (plAgeLoadedMsg* aMsg = plAgeLoadedMsg::ConvertNoRef(msg)) + { + fSuspended = !aMsg->fLoaded; + return true; + } + return hsKeyedObject::MsgReceive(msg); } From 8cbde377efa7e8b4a2159dba28fe107bcb6dbfe0 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 6 Feb 2012 21:17:08 -0500 Subject: [PATCH 2/3] Fix an obvious memory leak. This thing was pissing me off, which made me piss off a lot of other people, which pissed off even more people, so the entire planet got pissed off and nuclear warfare began. So, let's not do stupid crap and piss me off, okay? --- Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp index b8d89793..c4367b3d 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp @@ -358,7 +358,6 @@ void plSimulationMgr::Init() if (gTheInstance->InitSimulation()) { gTheInstance->RegisterAs(kSimulationMgr_KEY); - gTheInstance->GetKey()->RefObject(); plgDispatch::Dispatch()->RegisterForExactType(plAgeLoadedMsg::Index(), gTheInstance->GetKey()); } else @@ -376,11 +375,8 @@ void plSimulationMgr::Shutdown() hsAssert(gTheInstance, "Simulation manager missing during shutdown."); if (gTheInstance) { - // UnRef to match our Ref in Init(). Unless something strange is - // going on, this should destroy the instance and set gTheInstance to nil. -// gTheInstance->GetKey()->UnRefObject(); plgDispatch::Dispatch()->UnRegisterForExactType(plAgeLoadedMsg::Index(), gTheInstance->GetKey()); - gTheInstance->UnRegister(); // this will destroy the instance + gTheInstance->UnRegisterAs(kSimulationMgr_KEY); // this will destroy the instance gTheInstance = nil; } } From 54b5e4cf249949bac65c83673f72df10c1d1007e Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 6 Feb 2012 21:44:13 -0500 Subject: [PATCH 3/3] Fix Gira basket explosions Tweak the GZ marker detector region fix to only wake up kinematic detector regions... waking up regular dynamic actors before we position them causes bad things to happen. --- Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp index 37fb721f..17a95259 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp @@ -827,7 +827,12 @@ void plPXPhysical::ApplyHitForce() void plPXPhysical::ISetTransformGlobal(const hsMatrix44& l2w) { hsAssert(fActor->isDynamic(), "Shouldn't move a static actor"); - fActor->wakeUp(); + + // If we wake up normal dynamic actors, they might explode. + // However, kinematics won't update if they are asleep. Thankfully, kinematics don't + // explode, move, or cause spontaneous nuclear warfare. + if (fActor->readBodyFlag(NX_BF_KINEMATIC)) + fActor->wakeUp(); NxMat34 mat;