mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 10:52:46 +00:00
Updated plPXPhysicalControllerCore to match 69377bc74f2e
While based heavily on the old implementation, this is essentially a rewrite. Notable changes - Controllers are now updated at the same fixed frequency as the simulation. Resulting output is interpolated between steps to precisely match the frame delta. Physics work is only done when enough time has passed to perform a step. The kinematic actor that followed around the controller has been removed. The underlying kinematic actor created by the NxController is now used for triggering. A new sim group was added for a kinematically controlled avatar. 2 unused files removed - plPXPhysicalController.h & plPXPhysicalController.cpp
This commit is contained in:
@ -94,8 +94,7 @@ private:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool isController;
|
plPXPhysicalControllerCore* controller = plPXPhysicalControllerCore::GetController(hitActor);
|
||||||
plPXPhysicalControllerCore* controller = plPXPhysicalControllerCore::GetController(hitActor,&isController);
|
|
||||||
if (controller)
|
if (controller)
|
||||||
{
|
{
|
||||||
objKey = controller->GetOwner();
|
objKey = controller->GetOwner();
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,211 +0,0 @@
|
|||||||
/*==LICENSE==*
|
|
||||||
|
|
||||||
CyanWorlds.com Engine - MMOG client, server and tools
|
|
||||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Additional permissions under GNU GPL version 3 section 7
|
|
||||||
|
|
||||||
If you modify this Program, or any covered work, by linking or
|
|
||||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
|
||||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
|
||||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
|
||||||
(or a modified version of those libraries),
|
|
||||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
|
||||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
|
||||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
|
||||||
licensors of this Program grant you additional
|
|
||||||
permission to convey the resulting work. Corresponding Source for a
|
|
||||||
non-source form of such a combination shall include the source code for
|
|
||||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
|
||||||
work.
|
|
||||||
|
|
||||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|
||||||
or by snail mail at:
|
|
||||||
Cyan Worlds, Inc.
|
|
||||||
14617 N Newport Hwy
|
|
||||||
Mead, WA 99021
|
|
||||||
|
|
||||||
*==LICENSE==*/
|
|
||||||
#ifndef plPXPhysicalController_h_inc
|
|
||||||
#define plPXPhysicalController_h_inc
|
|
||||||
|
|
||||||
#include "../plAvatar/plAvCallbackAction.h"
|
|
||||||
#include "hsQuat.h"
|
|
||||||
|
|
||||||
#define PHYSX_ONLY_TRIGGER_FROM_KINEMATIC 1
|
|
||||||
|
|
||||||
class NxController;
|
|
||||||
class NxCapsuleController;
|
|
||||||
class NxActor;
|
|
||||||
class plCoordinateInterface;
|
|
||||||
class plPhysicalProxy;
|
|
||||||
class plDrawableSpans;
|
|
||||||
class hsGMaterial;
|
|
||||||
class NxCapsule;
|
|
||||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
|
||||||
class plDbgCollisionInfo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
plSceneObject *fSO;
|
|
||||||
hsVector3 fNormal;
|
|
||||||
hsBool fOverlap;
|
|
||||||
};
|
|
||||||
#endif // PLASMA_EXTERNAL_RELEASE
|
|
||||||
|
|
||||||
class plPXPhysicalController : public plPhysicalController
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
plPXPhysicalController(plKey ownerSO, hsScalar height, hsScalar radius);
|
|
||||||
virtual ~plPXPhysicalController();
|
|
||||||
|
|
||||||
virtual void Enable(bool enable);
|
|
||||||
virtual bool IsEnabled() const { return fEnable; }
|
|
||||||
|
|
||||||
virtual void SetLOSDB(plSimDefs::plLOSDB losDB) { fLOSDB = losDB; }
|
|
||||||
plSimDefs::plLOSDB GetLOSDB() const { return fLOSDB; }
|
|
||||||
|
|
||||||
virtual void SetVelocities(const hsVector3& linearVel, hsScalar angVel)
|
|
||||||
{
|
|
||||||
fLinearVelocity = linearVel;
|
|
||||||
fAngularVelocity = angVel;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual const hsVector3& GetLinearVelocity() const { return fAchievedLinearVelocity; }
|
|
||||||
virtual void ResetAchievedLinearVelocity() { fAchievedLinearVelocity.Set(0.f, 0.f, 0.f); }
|
|
||||||
|
|
||||||
virtual plKey GetSubworld() const { return fWorldKey; }
|
|
||||||
virtual void SetSubworld(plKey world);
|
|
||||||
|
|
||||||
virtual bool IsOnGround() const { return fTimeInAir < kAirTimeThreshold || fFalseGround; }
|
|
||||||
virtual bool IsOnFalseGround() const { return fFalseGround && !fGroundHit; }
|
|
||||||
virtual void GroundHit() { fGroundHit = true; }
|
|
||||||
virtual hsScalar GetAirTime() const { return fTimeInAir; }
|
|
||||||
virtual void ResetAirTime() { fTimeInAir = 0.f; }
|
|
||||||
virtual void AddSlidingNormal(hsVector3 vec);
|
|
||||||
virtual hsTArray<hsVector3>* GetSlidingNormals() { return &fSlidingNormals; }
|
|
||||||
|
|
||||||
virtual plPhysical* GetPushingPhysical() const { return fPushingPhysical; }
|
|
||||||
virtual bool GetFacingPushingPhysical() const { return fFacingPushingPhysical; }
|
|
||||||
|
|
||||||
virtual const plCoordinateInterface* GetSubworldCI() const;
|
|
||||||
|
|
||||||
virtual void GetState(hsPoint3& pos, float& zRot);
|
|
||||||
virtual void SetState(const hsPoint3& pos, float zRot);
|
|
||||||
|
|
||||||
plKey GetOwner() const { return fOwner; }
|
|
||||||
|
|
||||||
// Called by the simulation mgr each frame
|
|
||||||
static void Update(bool prestep, hsScalar delSecs);
|
|
||||||
// Used by the LOS mgr to find the controller for an actor it hit
|
|
||||||
static plPXPhysicalController* GetController(NxActor& actor, bool* isController);
|
|
||||||
// test to see if there are any controllers (i.e. avatars) in this subworld
|
|
||||||
static bool plPXPhysicalController::AnyControllersInThisWorld(plKey world);
|
|
||||||
static int plPXPhysicalController::NumControllers();
|
|
||||||
static int plPXPhysicalController::GetControllersInThisSubWorld(plKey world, int maxToReturn,
|
|
||||||
plPXPhysicalController** bufferout);
|
|
||||||
static int plPXPhysicalController::GetNumberOfControllersInThisSubWorld(plKey world);
|
|
||||||
// Call this if a static physical in the scene has changed (unloaded,
|
|
||||||
// collision enabled/disabled, etc)
|
|
||||||
static void RebuildCache();
|
|
||||||
|
|
||||||
virtual void GetPositionSim(hsPoint3& pos) const { IGetPositionSim(pos); }
|
|
||||||
|
|
||||||
virtual void Kinematic(bool state);
|
|
||||||
virtual bool IsKinematic();
|
|
||||||
virtual void GetKinematicPosition(hsPoint3& pos);
|
|
||||||
|
|
||||||
virtual plDrawableSpans* CreateProxy(hsGMaterial* mat, hsTArray<UInt32>& idx, plDrawableSpans* addTo);
|
|
||||||
|
|
||||||
virtual const hsMatrix44& GetPrevSubworldW2L() { return fPrevSubworldW2L; }
|
|
||||||
|
|
||||||
virtual void SetSeek(bool seek){fSeeking=seek;}
|
|
||||||
virtual void GetWorldSpaceCapsule(NxCapsule& cap);
|
|
||||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
|
||||||
static hsBool fDebugDisplay;
|
|
||||||
#endif // PLASMA_EXTERNAL_RELEASE
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static const hsScalar kAirTimeThreshold;
|
|
||||||
|
|
||||||
friend class PXControllerHitReport;
|
|
||||||
static plPXPhysicalController* FindController(NxController* controller);
|
|
||||||
|
|
||||||
void IApply(hsScalar delSecs);
|
|
||||||
void ISendUpdates(hsScalar delSecs);
|
|
||||||
void ICheckForFalseGround();
|
|
||||||
void ISetGlobalLoc(const hsMatrix44& l2w);
|
|
||||||
void IMatchKinematicToController();
|
|
||||||
void IMoveKinematicToController(hsPoint3& pos);
|
|
||||||
void ISetKinematicLoc(const hsMatrix44& l2w);
|
|
||||||
void IGetPositionSim(hsPoint3& pos) const;
|
|
||||||
|
|
||||||
void ICreateController();
|
|
||||||
void IDeleteController();
|
|
||||||
|
|
||||||
void IInformDetectors(bool entering);
|
|
||||||
|
|
||||||
plKey fOwner;
|
|
||||||
plKey fWorldKey;
|
|
||||||
hsScalar fRadius, fHeight;
|
|
||||||
NxCapsuleController* fController;
|
|
||||||
|
|
||||||
// this is the kinematic actor for triggering things when the avatar is collision-less during behaviors
|
|
||||||
NxActor* fKinematicActor;
|
|
||||||
|
|
||||||
hsVector3 fLinearVelocity;
|
|
||||||
hsScalar fAngularVelocity;
|
|
||||||
|
|
||||||
hsVector3 fAchievedLinearVelocity;
|
|
||||||
|
|
||||||
// The global position and rotation of the avatar last time we set it (so we
|
|
||||||
// can detect if someone else moves him)
|
|
||||||
hsMatrix44 fLastGlobalLoc;
|
|
||||||
//
|
|
||||||
hsPoint3 fLocalPosition;
|
|
||||||
hsQuat fLocalRotation;
|
|
||||||
|
|
||||||
hsMatrix44 fPrevSubworldW2L;
|
|
||||||
|
|
||||||
bool fEnable;
|
|
||||||
bool fEnableChanged;
|
|
||||||
plSimDefs::plLOSDB fLOSDB;
|
|
||||||
|
|
||||||
bool fKinematic;
|
|
||||||
bool fKinematicChanged;
|
|
||||||
bool fKinematicEnableNextUpdate;
|
|
||||||
|
|
||||||
bool fGroundHit;
|
|
||||||
bool fFalseGround;
|
|
||||||
hsScalar fTimeInAir;
|
|
||||||
hsTArray<hsVector3> fSlidingNormals;
|
|
||||||
hsTArray<hsVector3> fPrevSlidingNormals;
|
|
||||||
|
|
||||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
|
||||||
hsTArray<plDbgCollisionInfo> fDbgCollisionInfo;
|
|
||||||
void IDrawDebugDisplay();
|
|
||||||
#endif // PLASMA_EXTERNAL_RELEASE
|
|
||||||
|
|
||||||
plPhysical* fPushingPhysical;
|
|
||||||
bool fFacingPushingPhysical;
|
|
||||||
|
|
||||||
plPhysicalProxy* fProxyGen; // visual proxy for debugging
|
|
||||||
|
|
||||||
bool fHitHead;
|
|
||||||
|
|
||||||
bool fSeeking;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // plPXPhysicalController_h_inc
|
|
File diff suppressed because it is too large
Load Diff
@ -40,22 +40,19 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
|
|
||||||
*==LICENSE==*/
|
*==LICENSE==*/
|
||||||
#include "../plAvatar/plPhysicalControllerCore.h"
|
#include "../plAvatar/plPhysicalControllerCore.h"
|
||||||
#include "hsQuat.h"
|
|
||||||
#define PHYSX_ONLY_TRIGGER_FROM_KINEMATIC 1
|
|
||||||
|
|
||||||
class NxController;
|
|
||||||
class NxCapsuleController;
|
class NxCapsuleController;
|
||||||
class NxActor;
|
class NxActor;
|
||||||
class plCoordinateInterface;
|
class NxCapsule;
|
||||||
|
class PXControllerHitReport;
|
||||||
class plPhysicalProxy;
|
class plPhysicalProxy;
|
||||||
class plDrawableSpans;
|
class plDrawableSpans;
|
||||||
class hsGMaterial;
|
class hsGMaterial;
|
||||||
class NxCapsule;
|
|
||||||
class plSceneObject;
|
class plSceneObject;
|
||||||
class PXControllerHitReportWalk;
|
class plPXPhysical;
|
||||||
class plCollideMsg;
|
class plCollideMsg;
|
||||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
|
||||||
|
|
||||||
|
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||||
class plDbgCollisionInfo
|
class plDbgCollisionInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -64,98 +61,112 @@ public:
|
|||||||
hsBool fOverlap;
|
hsBool fOverlap;
|
||||||
};
|
};
|
||||||
#endif // PLASMA_EXTERNAL_RELEASE
|
#endif // PLASMA_EXTERNAL_RELEASE
|
||||||
|
|
||||||
class plPXPhysicalControllerCore: public plPhysicalControllerCore
|
class plPXPhysicalControllerCore: public plPhysicalControllerCore
|
||||||
{
|
{
|
||||||
friend PXControllerHitReportWalk;
|
|
||||||
public:
|
public:
|
||||||
plPXPhysicalControllerCore(plKey ownerSO, hsScalar height, hsScalar radius);
|
plPXPhysicalControllerCore(plKey ownerSO, hsScalar height, hsScalar radius);
|
||||||
~plPXPhysicalControllerCore();
|
~plPXPhysicalControllerCore();
|
||||||
//should actually be a 3 vector but everywhere else it is assumed to be just around Z
|
|
||||||
|
// An ArmatureMod has its own idea about when physics should be enabled/disabled.
|
||||||
inline virtual void Move(hsVector3 displacement, unsigned int collideWith, unsigned int &collisionResults);
|
// Use plArmatureModBase::EnablePhysics() instead.
|
||||||
// A disabled avatar doesn't move or accumulate air time if he's off the ground.
|
|
||||||
virtual void Enable(bool enable);
|
virtual void Enable(bool enable);
|
||||||
|
|
||||||
virtual void SetSubworld(plKey world) ;
|
// Subworld
|
||||||
virtual const plCoordinateInterface* GetSubworldCI() const ;
|
virtual void SetSubworld(plKey world);
|
||||||
|
|
||||||
// For the avatar SDL only
|
// For the avatar SDL only
|
||||||
virtual void GetState(hsPoint3& pos, float& zRot);
|
virtual void GetState(hsPoint3& pos, float& zRot);
|
||||||
virtual void SetState(const hsPoint3& pos, float zRot);
|
virtual void SetState(const hsPoint3& pos, float zRot);
|
||||||
// kinematic stuff .... should be just for when playing a behavior...
|
|
||||||
virtual void Kinematic(bool state);
|
// Movement strategy
|
||||||
virtual bool IsKinematic();
|
virtual void SetMovementStrategy(plMovementStrategy* strategy);
|
||||||
virtual void GetKinematicPosition(hsPoint3& pos);
|
|
||||||
virtual const hsMatrix44& GetPrevSubworldW2L(){ return fPrevSubworldW2L; }
|
// Global location
|
||||||
//when seeking no longer want to interact with exclusion regions
|
virtual void SetGlobalLoc(const hsMatrix44& l2w);
|
||||||
virtual void GetWorldSpaceCapsule(NxCapsule& cap) const;
|
|
||||||
static void RebuildCache();
|
// Local Sim Position
|
||||||
virtual const hsMatrix44& GetLastGlobalLoc(){return fLastGlobalLoc;}
|
virtual void GetPositionSim(hsPoint3& pos);
|
||||||
virtual void SetKinematicLoc(const hsMatrix44& l2w){ISetKinematicLoc(l2w);}
|
|
||||||
virtual void SetGlobalLoc(const hsMatrix44& l2w){ISetGlobalLoc(l2w);}
|
// Move kinematic controller
|
||||||
virtual void HandleEnableChanged();
|
virtual void Move(hsVector3 displacement, unsigned int collideWith, unsigned int &collisionResults);
|
||||||
virtual void HandleKinematicChanged();
|
|
||||||
virtual void HandleKinematicEnableNextUpdate();
|
// Set linear velocity on dynamic controller
|
||||||
virtual void GetPositionSim(hsPoint3& pos){IGetPositionSim(pos);}
|
virtual void SetLinearVelocitySim(const hsVector3& linearVel);
|
||||||
virtual void MoveKinematicToController(hsPoint3& pos);
|
|
||||||
virtual const hsPoint3& GetLocalPosition(){return fLocalPosition;}
|
// Sweep the controller path from startPos through endPos
|
||||||
virtual void SetControllerDimensions(hsScalar radius, hsScalar height);
|
virtual int SweepControllerPath(const hsPoint3& startPos, const hsPoint3& endPos, hsBool vsDynamics,
|
||||||
|
hsBool vsStatics, UInt32& vsSimGroups, std::vector<plControllerSweepRecord>& hits);
|
||||||
|
|
||||||
|
// any clean up for the controller should go here
|
||||||
virtual void LeaveAge();
|
virtual void LeaveAge();
|
||||||
virtual void UpdateControllerAndPhysicalRep();
|
|
||||||
|
// Capsule
|
||||||
|
void GetWorldSpaceCapsule(NxCapsule& cap) const;
|
||||||
|
|
||||||
|
// Create Proxy for debug rendering
|
||||||
|
plDrawableSpans* CreateProxy(hsGMaterial* mat, hsTArray<UInt32>& idx, plDrawableSpans* addTo);
|
||||||
|
|
||||||
|
// Dynamic hits
|
||||||
|
void AddDynamicHit(plPXPhysical* phys);
|
||||||
|
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
//Static Helper Functions
|
//Static Helper Functions
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// Used by the LOS mgr to find the controller for an actor it hit
|
|
||||||
static plPXPhysicalControllerCore* GetController(NxActor& actor, bool* isController);
|
// Call pre-sim to apply movement to controllers
|
||||||
// test to see if there are any controllers (i.e. avatars) in this subworld
|
static void Apply(hsScalar delSecs);
|
||||||
|
|
||||||
|
// Call post-sim to update controllers
|
||||||
|
static void Update(int numSubSteps, hsScalar alpha);
|
||||||
|
|
||||||
|
// Update controllers when not performing a physics step
|
||||||
|
static void UpdateNonPhysical(hsScalar alpha);
|
||||||
|
|
||||||
|
// Rebuild the controller cache, required when a static actor in the scene has changed.
|
||||||
|
static void RebuildCache();
|
||||||
|
|
||||||
|
// Returns the plPXPhysicalControllerCore associated with the given NxActor
|
||||||
|
static plPXPhysicalControllerCore* GetController(NxActor& actor);
|
||||||
|
|
||||||
|
// Subworld controller queries
|
||||||
static bool AnyControllersInThisWorld(plKey world);
|
static bool AnyControllersInThisWorld(plKey world);
|
||||||
static int NumControllers();
|
|
||||||
static int GetControllersInThisSubWorld(plKey world, int maxToReturn,
|
|
||||||
plPXPhysicalControllerCore** bufferout);
|
|
||||||
static int GetNumberOfControllersInThisSubWorld(plKey world);
|
static int GetNumberOfControllersInThisSubWorld(plKey world);
|
||||||
static void UpdatePrestep(hsScalar delSecs);
|
static int GetControllersInThisSubWorld(plKey world, int maxToReturn, plPXPhysicalControllerCore** bufferout);
|
||||||
static void UpdatePoststep(hsScalar delSecs);
|
|
||||||
static void UpdatePostSimStep(hsScalar delSecs);
|
// Controller count
|
||||||
virtual plDrawableSpans* CreateProxy(hsGMaterial* mat, hsTArray<UInt32>& idx, plDrawableSpans* addTo);
|
static int NumControllers();
|
||||||
|
static void SetMaxNumberOfControllers(int max) { fPXControllersMax = max; }
|
||||||
|
static int fPXControllersMax;
|
||||||
|
|
||||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||||
static hsBool fDebugDisplay;
|
static hsBool fDebugDisplay;
|
||||||
#endif // PLASMA_EXTERNAL_RELEASE
|
#endif
|
||||||
static void plPXPhysicalControllerCore::SetMaxNumberOfControllers(int max) { fPXControllersMax = max; }
|
|
||||||
static int fPXControllersMax;
|
|
||||||
virtual int SweepControllerPath(const hsPoint3& startPos, const hsPoint3& endPos, hsBool vsDynamics, hsBool vsStatics, UInt32& vsSimGroups, std::multiset< plControllerSweepRecord >& WhatWasHitOut);
|
|
||||||
virtual void BehaveLikeAnimatedPhysical(hsBool actLikeAnAnimatedPhys);
|
|
||||||
virtual hsBool BehavingLikeAnAnimatedPhysical();
|
|
||||||
virtual const hsVector3& GetLinearVelocity();
|
|
||||||
|
|
||||||
virtual void SetLinearVelocity(const hsVector3& linearVel);
|
|
||||||
//should actually be a 3 vector but everywhere else it is assumed to be just around Z
|
|
||||||
virtual void SetAngularVelocity(const hsScalar angvel);
|
|
||||||
virtual void SetVelocities(const hsVector3& linearVel, hsScalar angVel);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class PXControllerHitReport;
|
friend class PXControllerHitReport;
|
||||||
static plPXPhysicalControllerCore* FindController(NxController* controller);
|
|
||||||
void ISetGlobalLoc(const hsMatrix44& l2w);
|
virtual void IHandleEnableChanged();
|
||||||
void IMatchKinematicToController();
|
|
||||||
void IMatchControllerToKinematic();
|
void IInformDetectors(bool entering);
|
||||||
void ISetKinematicLoc(const hsMatrix44& l2w);
|
|
||||||
void IGetPositionSim(hsPoint3& pos) const;
|
void ICreateController(const hsPoint3& pos);
|
||||||
void ICreateController();
|
|
||||||
void IDeleteController();
|
void IDeleteController();
|
||||||
void IInformDetectors(bool entering,bool deferUntilNextSim);
|
|
||||||
void plPXPhysicalControllerCore::ICreateController(const hsPoint3& pos);
|
void IDispatchQueuedMsgs();
|
||||||
NxActor* fKinematicActor;
|
void IProcessDynamicHits();
|
||||||
NxCapsuleController* fController;
|
|
||||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||||
hsTArray<plDbgCollisionInfo> fDbgCollisionInfo;
|
|
||||||
void IDrawDebugDisplay();
|
void IDrawDebugDisplay();
|
||||||
|
hsTArray<plDbgCollisionInfo> fDbgCollisionInfo;
|
||||||
#endif
|
#endif
|
||||||
void plPXPhysicalControllerCore::IHandleResize();
|
|
||||||
hsTArray<plCollideMsg*> fQueuedCollideMsgs;
|
std::vector<plCollideMsg*> fQueuedCollideMsgs;
|
||||||
hsScalar fPreferedRadius;
|
std::vector<plPXPhysical*> fDynamicHits;
|
||||||
hsScalar fPreferedHeight;
|
|
||||||
// The global position and rotation of the avatar last time we set it (so we
|
NxCapsuleController* fController;
|
||||||
// can detect if someone else moves him)
|
NxActor* fActor;
|
||||||
plPhysicalProxy* fProxyGen;
|
|
||||||
hsBool fBehavingLikeAnimatedPhys;
|
plPhysicalProxy* fProxyGen;
|
||||||
|
bool fKinematicCCT;
|
||||||
};
|
};
|
||||||
|
@ -67,80 +67,26 @@ class SensorReport : public NxUserTriggerReport
|
|||||||
{
|
{
|
||||||
virtual void onTrigger(NxShape& triggerShape, NxShape& otherShape, NxTriggerFlag status)
|
virtual void onTrigger(NxShape& triggerShape, NxShape& otherShape, NxTriggerFlag status)
|
||||||
{
|
{
|
||||||
// Get our trigger physical. This should definitely have a plPXPhysical
|
plKey otherKey = nil;
|
||||||
plPXPhysical* triggerPhys = (plPXPhysical*)triggerShape.getActor().userData;
|
|
||||||
hsBool doReport = false;
|
hsBool doReport = false;
|
||||||
|
|
||||||
// Get the triggerer. This may be an avatar, which doesn't have a
|
// Get our trigger physical. This should definitely have a plPXPhysical
|
||||||
// plPXPhysical, so we have to extract the necessary info.
|
plPXPhysical* triggerPhys = (plPXPhysical*)triggerShape.getActor().userData;
|
||||||
plKey otherKey = nil;
|
|
||||||
hsPoint3 otherPos = plPXConvert::Point(otherShape.getGlobalPosition());
|
|
||||||
|
|
||||||
if (plSimulationMgr::fExtraProfile)
|
|
||||||
DetectorLogRed("-->%s %s (status=%x) other@(%f,%f,%f)",triggerPhys->GetObjectKey()->GetName(),status & NX_TRIGGER_ON_ENTER ? "enter" : "exit",status,otherPos.fX,otherPos.fY,otherPos.fZ);
|
|
||||||
|
|
||||||
|
// Get the triggerer. If it doesn't have a plPXPhyscial, it's an avatar
|
||||||
plPXPhysical* otherPhys = (plPXPhysical*)otherShape.getActor().userData;
|
plPXPhysical* otherPhys = (plPXPhysical*)otherShape.getActor().userData;
|
||||||
if (otherPhys)
|
if (otherPhys)
|
||||||
{
|
{
|
||||||
otherKey = otherPhys->GetObjectKey();
|
otherKey = otherPhys->GetObjectKey();
|
||||||
doReport = triggerPhys->DoReportOn((plSimDefs::Group)otherPhys->GetGroup());
|
doReport = triggerPhys->DoReportOn((plSimDefs::Group)otherPhys->GetGroup());
|
||||||
if (!doReport)
|
|
||||||
{
|
|
||||||
if (plSimulationMgr::fExtraProfile)
|
|
||||||
DetectorLogRed("<--Kill collision %s :failed group. US=%x OTHER=(%s)%x",triggerPhys->GetObjectKey()->GetName(),triggerPhys->GetGroup(),otherPhys->GetObjectKey()->GetName(),otherPhys->GetGroup());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool isController;
|
plPXPhysicalControllerCore* controller = plPXPhysicalControllerCore::GetController(otherShape.getActor());
|
||||||
plPXPhysicalControllerCore* controller = plPXPhysicalControllerCore::GetController(otherShape.getActor(),&isController);
|
|
||||||
if (controller)
|
if (controller)
|
||||||
{
|
{
|
||||||
if (isController)
|
|
||||||
{
|
|
||||||
#ifdef PHYSX_ONLY_TRIGGER_FROM_KINEMATIC
|
|
||||||
if (plSimulationMgr::fExtraProfile)
|
|
||||||
DetectorLogRed("<--Kill collision %s : ignoring controller events.",triggerPhys->GetObjectKey()->GetName());
|
|
||||||
return;
|
|
||||||
#else // else if trigger on both controller and kinematic
|
|
||||||
// only suppress controller collision 'enters' when disabled but let 'exits' continue
|
|
||||||
// ...this is because there are detector regions that are on the edge on ladders that the exit gets missed.
|
|
||||||
if ( ( !controller->IsEnabled() /*&& (status & NX_TRIGGER_ON_ENTER)*/ ) || controller->IsKinematic() )
|
|
||||||
{
|
|
||||||
if (plSimulationMgr::fExtraProfile)
|
|
||||||
DetectorLogRed("<--Kill collision %s : controller is not enabled.",triggerPhys->GetObjectKey()->GetName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif // PHYSX_ONLY_TRIGGER_FROM_KINEMATIC
|
|
||||||
}
|
|
||||||
#ifndef PHYSX_ONLY_TRIGGER_FROM_KINEMATIC // if triggering only kinematics, then all should trigger
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// only suppress kinematic collision 'enters' when disabled but let 'exits' continue
|
|
||||||
// ...this is because there are detector regions that are on the edge on ladders that the exit gets missed.
|
|
||||||
if ( !controller->IsKinematic() /*&& (status & NX_TRIGGER_ON_ENTER) */ )
|
|
||||||
{
|
|
||||||
if (plSimulationMgr::fExtraProfile)
|
|
||||||
DetectorLogRed("<--Kill collision %s : kinematic is not enabled.",triggerPhys->GetObjectKey()->GetName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // PHYSX_ONLY_TRIGGER_FROM_KINEMATIC
|
|
||||||
otherKey = controller->GetOwner();
|
otherKey = controller->GetOwner();
|
||||||
doReport = triggerPhys->DoReportOn(plSimDefs::kGroupAvatar);
|
doReport = triggerPhys->DoReportOn(plSimDefs::kGroupAvatar);
|
||||||
if (plSimulationMgr::fExtraProfile )
|
|
||||||
{
|
|
||||||
if (!doReport)
|
|
||||||
{
|
|
||||||
DetectorLogRed("<--Kill collision %s :failed group. US=%x OTHER=(NotAvatar)",triggerPhys->GetObjectKey()->GetName(),triggerPhys->GetGroup());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hsPoint3 avpos;
|
|
||||||
controller->GetPositionSim(avpos);
|
|
||||||
DetectorLogRed("-->Avatar at (%f,%f,%f)",avpos.fX,avpos.fY,avpos.fZ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,6 +354,7 @@ plSimulationMgr::plSimulationMgr()
|
|||||||
: fSuspended(true)
|
: fSuspended(true)
|
||||||
, fMaxDelta(kDefaultMaxDelta)
|
, fMaxDelta(kDefaultMaxDelta)
|
||||||
, fStepSize(kDefaultStepSize)
|
, fStepSize(kDefaultStepSize)
|
||||||
|
, fAccumulator(0.0f)
|
||||||
, fLOSDispatch(TRACKED_NEW plLOSDispatch())
|
, fLOSDispatch(TRACKED_NEW plLOSDispatch())
|
||||||
, fSoundMgr(new plPhysicsSoundMgr)
|
, fSoundMgr(new plPhysicsSoundMgr)
|
||||||
, fLog(nil)
|
, fLog(nil)
|
||||||
@ -496,6 +443,7 @@ NxScene* plSimulationMgr::GetScene(plKey world)
|
|||||||
scene->setGroupCollisionFlag(i, plSimDefs::kGroupDynamicBlocker, false);
|
scene->setGroupCollisionFlag(i, plSimDefs::kGroupDynamicBlocker, false);
|
||||||
scene->setGroupCollisionFlag(i, plSimDefs::kGroupLOSOnly, false);
|
scene->setGroupCollisionFlag(i, plSimDefs::kGroupLOSOnly, false);
|
||||||
scene->setGroupCollisionFlag(plSimDefs::kGroupLOSOnly, i, false);
|
scene->setGroupCollisionFlag(plSimDefs::kGroupLOSOnly, i, false);
|
||||||
|
scene->setGroupCollisionFlag(i, plSimDefs::kGroupAvatarKinematic, false);
|
||||||
}
|
}
|
||||||
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupAvatar, false);
|
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupAvatar, false);
|
||||||
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupAvatarBlocker, true);
|
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupAvatarBlocker, true);
|
||||||
@ -503,6 +451,10 @@ NxScene* plSimulationMgr::GetScene(plKey world)
|
|||||||
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupStatic, true);
|
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupStatic, true);
|
||||||
scene->setGroupCollisionFlag( plSimDefs::kGroupStatic, plSimDefs::kGroupAvatar, true);
|
scene->setGroupCollisionFlag( plSimDefs::kGroupStatic, plSimDefs::kGroupAvatar, true);
|
||||||
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupDynamic, true);
|
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatar, plSimDefs::kGroupDynamic, true);
|
||||||
|
|
||||||
|
// Kinematically controlled avatars interact with detectors and dynamics
|
||||||
|
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatarKinematic, plSimDefs::kGroupDetector, true);
|
||||||
|
scene->setGroupCollisionFlag(plSimDefs::kGroupAvatarKinematic, plSimDefs::kGroupDynamic, true);
|
||||||
|
|
||||||
// The dynamics are in actor group 1, everything else is in 0. Request
|
// The dynamics are in actor group 1, everything else is in 0. Request
|
||||||
// a callback for whenever a dynamic touches something.
|
// a callback for whenever a dynamic touches something.
|
||||||
@ -616,8 +568,7 @@ void plSimulationMgr::UpdateAvatarInDetector(plKey world, plPXPhysical* detector
|
|||||||
if ( actors[i]->userData == nil )
|
if ( actors[i]->userData == nil )
|
||||||
{
|
{
|
||||||
// we go a controller
|
// we go a controller
|
||||||
bool isController;
|
plPXPhysicalControllerCore* controller = plPXPhysicalControllerCore::GetController(*actors[i]);
|
||||||
plPXPhysicalControllerCore* controller = plPXPhysicalControllerCore::GetController(*actors[i],&isController);
|
|
||||||
if (controller && controller->IsEnabled())
|
if (controller && controller->IsEnabled())
|
||||||
{
|
{
|
||||||
plKey avatar = controller->GetOwner();
|
plKey avatar = controller->GetOwner();
|
||||||
@ -644,20 +595,29 @@ void plSimulationMgr::Advance(float delSecs)
|
|||||||
if (fSuspended)
|
if (fSuspended)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (delSecs > fMaxDelta)
|
fAccumulator += delSecs;
|
||||||
|
if (fAccumulator < fStepSize)
|
||||||
|
{
|
||||||
|
// Not enough time has passed to perform a substep.
|
||||||
|
plPXPhysicalControllerCore::UpdateNonPhysical(fAccumulator / fStepSize);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (fAccumulator > fMaxDelta)
|
||||||
{
|
{
|
||||||
if (fExtraProfile)
|
if (fExtraProfile)
|
||||||
Log("Step clamped from %f to limit of %f", delSecs, fMaxDelta);
|
Log("Step clamped from %f to limit of %f", fAccumulator, fMaxDelta);
|
||||||
delSecs = fMaxDelta;
|
fAccumulator = fMaxDelta;
|
||||||
}
|
}
|
||||||
plProfile_IncCount(StepLen, (int)(delSecs*1000));
|
|
||||||
|
|
||||||
#ifndef PLASMA_EXTERNAL_RELASE
|
// Perform as many whole substeps as possible saving the remainder in our accumulator.
|
||||||
UInt32 stepTime = hsTimer::GetPrecTickCount();
|
int numSubSteps = (int)(fAccumulator / fStepSize);
|
||||||
#endif
|
float delta = numSubSteps * fStepSize;
|
||||||
|
fAccumulator -= delta;
|
||||||
|
|
||||||
|
plProfile_IncCount(StepLen, (int)(delta*1000));
|
||||||
plProfile_BeginTiming(Step);
|
plProfile_BeginTiming(Step);
|
||||||
plPXPhysicalControllerCore::UpdatePrestep(delSecs);
|
|
||||||
plPXPhysicalControllerCore::UpdatePoststep( delSecs);
|
plPXPhysicalControllerCore::Apply(delta);
|
||||||
|
|
||||||
for (SceneMap::iterator it = fScenes.begin(); it != fScenes.end(); it++)
|
for (SceneMap::iterator it = fScenes.begin(); it != fScenes.end(); it++)
|
||||||
{
|
{
|
||||||
@ -672,12 +632,13 @@ void plSimulationMgr::Advance(float delSecs)
|
|||||||
}
|
}
|
||||||
if (do_advance)
|
if (do_advance)
|
||||||
{
|
{
|
||||||
scene->simulate(delSecs);
|
scene->simulate(delta);
|
||||||
scene->flushStream();
|
scene->flushStream();
|
||||||
scene->fetchResults(NX_RIGID_BODY_FINISHED, true);
|
scene->fetchResults(NX_RIGID_BODY_FINISHED, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plPXPhysicalControllerCore::UpdatePostSimStep(delSecs);
|
|
||||||
|
plPXPhysicalControllerCore::Update(numSubSteps, fAccumulator / fStepSize);
|
||||||
|
|
||||||
//sending off and clearing the Collision Messages generated by scene->simulate
|
//sending off and clearing the Collision Messages generated by scene->simulate
|
||||||
IDispatchCollisionMessages();
|
IDispatchCollisionMessages();
|
||||||
@ -754,9 +715,6 @@ void plSimulationMgr::ISendUpdates()
|
|||||||
plPXPhysical* physical = (plPXPhysical*)actors[i]->userData;
|
plPXPhysical* physical = (plPXPhysical*)actors[i]->userData;
|
||||||
if (physical)
|
if (physical)
|
||||||
{
|
{
|
||||||
// apply any hit forces
|
|
||||||
physical->ApplyHitForce();
|
|
||||||
|
|
||||||
if (physical->GetSceneNode())
|
if (physical->GetSceneNode())
|
||||||
{
|
{
|
||||||
physical->SendNewLocation();
|
physical->SendNewLocation();
|
||||||
|
@ -159,6 +159,7 @@ protected:
|
|||||||
|
|
||||||
float fMaxDelta;
|
float fMaxDelta;
|
||||||
float fStepSize;
|
float fStepSize;
|
||||||
|
float fAccumulator;
|
||||||
|
|
||||||
// A utility class to keep track of a request for a physical synchronization.
|
// A utility class to keep track of a request for a physical synchronization.
|
||||||
// These requests must pass a certain criteria (see the code for the latest)
|
// These requests must pass a certain criteria (see the code for the latest)
|
||||||
|
@ -68,8 +68,10 @@ namespace plSimDefs
|
|||||||
kGroupLOSOnly,
|
kGroupLOSOnly,
|
||||||
//kExcludeRegion setting up so only blocks avatars and only when not in seek mode
|
//kExcludeRegion setting up so only blocks avatars and only when not in seek mode
|
||||||
kGroupExcludeRegion,
|
kGroupExcludeRegion,
|
||||||
|
// A kinematic avatar only interacts with dynamics and detectors
|
||||||
|
kGroupAvatarKinematic,
|
||||||
// Just for error checking
|
// Just for error checking
|
||||||
kGroupMax,
|
kGroupMax
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Different types of line-of-sight requests. */
|
/** Different types of line-of-sight requests. */
|
||||||
|
Reference in New Issue
Block a user