From e733ca824ba92070f1f7c1b5288ea7abd1ffdeb9 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 10 Feb 2012 12:45:14 -0500 Subject: [PATCH 1/2] More panic link fixes Now, we check the armature mod to see if we're REALLY linked in (the screen is not black). That way, we can be sure all delayed transforms and false hits (like how we initially spawn into the AhnySphere04 panic region) don't panic link us. --- .../PubUtilLib/plAvatar/plArmatureMod.cpp | 19 ++++++++++++++---- .../PubUtilLib/plAvatar/plArmatureMod.h | 2 ++ .../plPhysical/plCollisionDetector.cpp | 20 ++++++++++--------- .../plPhysical/plCollisionDetector.h | 3 +-- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp index 7d18dcf8..6527f649 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp @@ -650,6 +650,7 @@ void plArmatureMod::IInitDefaults() fStealthLevel = 0; fMouseFrameTurnStrength = 0.f; fSuspendInputCount = 0; + fIsLinkedIn = false; fMidLink = false; fAlreadyPanicLinking = false; fReverseFBOnIdle = false; @@ -1375,16 +1376,21 @@ hsBool plArmatureMod::MsgReceive(plMessage* msg) plLinkInDoneMsg *doneMsg = plLinkInDoneMsg::ConvertNoRef(msg); if (doneMsg) { + fIsLinkedIn = true; IFireBehaviorNotify(plHBehavior::kBehaviorTypeLinkIn, false); return true; } plAgeLoadedMsg *ageLoadMsg = plAgeLoadedMsg::ConvertNoRef(msg); - if (ageLoadMsg && ageLoadMsg->fLoaded) + if (ageLoadMsg) { - // only the local player gets these - NetworkSynch(hsTimer::GetSysSeconds(), true); - EnablePhysics(true); + if (ageLoadMsg->fLoaded) + { + // only the local player gets these + NetworkSynch(hsTimer::GetSysSeconds(), true); + EnablePhysics(true); + } else + fIsLinkedIn = false; return true; } @@ -2518,6 +2524,11 @@ bool plArmatureMod::IsMidLink() return fMidLink; } +bool plArmatureMod::IsLinkedIn() +{ + return fIsLinkedIn; +} + hsBool plArmatureMod::ConsumeJump() { if (!GetInputFlag(B_CONTROL_CONSUMABLE_JUMP)) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h index c89fa1df..997a1343 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h @@ -318,6 +318,7 @@ public: int GetStealthLevel() const { return fStealthLevel; } bool IsOpaque(); + bool IsLinkedIn(); bool IsMidLink(); hsBool ConsumeJump(); // returns true if the jump keypress was available to consume @@ -401,6 +402,7 @@ protected: plArmatureUpdateMsg *fUpdateMsg; // Trying to be a good lad here and align all our bools and bytes... + bool fIsLinkedIn; // We have finished playing the LinkEffects and are properly in the age bool fMidLink; // We're in between a LeaveAge and an EnterAge bool fAlreadyPanicLinking; // Cleared when you enter an age. Prevents spamming the server with panic link requests. bool fUnconsumedJump; // We've pressed the jump key, but haven't jumped yet diff --git a/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.cpp b/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.cpp index b0891d65..3cf4c3b9 100644 --- a/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.cpp @@ -928,9 +928,7 @@ void plSubworldRegionDetector::Write(hsStream* stream, hsResMgr* mgr) /////////////////////////////////// hsBool plPanicLinkRegion::MsgReceive(plMessage* msg) { - plCollideMsg* pCollMsg = plCollideMsg::ConvertNoRef(msg); - - if (pCollMsg) + if (plCollideMsg* pCollMsg = plCollideMsg::ConvertNoRef(msg)) { if (plNetClientApp::GetInstance()->GetLocalPlayerKey() != pCollMsg->fOtherKey) return true; @@ -940,13 +938,17 @@ hsBool plPanicLinkRegion::MsgReceive(plMessage* msg) plArmatureMod* avMod = IGetAvatarModifier(pCollMsg->fOtherKey); if (avMod) { - hsPoint3 kinPos; - if (avMod->GetController()) + if (avMod->IsLinkedIn()) { - avMod->GetController()->GetKinematicPosition(kinPos); - DetectorLogSpecial("Avatar is panic linking. KinPos at %f,%f,%f and is %s",kinPos.fX,kinPos.fY,kinPos.fZ,avMod->GetController()->IsEnabled() ? "enabled" : "disabled"); - } - avMod->PanicLink(fPlayLinkOutAnim); + hsPoint3 kinPos; + if (avMod->GetController()) + { + avMod->GetController()->GetKinematicPosition(kinPos); + DetectorLogSpecial("Avatar is panic linking. KinPos at %f,%f,%f and is %s",kinPos.fX,kinPos.fY,kinPos.fZ,avMod->GetController()->IsEnabled() ? "enabled" : "disabled"); + } + avMod->PanicLink(fPlayLinkOutAnim); + } else + DetectorLogRed("PANIC LINK %s before we actually linked in!", GetKey()->GetName()); } } diff --git a/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.h b/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.h index 519215d3..8333b663 100644 --- a/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.h +++ b/Sources/Plasma/PubUtilLib/plPhysical/plCollisionDetector.h @@ -237,8 +237,7 @@ class plPanicLinkRegion : public plCollisionDetector public: hsBool fPlayLinkOutAnim; - plPanicLinkRegion() : fPlayLinkOutAnim(true) {;} - ~plPanicLinkRegion(){;} + plPanicLinkRegion() : fPlayLinkOutAnim(true) { } virtual hsBool MsgReceive(plMessage* msg); From 8f2d4a67128a814d2e5d9a75f226725875557b4d Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 10 Feb 2012 12:47:35 -0500 Subject: [PATCH 2/2] Revert hacks and do it right. Now that we properly suspend/resume the simulation AND filter out false positives in the PanicLink region, we can use the correct PhysX apis have have regions that work 100% --- .../PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp index 5393a404..1300e7b2 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp @@ -395,7 +395,7 @@ void plPXPhysicalControllerCore::IMatchKinematicToController() kinPos.z = (NxReal)cPos.z; if (plSimulationMgr::fExtraProfile) SimLog("Match setting kinematic from %f,%f,%f to %f,%f,%f",prevKinPos.x,prevKinPos.y,prevKinPos.z,kinPos.x,kinPos.y,kinPos.z ); - if (fBehavingLikeAnimatedPhys && fKinematic) // if NX_BF_KINEMATIC && (avatar is on a ladder or something) + if (fKinematicActor->readBodyFlag(NX_BF_KINEMATIC)) fKinematicActor->moveGlobalPosition(kinPos); else fKinematicActor->setGlobalPosition(kinPos); @@ -409,7 +409,7 @@ void plPXPhysicalControllerCore::UpdateControllerAndPhysicalRep() {//this means we are moving the controller and then synchnig the kin NxExtendedVec3 ControllerPos= fController->getPosition(); NxVec3 NewKinPos((NxReal)ControllerPos.x, (NxReal)ControllerPos.y, (NxReal)ControllerPos.z); - if (fEnabled || fKinematic) + if (fKinematicActor->readBodyFlag(NX_BF_KINEMATIC)) { if (plSimulationMgr::fExtraProfile) SimLog("Moving kinematic to %f,%f,%f",NewKinPos.x, NewKinPos.y, NewKinPos.z ); @@ -449,7 +449,7 @@ void plPXPhysicalControllerCore::MoveKinematicToController(hsPoint3& pos) newPos.x = (NxReal)pos.fX; newPos.y = (NxReal)pos.fY; newPos.z = (NxReal)pos.fZ+kPhysZOffset; - if (fBehavingLikeAnimatedPhys) + if (fKinematicActor->readBodyFlag(NX_BF_KINEMATIC)) { if (plSimulationMgr::fExtraProfile) SimLog("Moving kinematic from %f,%f,%f to %f,%f,%f",pos.fX,pos.fY,pos.fZ+kPhysZOffset,kinPos.x,kinPos.y,kinPos.z ); @@ -491,7 +491,7 @@ void plPXPhysicalControllerCore::ISetKinematicLoc(const hsMatrix44& l2w) // add z offset kPos.fZ += kPhysZOffset; // Update the physical position of kinematic - if (fBehavingLikeAnimatedPhys) + if (fKinematicActor->readBodyFlag(NX_BF_KINEMATIC)) fKinematicActor->moveGlobalPosition(plPXConvert::Point(kPos)); else fKinematicActor->setGlobalPosition(plPXConvert::Point(kPos));