From 24a644107e3cfbc40ccefef0820fdda4bb3c7a24 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 25 Feb 2012 01:55:55 -0500 Subject: [PATCH] Fix relto-plunge Looks like the fissure fall camera region got triggered then untriggered during the linking process. In debug builds, this happened in one frame, so only an exit message got sent out. In faster builds, both would be sent, and you would plunge. To fix that, we don't send eval until we're no longer MidLink. --- .../plPhysical/plCollisionDetector.cpp | 23 +++++++++++++++---- .../plPhysical/plCollisionDetector.h | 8 +++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.cpp b/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.cpp index 57a3648d..cf03b0b9 100644 --- a/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.cpp @@ -73,6 +73,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com plArmatureMod* plCollisionDetector::IGetAvatarModifier(plKey key) { + if (!key) + return nil; + plSceneObject* avObj = plSceneObject::ConvertNoRef(key->ObjectIsLoaded()); if (avObj) { @@ -242,8 +245,6 @@ plCameraRegionDetector::~plCameraRegionDetector() void plCameraRegionDetector::ITrigger(plKey hitter, bool entering, bool immediate) { - if (fSavingSendMsg) - DetectorLogRed("%s: Stale messages on ITrigger. This should never happen!", GetKeyName().c_str()); if (fIsInside && entering) DetectorLogRed("%s: Duplicate enter! Did we miss an exit?", GetKeyName().c_str()); else if (!fIsInside && !entering) @@ -384,11 +385,18 @@ hsBool plObjectInVolumeDetector::MsgReceive(plMessage* msg) plCollideMsg* pCollMsg = plCollideMsg::ConvertNoRef(msg); if (pCollMsg) { + fLastHitter = pCollMsg->fOtherKey; // If the avatar is disabled (flying around), don't trigger - if (IIsDisabledAvatar(pCollMsg->fOtherKey)) + if (IIsDisabledAvatar(fLastHitter)) return false; - ITrigger(pCollMsg->fOtherKey, (pCollMsg->fEntering != 0)); - plgDispatch::Dispatch()->RegisterForExactType(plEvalMsg::Index(), GetKey()); + ITrigger(fLastHitter, (pCollMsg->fEntering != 0)); + + // If we never eval before the exit... + if (fWaitingForEval) + plgDispatch::Dispatch()->UnRegisterForExactType(plEvalMsg::Index(), GetKey()); + else + plgDispatch::Dispatch()->RegisterForExactType(plEvalMsg::Index(), GetKey()); + fWaitingForEval = !fWaitingForEval; return true; } @@ -396,8 +404,13 @@ hsBool plObjectInVolumeDetector::MsgReceive(plMessage* msg) if (pEvalMsg) { fNumEvals++; + // Don't dispatch if we're not in the age + if (plArmatureMod* av = IGetAvatarModifier(fLastHitter)) + if (av->IsMidLink()) + return true; ISendSavedTriggerMsgs(); plgDispatch::Dispatch()->UnRegisterForExactType(plEvalMsg::Index(), GetKey()); + fWaitingForEval = false; } plPlayerPageMsg* pageMsg = plPlayerPageMsg::ConvertNoRef(msg); diff --git a/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.h b/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.h index f2fa65ea..623b716a 100644 --- a/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.h +++ b/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.h @@ -99,15 +99,19 @@ protected: uint32_t fNumEvals; uint32_t fLastEnterEval; uint32_t fLastExitEval; + bool fWaitingForEval; + plKey fLastHitter; public: plObjectInVolumeDetector() - : plCollisionDetector(), fSavedActivatorMsg(nil), fNumEvals(0), fLastEnterEval(0), fLastExitEval(0) + : plCollisionDetector(), fSavedActivatorMsg(nil), fNumEvals(0), fLastEnterEval(0), + fWaitingForEval(false), fLastHitter(nil) { } plObjectInVolumeDetector(int8_t type) - : plCollisionDetector(type), fSavedActivatorMsg(nil), fNumEvals(0), fLastEnterEval(0), fLastExitEval(0) + : plCollisionDetector(type), fSavedActivatorMsg(nil), fNumEvals(0), fLastEnterEval(0), + fWaitingForEval(false), fLastHitter(nil) { } virtual ~plObjectInVolumeDetector() { }