From b5296d614fffb2c777e2141a30d624da0caba0f8 Mon Sep 17 00:00:00 2001 From: Skoader Date: Tue, 23 Oct 2012 13:45:21 +1100 Subject: [PATCH] Fix warping an avatar triggers all detectors along the path When explicitly moving an avatar over the given threshold, teleport the underlying actor most of the way before moving the controller. --- .../plPhysX/plPXPhysicalControllerCore.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp index f6b79f69..a5cd51ae 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysicalControllerCore.cpp @@ -334,6 +334,7 @@ void plPXPhysicalControllerCore::SetGlobalLoc(const hsMatrix44& l2w) fLastGlobalLoc = l2w; // Update our local position and rotation + hsPoint3 prevPosition = fLocalPosition; const plCoordinateInterface* subworldCI = GetSubworldCI(); if (subworldCI) { @@ -360,8 +361,20 @@ void plPXPhysicalControllerCore::SetGlobalLoc(const hsMatrix44& l2w) // Update the physical position if (fKinematicCCT) { - NxExtendedVec3 pos(fLocalPosition.fX, fLocalPosition.fY, fLocalPosition.fZ + kCCTZOffset); - fController->setPosition(pos); + hsVector3 disp(&fLocalPosition, &prevPosition); + if (disp.Magnitude() > 2.f) + { + // Teleport the underlying actor most of the way + disp.Normalize(); + disp *= 0.001f; + + hsPoint3 teleportPos = fLocalPosition - disp; + NxVec3 pos(teleportPos.fX, teleportPos.fY, teleportPos.fZ + kPhysZOffset); + fActor->setGlobalPosition(pos); + } + + NxExtendedVec3 extPos(fLocalPosition.fX, fLocalPosition.fY, fLocalPosition.fZ + kCCTZOffset); + fController->setPosition(extPos); } else {