feat(physics): wire physx sdk into build
This commit is contained in:
223
engine/third_party/physx/include/characterkinematic/PxBoxController.h
vendored
Normal file
223
engine/third_party/physx/include/characterkinematic/PxBoxController.h
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_BOX_CONTROLLER_H
|
||||
#define PX_BOX_CONTROLLER_H
|
||||
|
||||
#include "characterkinematic/PxController.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Descriptor for a box character controller.
|
||||
|
||||
\see PxBoxController PxControllerDesc
|
||||
*/
|
||||
class PxBoxControllerDesc : public PxControllerDesc
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief constructor sets to default.
|
||||
*/
|
||||
PX_INLINE PxBoxControllerDesc();
|
||||
PX_INLINE virtual ~PxBoxControllerDesc() {}
|
||||
|
||||
/**
|
||||
\brief copy constructor.
|
||||
*/
|
||||
PX_INLINE PxBoxControllerDesc(const PxBoxControllerDesc&);
|
||||
|
||||
/**
|
||||
\brief assignment operator.
|
||||
*/
|
||||
PX_INLINE PxBoxControllerDesc& operator=(const PxBoxControllerDesc&);
|
||||
|
||||
/**
|
||||
\brief (re)sets the structure to the default.
|
||||
*/
|
||||
PX_INLINE virtual void setToDefault();
|
||||
|
||||
/**
|
||||
\brief returns true if the current settings are valid
|
||||
|
||||
\return True if the descriptor is valid.
|
||||
*/
|
||||
PX_INLINE virtual bool isValid() const;
|
||||
|
||||
/**
|
||||
\brief Half height
|
||||
|
||||
<b>Default:</b> 1.0
|
||||
*/
|
||||
PxF32 halfHeight; // Half-height in the "up" direction
|
||||
|
||||
/**
|
||||
\brief Half side extent
|
||||
|
||||
<b>Default:</b> 0.5
|
||||
*/
|
||||
PxF32 halfSideExtent; // Half-extent in the "side" direction
|
||||
|
||||
/**
|
||||
\brief Half forward extent
|
||||
|
||||
<b>Default:</b> 0.5
|
||||
*/
|
||||
PxF32 halfForwardExtent; // Half-extent in the "forward" direction
|
||||
|
||||
protected:
|
||||
PX_INLINE void copy(const PxBoxControllerDesc&);
|
||||
};
|
||||
|
||||
PX_INLINE PxBoxControllerDesc::PxBoxControllerDesc() :
|
||||
PxControllerDesc (PxControllerShapeType::eBOX),
|
||||
halfHeight (1.0f),
|
||||
halfSideExtent (0.5f),
|
||||
halfForwardExtent (0.5f)
|
||||
{
|
||||
}
|
||||
|
||||
PX_INLINE PxBoxControllerDesc::PxBoxControllerDesc(const PxBoxControllerDesc& other) : PxControllerDesc(other)
|
||||
{
|
||||
copy(other);
|
||||
}
|
||||
|
||||
PX_INLINE PxBoxControllerDesc& PxBoxControllerDesc::operator=(const PxBoxControllerDesc& other)
|
||||
{
|
||||
PxControllerDesc::operator=(other);
|
||||
copy(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_INLINE void PxBoxControllerDesc::copy(const PxBoxControllerDesc& other)
|
||||
{
|
||||
halfHeight = other.halfHeight;
|
||||
halfSideExtent = other.halfSideExtent;
|
||||
halfForwardExtent = other.halfForwardExtent;
|
||||
}
|
||||
|
||||
PX_INLINE void PxBoxControllerDesc::setToDefault()
|
||||
{
|
||||
*this = PxBoxControllerDesc();
|
||||
}
|
||||
|
||||
PX_INLINE bool PxBoxControllerDesc::isValid() const
|
||||
{
|
||||
if(!PxControllerDesc::isValid()) return false;
|
||||
if(halfHeight<=0.0f) return false;
|
||||
if(halfSideExtent<=0.0f) return false;
|
||||
if(halfForwardExtent<=0.0f) return false;
|
||||
if(stepOffset>2.0f*halfHeight) return false; // Prevents obvious mistakes
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Box character controller.
|
||||
|
||||
\see PxBoxControllerDesc PxController
|
||||
*/
|
||||
class PxBoxController : public PxController
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Gets controller's half height.
|
||||
|
||||
\return The half height of the controller.
|
||||
|
||||
\see PxBoxControllerDesc.halfHeight setHalfHeight()
|
||||
*/
|
||||
virtual PxF32 getHalfHeight() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets controller's half side extent.
|
||||
|
||||
\return The half side extent of the controller.
|
||||
|
||||
\see PxBoxControllerDesc.halfSideExtent setHalfSideExtent()
|
||||
*/
|
||||
virtual PxF32 getHalfSideExtent() const = 0;
|
||||
|
||||
/**
|
||||
\brief Gets controller's half forward extent.
|
||||
|
||||
\return The half forward extent of the controller.
|
||||
|
||||
\see PxBoxControllerDesc.halfForwardExtent setHalfForwardExtent()
|
||||
*/
|
||||
virtual PxF32 getHalfForwardExtent() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets controller's half height.
|
||||
|
||||
\warning this doesn't check for collisions.
|
||||
|
||||
\param[in] halfHeight The new half height for the controller.
|
||||
\return Currently always true.
|
||||
|
||||
\see PxBoxControllerDesc.halfHeight getHalfHeight()
|
||||
*/
|
||||
virtual bool setHalfHeight(PxF32 halfHeight) = 0;
|
||||
|
||||
/**
|
||||
\brief Sets controller's half side extent.
|
||||
|
||||
\warning this doesn't check for collisions.
|
||||
|
||||
\param[in] halfSideExtent The new half side extent for the controller.
|
||||
\return Currently always true.
|
||||
|
||||
\see PxBoxControllerDesc.halfSideExtent getHalfSideExtent()
|
||||
*/
|
||||
virtual bool setHalfSideExtent(PxF32 halfSideExtent) = 0;
|
||||
|
||||
/**
|
||||
\brief Sets controller's half forward extent.
|
||||
|
||||
\warning this doesn't check for collisions.
|
||||
|
||||
\param[in] halfForwardExtent The new half forward extent for the controller.
|
||||
\return Currently always true.
|
||||
|
||||
\see PxBoxControllerDesc.halfForwardExtent getHalfForwardExtent()
|
||||
*/
|
||||
virtual bool setHalfForwardExtent(PxF32 halfForwardExtent) = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxBoxController() {}
|
||||
virtual ~PxBoxController() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
244
engine/third_party/physx/include/characterkinematic/PxCapsuleController.h
vendored
Normal file
244
engine/third_party/physx/include/characterkinematic/PxCapsuleController.h
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CAPSULE_CONTROLLER_H
|
||||
#define PX_CAPSULE_CONTROLLER_H
|
||||
|
||||
#include "characterkinematic/PxController.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxCapsuleClimbingMode
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eEASY, //!< Standard mode, let the capsule climb over surfaces according to impact normal
|
||||
eCONSTRAINED, //!< Constrained mode, try to limit climbing according to the step offset
|
||||
|
||||
eLAST
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A descriptor for a capsule character controller.
|
||||
|
||||
\see PxCapsuleController PxControllerDesc
|
||||
*/
|
||||
class PxCapsuleControllerDesc : public PxControllerDesc
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief constructor sets to default.
|
||||
*/
|
||||
PX_INLINE PxCapsuleControllerDesc ();
|
||||
PX_INLINE virtual ~PxCapsuleControllerDesc () {}
|
||||
|
||||
/**
|
||||
\brief copy constructor.
|
||||
*/
|
||||
PX_INLINE PxCapsuleControllerDesc(const PxCapsuleControllerDesc&);
|
||||
|
||||
/**
|
||||
\brief assignment operator.
|
||||
*/
|
||||
PX_INLINE PxCapsuleControllerDesc& operator=(const PxCapsuleControllerDesc&);
|
||||
|
||||
/**
|
||||
\brief (re)sets the structure to the default.
|
||||
*/
|
||||
PX_INLINE virtual void setToDefault();
|
||||
/**
|
||||
\brief returns true if the current settings are valid
|
||||
|
||||
\return True if the descriptor is valid.
|
||||
*/
|
||||
PX_INLINE virtual bool isValid() const;
|
||||
|
||||
/**
|
||||
\brief The radius of the capsule
|
||||
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
\see PxCapsuleController
|
||||
*/
|
||||
PxF32 radius;
|
||||
|
||||
/**
|
||||
\brief The height of the controller
|
||||
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
\see PxCapsuleController
|
||||
*/
|
||||
PxF32 height;
|
||||
|
||||
/**
|
||||
\brief The climbing mode
|
||||
|
||||
<b>Default:</b> PxCapsuleClimbingMode::eEASY
|
||||
|
||||
\see PxCapsuleController
|
||||
*/
|
||||
PxCapsuleClimbingMode::Enum climbingMode;
|
||||
|
||||
protected:
|
||||
PX_INLINE void copy(const PxCapsuleControllerDesc&);
|
||||
};
|
||||
|
||||
PX_INLINE PxCapsuleControllerDesc::PxCapsuleControllerDesc () : PxControllerDesc(PxControllerShapeType::eCAPSULE)
|
||||
{
|
||||
radius = height = 0.0f;
|
||||
climbingMode = PxCapsuleClimbingMode::eEASY;
|
||||
}
|
||||
|
||||
PX_INLINE PxCapsuleControllerDesc::PxCapsuleControllerDesc(const PxCapsuleControllerDesc& other) : PxControllerDesc(other)
|
||||
{
|
||||
copy(other);
|
||||
}
|
||||
|
||||
PX_INLINE PxCapsuleControllerDesc& PxCapsuleControllerDesc::operator=(const PxCapsuleControllerDesc& other)
|
||||
{
|
||||
PxControllerDesc::operator=(other);
|
||||
copy(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_INLINE void PxCapsuleControllerDesc::copy(const PxCapsuleControllerDesc& other)
|
||||
{
|
||||
radius = other.radius;
|
||||
height = other.height;
|
||||
climbingMode = other.climbingMode;
|
||||
}
|
||||
|
||||
PX_INLINE void PxCapsuleControllerDesc::setToDefault()
|
||||
{
|
||||
*this = PxCapsuleControllerDesc();
|
||||
}
|
||||
|
||||
PX_INLINE bool PxCapsuleControllerDesc::isValid() const
|
||||
{
|
||||
if(!PxControllerDesc::isValid()) return false;
|
||||
if(radius<=0.0f) return false;
|
||||
if(height<=0.0f) return false;
|
||||
if(stepOffset>height+radius*2.0f) return false; // Prevents obvious mistakes
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
\brief A capsule character controller.
|
||||
|
||||
The capsule is defined as a position, a vertical height, and a radius.
|
||||
The height is the distance between the two sphere centers at the end of the capsule.
|
||||
In other words:
|
||||
|
||||
p = pos (returned by controller)<br>
|
||||
h = height<br>
|
||||
r = radius<br>
|
||||
|
||||
p = center of capsule<br>
|
||||
top sphere center = p.y + h*0.5<br>
|
||||
bottom sphere center = p.y - h*0.5<br>
|
||||
top capsule point = p.y + h*0.5 + r<br>
|
||||
bottom capsule point = p.y - h*0.5 - r<br>
|
||||
*/
|
||||
class PxCapsuleController : public PxController
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Gets controller's radius.
|
||||
|
||||
\return The radius of the controller.
|
||||
|
||||
\see PxCapsuleControllerDesc.radius setRadius()
|
||||
*/
|
||||
virtual PxF32 getRadius() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets controller's radius.
|
||||
|
||||
\warning this doesn't check for collisions.
|
||||
|
||||
\param[in] radius The new radius for the controller.
|
||||
\return Currently always true.
|
||||
|
||||
\see PxCapsuleControllerDesc.radius getRadius()
|
||||
*/
|
||||
virtual bool setRadius(PxF32 radius) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets controller's height.
|
||||
|
||||
\return The height of the capsule controller.
|
||||
|
||||
\see PxCapsuleControllerDesc.height setHeight()
|
||||
*/
|
||||
virtual PxF32 getHeight() const = 0;
|
||||
|
||||
/**
|
||||
\brief Resets controller's height.
|
||||
|
||||
\warning this doesn't check for collisions.
|
||||
|
||||
\param[in] height The new height for the controller.
|
||||
\return Currently always true.
|
||||
|
||||
\see PxCapsuleControllerDesc.height getHeight()
|
||||
*/
|
||||
virtual bool setHeight(PxF32 height) = 0;
|
||||
|
||||
/**
|
||||
\brief Gets controller's climbing mode.
|
||||
|
||||
\return The capsule controller's climbing mode.
|
||||
|
||||
\see PxCapsuleControllerDesc.climbingMode setClimbingMode()
|
||||
*/
|
||||
virtual PxCapsuleClimbingMode::Enum getClimbingMode() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets controller's climbing mode.
|
||||
|
||||
\param[in] mode The capsule controller's climbing mode.
|
||||
|
||||
\see PxCapsuleControllerDesc.climbingMode getClimbingMode()
|
||||
*/
|
||||
virtual bool setClimbingMode(PxCapsuleClimbingMode::Enum mode) = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxCapsuleController() {}
|
||||
virtual ~PxCapsuleController() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
926
engine/third_party/physx/include/characterkinematic/PxController.h
vendored
Normal file
926
engine/third_party/physx/include/characterkinematic/PxController.h
vendored
Normal file
@@ -0,0 +1,926 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONTROLLER_H
|
||||
#define PX_CONTROLLER_H
|
||||
|
||||
#include "characterkinematic/PxExtended.h"
|
||||
#include "characterkinematic/PxControllerObstacles.h"
|
||||
#include "PxQueryFiltering.h"
|
||||
#include "foundation/PxErrorCallback.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief The type of controller, eg box, sphere or capsule.
|
||||
*/
|
||||
struct PxControllerShapeType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief A box controller.
|
||||
|
||||
\see PxBoxController PxBoxControllerDesc
|
||||
*/
|
||||
eBOX,
|
||||
|
||||
/**
|
||||
\brief A capsule controller
|
||||
|
||||
\see PxCapsuleController PxCapsuleControllerDesc
|
||||
*/
|
||||
eCAPSULE,
|
||||
|
||||
eFORCE_DWORD = 0x7fffffff
|
||||
};
|
||||
};
|
||||
|
||||
class PxShape;
|
||||
class PxScene;
|
||||
class PxController;
|
||||
class PxRigidDynamic;
|
||||
class PxMaterial;
|
||||
struct PxFilterData;
|
||||
class PxQueryFilterCallback;
|
||||
class PxControllerBehaviorCallback;
|
||||
class PxObstacleContext;
|
||||
class PxObstacle;
|
||||
|
||||
/**
|
||||
\brief specifies how a CCT interacts with non-walkable parts.
|
||||
|
||||
This is only used when slopeLimit is non zero. It is currently enabled for static actors only, and not supported for spheres or capsules.
|
||||
*/
|
||||
struct PxControllerNonWalkableMode
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
ePREVENT_CLIMBING, //!< Stops character from climbing up non-walkable slopes, but doesn't move it otherwise
|
||||
ePREVENT_CLIMBING_AND_FORCE_SLIDING //!< Stops character from climbing up non-walkable slopes, and forces it to slide down those slopes
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief specifies which sides a character is colliding with.
|
||||
*/
|
||||
struct PxControllerCollisionFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eCOLLISION_SIDES = (1<<0), //!< Character is colliding to the sides.
|
||||
eCOLLISION_UP = (1<<1), //!< Character has collision above.
|
||||
eCOLLISION_DOWN = (1<<2) //!< Character has collision below.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Bitfield that contains a set of raised flags defined in PxControllerCollisionFlag.
|
||||
|
||||
\see PxControllerCollisionFlag
|
||||
*/
|
||||
typedef PxFlags<PxControllerCollisionFlag::Enum, PxU8> PxControllerCollisionFlags;
|
||||
PX_FLAGS_OPERATORS(PxControllerCollisionFlag::Enum, PxU8)
|
||||
|
||||
/**
|
||||
\brief Describes a controller's internal state.
|
||||
*/
|
||||
struct PxControllerState
|
||||
{
|
||||
PxVec3 deltaXP; //!< delta position vector for the object the CCT is standing/riding on. Not always match the CCT delta when variable timesteps are used.
|
||||
PxShape* touchedShape; //!< Shape on which the CCT is standing
|
||||
PxRigidActor* touchedActor; //!< Actor owning 'touchedShape'
|
||||
PxObstacleHandle touchedObstacleHandle; // Obstacle on which the CCT is standing
|
||||
PxU32 collisionFlags; //!< Last known collision flags (PxControllerCollisionFlag)
|
||||
bool standOnAnotherCCT; //!< Are we standing on another CCT?
|
||||
bool standOnObstacle; //!< Are we standing on a user-defined obstacle?
|
||||
bool isMovingUp; //!< is CCT moving up or not? (i.e. explicit jumping)
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Describes a controller's internal statistics.
|
||||
*/
|
||||
struct PxControllerStats
|
||||
{
|
||||
PxU16 nbIterations;
|
||||
PxU16 nbFullUpdates;
|
||||
PxU16 nbPartialUpdates;
|
||||
PxU16 nbTessellation;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Describes a generic CCT hit.
|
||||
*/
|
||||
struct PxControllerHit
|
||||
{
|
||||
PxController* controller; //!< Current controller
|
||||
PxExtendedVec3 worldPos; //!< Contact position in world space
|
||||
PxVec3 worldNormal; //!< Contact normal in world space
|
||||
PxVec3 dir; //!< Motion direction
|
||||
PxF32 length; //!< Motion length
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Describes a hit between a CCT and a shape. Passed to onShapeHit()
|
||||
|
||||
\see PxUserControllerHitReport.onShapeHit()
|
||||
*/
|
||||
struct PxControllerShapeHit : public PxControllerHit
|
||||
{
|
||||
PxShape* shape; //!< Touched shape
|
||||
PxRigidActor* actor; //!< Touched actor
|
||||
PxU32 triangleIndex; //!< touched triangle index (only for meshes/heightfields)
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Describes a hit between a CCT and another CCT. Passed to onControllerHit().
|
||||
|
||||
\see PxUserControllerHitReport.onControllerHit()
|
||||
*/
|
||||
struct PxControllersHit : public PxControllerHit
|
||||
{
|
||||
PxController* other; //!< Touched controller
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Describes a hit between a CCT and a user-defined obstacle. Passed to onObstacleHit().
|
||||
|
||||
\see PxUserControllerHitReport.onObstacleHit() PxObstacleContext
|
||||
*/
|
||||
struct PxControllerObstacleHit : public PxControllerHit
|
||||
{
|
||||
const void* userData;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief User callback class for character controller events.
|
||||
|
||||
\note Character controller hit reports are only generated when move is called.
|
||||
|
||||
\see PxControllerDesc.callback
|
||||
*/
|
||||
class PxUserControllerHitReport
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Called when current controller hits a shape.
|
||||
|
||||
This is called when the CCT moves and hits a shape. This will not be called when a moving shape hits a non-moving CCT.
|
||||
|
||||
\param[in] hit Provides information about the hit.
|
||||
|
||||
\see PxControllerShapeHit
|
||||
*/
|
||||
virtual void onShapeHit(const PxControllerShapeHit& hit) = 0;
|
||||
|
||||
/**
|
||||
\brief Called when current controller hits another controller.
|
||||
|
||||
\param[in] hit Provides information about the hit.
|
||||
|
||||
\see PxControllersHit
|
||||
*/
|
||||
virtual void onControllerHit(const PxControllersHit& hit) = 0;
|
||||
|
||||
/**
|
||||
\brief Called when current controller hits a user-defined obstacle.
|
||||
|
||||
\param[in] hit Provides information about the hit.
|
||||
|
||||
\see PxControllerObstacleHit PxObstacleContext
|
||||
*/
|
||||
virtual void onObstacleHit(const PxControllerObstacleHit& hit) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PxUserControllerHitReport(){}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Dedicated filtering callback for CCT vs CCT.
|
||||
|
||||
This controls collisions between CCTs (one CCT vs anoter CCT).
|
||||
|
||||
To make each CCT collide against all other CCTs, just return true - or simply avoid defining a callback.
|
||||
To make each CCT freely go through all other CCTs, just return false.
|
||||
Otherwise create a custom filtering logic in this callback.
|
||||
|
||||
\see PxControllerFilters
|
||||
*/
|
||||
class PxControllerFilterCallback
|
||||
{
|
||||
public:
|
||||
virtual ~PxControllerFilterCallback(){}
|
||||
|
||||
/**
|
||||
\brief Filtering method for CCT-vs-CCT.
|
||||
|
||||
\param[in] a First CCT
|
||||
\param[in] b Second CCT
|
||||
\return true to keep the pair, false to filter it out
|
||||
*/
|
||||
virtual bool filter(const PxController& a, const PxController& b) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Filtering data for "move" call.
|
||||
|
||||
This class contains all filtering-related parameters for the PxController::move() call.
|
||||
|
||||
Collisions between a CCT and the world are filtered using the mFilterData, mFilterCallback and mFilterFlags
|
||||
members. These parameters are internally passed to PxScene::overlap() to find objects touched by the CCT.
|
||||
Please refer to the PxScene::overlap() documentation for details.
|
||||
|
||||
Collisions between a CCT and another CCT are filtered using the mCCTFilterCallback member. If this filter
|
||||
callback is not defined, none of the CCT-vs-CCT collisions are filtered, and each CCT will collide against
|
||||
all other CCTs.
|
||||
|
||||
\note PxQueryFlag::eANY_HIT and PxQueryFlag::eNO_BLOCK are ignored in mFilterFlags.
|
||||
|
||||
\see PxController.move() PxControllerFilterCallback
|
||||
*/
|
||||
class PxControllerFilters
|
||||
{
|
||||
public:
|
||||
|
||||
PX_INLINE PxControllerFilters(const PxFilterData* filterData=NULL, PxQueryFilterCallback* cb=NULL, PxControllerFilterCallback* cctFilterCb=NULL) :
|
||||
mFilterData (filterData),
|
||||
mFilterCallback (cb),
|
||||
mFilterFlags (PxQueryFlag::eSTATIC|PxQueryFlag::eDYNAMIC|PxQueryFlag::ePREFILTER),
|
||||
mCCTFilterCallback (cctFilterCb)
|
||||
{}
|
||||
|
||||
// CCT-vs-shapes:
|
||||
const PxFilterData* mFilterData; //!< Data for internal PxQueryFilterData structure. Passed to PxScene::overlap() call.
|
||||
//!< This can be NULL, in which case a default PxFilterData is used.
|
||||
PxQueryFilterCallback* mFilterCallback; //!< Custom filter logic (can be NULL). Passed to PxScene::overlap() call.
|
||||
PxQueryFlags mFilterFlags; //!< Flags for internal PxQueryFilterData structure. Passed to PxScene::overlap() call.
|
||||
// CCT-vs-CCT:
|
||||
PxControllerFilterCallback* mCCTFilterCallback; //!< CCT-vs-CCT filter callback. If NULL, all CCT-vs-CCT collisions are kept.
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Descriptor class for a character controller.
|
||||
|
||||
\see PxBoxController PxCapsuleController
|
||||
*/
|
||||
class PxControllerDesc
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief returns true if the current settings are valid
|
||||
|
||||
\return True if the descriptor is valid.
|
||||
*/
|
||||
PX_INLINE virtual bool isValid() const;
|
||||
|
||||
/**
|
||||
\brief Returns the character controller type
|
||||
|
||||
\return The controllers type.
|
||||
|
||||
\see PxControllerType PxCapsuleControllerDesc PxBoxControllerDesc
|
||||
*/
|
||||
PX_INLINE PxControllerShapeType::Enum getType() const { return mType; }
|
||||
|
||||
/**
|
||||
\brief The position of the character
|
||||
|
||||
\note The character's initial position must be such that it does not overlap the static geometry.
|
||||
|
||||
<b>Default:</b> Zero
|
||||
*/
|
||||
PxExtendedVec3 position;
|
||||
|
||||
/**
|
||||
\brief Specifies the 'up' direction
|
||||
|
||||
In order to provide stepping functionality the SDK must be informed about the up direction.
|
||||
|
||||
<b>Default:</b> (0, 1, 0)
|
||||
|
||||
*/
|
||||
PxVec3 upDirection;
|
||||
|
||||
/**
|
||||
\brief The maximum slope which the character can walk up.
|
||||
|
||||
In general it is desirable to limit where the character can walk, in particular it is unrealistic
|
||||
for the character to be able to climb arbitary slopes.
|
||||
|
||||
The limit is expressed as the cosine of desired limit angle. A value of 0 disables this feature.
|
||||
|
||||
\warning It is currently enabled for static actors only (not for dynamic/kinematic actors), and not supported for spheres or capsules.
|
||||
|
||||
<b>Default:</b> 0.707
|
||||
|
||||
\see upDirection invisibleWallHeight maxJumpHeight
|
||||
*/
|
||||
PxF32 slopeLimit;
|
||||
|
||||
/**
|
||||
\brief Height of invisible walls created around non-walkable triangles
|
||||
|
||||
The library can automatically create invisible walls around non-walkable triangles defined
|
||||
by the 'slopeLimit' parameter. This defines the height of those walls. If it is 0.0, then
|
||||
no extra triangles are created.
|
||||
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
\see upDirection slopeLimit maxJumpHeight
|
||||
*/
|
||||
PxF32 invisibleWallHeight;
|
||||
|
||||
/**
|
||||
\brief Maximum height a jumping character can reach
|
||||
|
||||
This is only used if invisible walls are created ('invisibleWallHeight' is non zero).
|
||||
|
||||
When a character jumps, the non-walkable triangles he might fly over are not found
|
||||
by the collision queries (since the character's bounding volume does not touch them).
|
||||
Thus those non-walkable triangles do not create invisible walls, and it is possible
|
||||
for a jumping character to land on a non-walkable triangle, while he wouldn't have
|
||||
reached that place by just walking.
|
||||
|
||||
The 'maxJumpHeight' variable is used to extend the size of the collision volume
|
||||
downward. This way, all the non-walkable triangles are properly found by the collision
|
||||
queries and it becomes impossible to 'jump over' invisible walls.
|
||||
|
||||
If the character in your game can not jump, it is safe to use 0.0 here. Otherwise it
|
||||
is best to keep this value as small as possible, since a larger collision volume
|
||||
means more triangles to process.
|
||||
|
||||
<b>Default:</b> 0.0
|
||||
|
||||
\see upDirection slopeLimit invisibleWallHeight
|
||||
*/
|
||||
PxF32 maxJumpHeight;
|
||||
|
||||
/**
|
||||
\brief The contact offset used by the controller.
|
||||
|
||||
Specifies a skin around the object within which contacts will be generated.
|
||||
Use it to avoid numerical precision issues.
|
||||
|
||||
This is dependant on the scale of the users world, but should be a small, positive
|
||||
non zero value.
|
||||
|
||||
<b>Default:</b> 0.1
|
||||
*/
|
||||
PxF32 contactOffset;
|
||||
|
||||
/**
|
||||
\brief Defines the maximum height of an obstacle which the character can climb.
|
||||
|
||||
A small value will mean that the character gets stuck and cannot walk up stairs etc,
|
||||
a value which is too large will mean that the character can climb over unrealistically
|
||||
high obstacles.
|
||||
|
||||
<b>Default:</b> 0.5
|
||||
|
||||
\see upDirection
|
||||
*/
|
||||
PxF32 stepOffset;
|
||||
|
||||
/**
|
||||
\brief Density of underlying kinematic actor
|
||||
|
||||
The CCT creates a PhysX's kinematic actor under the hood. This controls its density.
|
||||
|
||||
<b>Default:</b> 10.0
|
||||
*/
|
||||
PxF32 density;
|
||||
|
||||
/**
|
||||
\brief Scale coefficient for underlying kinematic actor
|
||||
|
||||
The CCT creates a PhysX's kinematic actor under the hood. This controls its scale factor.
|
||||
This should be a number a bit smaller than 1.0.
|
||||
|
||||
This scale factor affects how the character interacts with dynamic rigid bodies around it (e.g. pushing them, etc).
|
||||
|
||||
With a scale factor < 1, the underlying kinematic actor will not touch surrounding rigid bodies - they will
|
||||
only interact with the character controller's shapes (capsules or boxes), and users will have full control
|
||||
over the interactions (i.e. they will have to push the objects with explicit forces themselves).
|
||||
|
||||
With a scale factor >=1, the underlying kinematic actor will touch and push surrounding rigid bodies based
|
||||
on PhysX's computations, as if there would be no character controller involved. This works fine except
|
||||
when you push objects into a wall. PhysX has no control over kinematic actors (since they are kinematic)
|
||||
so they would freely push dynamic objects into walls, and make them tunnel / explode / behave badly.
|
||||
|
||||
With a smaller kinematic actor however, the character controller's swept shape touches dynamic rigid bodies
|
||||
first, and can apply forces to them to move them away (or not, depending on what the gameplay needs).
|
||||
Meanwhile the character controller's swept shape itself is stopped by these dynamic bodies.
|
||||
|
||||
Setting the scale factor to 1 could still work, but it is unreliable. Depending on FPU accuracy you could
|
||||
end up with either the CCT's volume or the underlying kinematic actor touching the dynamic bodies first,
|
||||
and this could change from one moment to the next.
|
||||
|
||||
<b>Default:</b> 0.8
|
||||
*/
|
||||
PxF32 scaleCoeff;
|
||||
|
||||
/**
|
||||
\brief Cached volume growth
|
||||
|
||||
Amount of space around the controller we cache to improve performance. This is a scale factor
|
||||
that should be higher than 1.0f but not too big, ideally lower than 2.0f.
|
||||
|
||||
<b>Default:</b> 1.5
|
||||
*/
|
||||
PxF32 volumeGrowth;
|
||||
|
||||
/**
|
||||
\brief Specifies a user report callback.
|
||||
|
||||
This report callback is called when the character collides with shapes and other characters.
|
||||
|
||||
Setting this to NULL disables the callback.
|
||||
|
||||
<b>Default:</b> NULL
|
||||
|
||||
\see PxUserControllerHitReport
|
||||
*/
|
||||
PxUserControllerHitReport* reportCallback;
|
||||
|
||||
/**
|
||||
\brief Specifies a user behavior callback.
|
||||
|
||||
This behavior callback is called to customize the controller's behavior w.r.t. touched shapes.
|
||||
|
||||
Setting this to NULL disables the callback.
|
||||
|
||||
<b>Default:</b> NULL
|
||||
|
||||
\see PxControllerBehaviorCallback
|
||||
*/
|
||||
PxControllerBehaviorCallback* behaviorCallback;
|
||||
|
||||
/**
|
||||
\brief The non-walkable mode controls if a character controller slides or not on a non-walkable part.
|
||||
|
||||
This is only used when slopeLimit is non zero.
|
||||
|
||||
<b>Default:</b> PxControllerNonWalkableMode::ePREVENT_CLIMBING
|
||||
|
||||
\see PxControllerNonWalkableMode
|
||||
*/
|
||||
PxControllerNonWalkableMode::Enum nonWalkableMode;
|
||||
|
||||
/**
|
||||
\brief The material for the actor associated with the controller.
|
||||
|
||||
The controller internally creates a rigid body actor. This parameter specifies the material of the actor.
|
||||
|
||||
<b>Default:</b> NULL
|
||||
|
||||
\see PxMaterial
|
||||
*/
|
||||
PxMaterial* material;
|
||||
|
||||
/**
|
||||
\brief Use a deletion listener to get informed about released objects and clear internal caches if needed.
|
||||
|
||||
If a character controller registers a deletion listener, it will get informed about released objects. That allows the
|
||||
controller to invalidate cached data that connects to a released object. If a deletion listener is not
|
||||
registered, PxController::invalidateCache has to be called manually after objects have been released.
|
||||
|
||||
\see PxController::invalidateCache
|
||||
|
||||
<b>Default:</b> true
|
||||
*/
|
||||
bool registerDeletionListener;
|
||||
|
||||
/**
|
||||
\brief Client ID for associated actor.
|
||||
|
||||
\see PxClientID PxActor::setOwnerClient
|
||||
|
||||
<b>Default:</b> PX_DEFAULT_CLIENT
|
||||
*/
|
||||
PxClientID clientID;
|
||||
|
||||
/**
|
||||
\brief User specified data associated with the controller.
|
||||
|
||||
<b>Default:</b> NULL
|
||||
*/
|
||||
void* userData;
|
||||
|
||||
protected:
|
||||
const PxControllerShapeType::Enum mType; //!< The type of the controller. This gets set by the derived class' ctor, the user should not have to change it.
|
||||
|
||||
/**
|
||||
\brief constructor sets to default.
|
||||
*/
|
||||
PX_INLINE PxControllerDesc(PxControllerShapeType::Enum);
|
||||
PX_INLINE virtual ~PxControllerDesc();
|
||||
|
||||
/**
|
||||
\brief copy constructor.
|
||||
*/
|
||||
PX_INLINE PxControllerDesc(const PxControllerDesc&);
|
||||
|
||||
/**
|
||||
\brief assignment operator.
|
||||
*/
|
||||
PX_INLINE PxControllerDesc& operator=(const PxControllerDesc&);
|
||||
|
||||
PX_INLINE void copy(const PxControllerDesc&);
|
||||
};
|
||||
|
||||
PX_INLINE PxControllerDesc::PxControllerDesc(PxControllerShapeType::Enum t) :
|
||||
position (PxExtended(0.0), PxExtended(0.0), PxExtended(0.0)),
|
||||
upDirection (0.0f, 1.0f, 0.0f),
|
||||
slopeLimit (0.707f),
|
||||
invisibleWallHeight (0.0f),
|
||||
maxJumpHeight (0.0f),
|
||||
contactOffset (0.1f),
|
||||
stepOffset (0.5f),
|
||||
density (10.0f),
|
||||
scaleCoeff (0.8f),
|
||||
volumeGrowth (1.5f),
|
||||
reportCallback (NULL),
|
||||
behaviorCallback (NULL),
|
||||
nonWalkableMode (PxControllerNonWalkableMode::ePREVENT_CLIMBING),
|
||||
material (NULL),
|
||||
registerDeletionListener (true),
|
||||
clientID (PX_DEFAULT_CLIENT),
|
||||
userData (NULL),
|
||||
mType (t)
|
||||
{
|
||||
}
|
||||
|
||||
PX_INLINE PxControllerDesc::PxControllerDesc(const PxControllerDesc& other) : mType(other.mType)
|
||||
{
|
||||
copy(other);
|
||||
}
|
||||
|
||||
PX_INLINE PxControllerDesc& PxControllerDesc::operator=(const PxControllerDesc& other)
|
||||
{
|
||||
copy(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_INLINE void PxControllerDesc::copy(const PxControllerDesc& other)
|
||||
{
|
||||
upDirection = other.upDirection;
|
||||
slopeLimit = other.slopeLimit;
|
||||
contactOffset = other.contactOffset;
|
||||
stepOffset = other.stepOffset;
|
||||
density = other.density;
|
||||
scaleCoeff = other.scaleCoeff;
|
||||
volumeGrowth = other.volumeGrowth;
|
||||
reportCallback = other.reportCallback;
|
||||
behaviorCallback = other.behaviorCallback;
|
||||
userData = other.userData;
|
||||
nonWalkableMode = other.nonWalkableMode;
|
||||
position.x = other.position.x;
|
||||
position.y = other.position.y;
|
||||
position.z = other.position.z;
|
||||
material = other.material;
|
||||
invisibleWallHeight = other.invisibleWallHeight;
|
||||
maxJumpHeight = other.maxJumpHeight;
|
||||
registerDeletionListener = other.registerDeletionListener;
|
||||
clientID = other.clientID;
|
||||
}
|
||||
|
||||
PX_INLINE PxControllerDesc::~PxControllerDesc()
|
||||
{
|
||||
}
|
||||
|
||||
PX_INLINE bool PxControllerDesc::isValid() const
|
||||
{
|
||||
if( mType!=PxControllerShapeType::eBOX
|
||||
&& mType!=PxControllerShapeType::eCAPSULE)
|
||||
return false;
|
||||
if(scaleCoeff<0.0f)
|
||||
return false;
|
||||
if(volumeGrowth<1.0f)
|
||||
return false;
|
||||
if(density<0.0f)
|
||||
return false;
|
||||
if(slopeLimit<0.0f)
|
||||
return false;
|
||||
if(stepOffset<0.0f)
|
||||
return false;
|
||||
if(contactOffset<=0.0f)
|
||||
return false;
|
||||
if(!material)
|
||||
return false;
|
||||
if(!toVec3(position).isFinite())
|
||||
return false; //the float version needs to be finite otherwise actor creation will fail.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Base class for character controllers.
|
||||
|
||||
\see PxCapsuleController PxBoxController
|
||||
*/
|
||||
class PxController
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Return the type of controller
|
||||
|
||||
\see PxControllerType
|
||||
*/
|
||||
virtual PxControllerShapeType::Enum getType() const = 0;
|
||||
|
||||
/**
|
||||
\brief Releases the controller.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Moves the character using a "collide-and-slide" algorithm.
|
||||
|
||||
\param[in] disp Displacement vector
|
||||
\param[in] minDist The minimum travelled distance to consider. If travelled distance is smaller, the character doesn't move.
|
||||
This is used to stop the recursive motion algorithm when remaining distance to travel is small.
|
||||
\param[in] elapsedTime Time elapsed since last call
|
||||
\param[in] filters User-defined filters for this move
|
||||
\param[in] obstacles Potential additional obstacles the CCT should collide with.
|
||||
\return Collision flags, collection of ::PxControllerCollisionFlags
|
||||
*/
|
||||
virtual PxControllerCollisionFlags move(const PxVec3& disp, PxF32 minDist, PxF32 elapsedTime, const PxControllerFilters& filters, const PxObstacleContext* obstacles=NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Sets controller's position.
|
||||
|
||||
The position controlled by this function is the center of the collision shape.
|
||||
|
||||
\warning This is a 'teleport' function, it doesn't check for collisions.
|
||||
\warning The character's position must be such that it does not overlap the static geometry.
|
||||
|
||||
To move the character under normal conditions use the #move() function.
|
||||
|
||||
\param[in] position The new (center) positon for the controller.
|
||||
\return Currently always returns true.
|
||||
|
||||
\see PxControllerDesc.position getPosition() getFootPosition() setFootPosition() move()
|
||||
*/
|
||||
virtual bool setPosition(const PxExtendedVec3& position) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the raw position of the controller.
|
||||
|
||||
The position retrieved by this function is the center of the collision shape. To retrieve the bottom position of the shape,
|
||||
a.k.a. the foot position, use the getFootPosition() function.
|
||||
|
||||
The position is updated by calls to move(). Calling this method without calling
|
||||
move() will return the last position or the initial position of the controller.
|
||||
|
||||
\return The controller's center position
|
||||
|
||||
\see PxControllerDesc.position setPosition() getFootPosition() setFootPosition() move()
|
||||
*/
|
||||
virtual const PxExtendedVec3& getPosition() const = 0;
|
||||
|
||||
/**
|
||||
\brief Set controller's foot position.
|
||||
|
||||
The position controlled by this function is the bottom of the collision shape, a.k.a. the foot position.
|
||||
|
||||
\note The foot position takes the contact offset into account
|
||||
|
||||
\warning This is a 'teleport' function, it doesn't check for collisions.
|
||||
|
||||
To move the character under normal conditions use the #move() function.
|
||||
|
||||
\param[in] position The new (bottom) positon for the controller.
|
||||
\return Currently always returns true.
|
||||
|
||||
\see PxControllerDesc.position setPosition() getPosition() getFootPosition() move()
|
||||
*/
|
||||
virtual bool setFootPosition(const PxExtendedVec3& position) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the "foot" position of the controller, i.e. the position of the bottom of the CCT's shape.
|
||||
|
||||
\note The foot position takes the contact offset into account
|
||||
|
||||
\return The controller's foot position
|
||||
|
||||
\see PxControllerDesc.position setPosition() getPosition() setFootPosition() move()
|
||||
*/
|
||||
virtual PxExtendedVec3 getFootPosition() const = 0;
|
||||
|
||||
/**
|
||||
\brief Get the rigid body actor associated with this controller (see PhysX documentation).
|
||||
The behavior upon manually altering this actor is undefined, you should primarily
|
||||
use it for reading const properties.
|
||||
|
||||
\return the actor associated with the controller.
|
||||
*/
|
||||
virtual PxRigidDynamic* getActor() const = 0;
|
||||
|
||||
/**
|
||||
\brief The step height.
|
||||
|
||||
\param[in] offset The new step offset for the controller.
|
||||
|
||||
\see PxControllerDesc.stepOffset
|
||||
*/
|
||||
virtual void setStepOffset(const PxF32 offset) =0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the step height.
|
||||
|
||||
\return The step offset for the controller.
|
||||
|
||||
\see setStepOffset()
|
||||
*/
|
||||
virtual PxF32 getStepOffset() const =0;
|
||||
|
||||
/**
|
||||
\brief Sets the non-walkable mode for the CCT.
|
||||
|
||||
\param[in] flag The new value of the non-walkable mode.
|
||||
|
||||
\see PxControllerNonWalkableMode
|
||||
*/
|
||||
virtual void setNonWalkableMode(PxControllerNonWalkableMode::Enum flag) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the non-walkable mode for the CCT.
|
||||
|
||||
\return The current non-walkable mode.
|
||||
|
||||
\see PxControllerNonWalkableMode
|
||||
*/
|
||||
virtual PxControllerNonWalkableMode::Enum getNonWalkableMode() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the contact offset.
|
||||
|
||||
\return The contact offset for the controller.
|
||||
|
||||
\see PxControllerDesc.contactOffset
|
||||
*/
|
||||
virtual PxF32 getContactOffset() const =0;
|
||||
|
||||
/**
|
||||
\brief Sets the contact offset.
|
||||
|
||||
\param[in] offset The contact offset for the controller.
|
||||
|
||||
\see PxControllerDesc.contactOffset
|
||||
*/
|
||||
virtual void setContactOffset(PxF32 offset) =0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the 'up' direction.
|
||||
|
||||
\return The up direction for the controller.
|
||||
|
||||
\see PxControllerDesc.upDirection
|
||||
*/
|
||||
virtual PxVec3 getUpDirection() const =0;
|
||||
|
||||
/**
|
||||
\brief Sets the 'up' direction.
|
||||
|
||||
\param[in] up The up direction for the controller.
|
||||
|
||||
\see PxControllerDesc.upDirection
|
||||
*/
|
||||
virtual void setUpDirection(const PxVec3& up) =0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the slope limit.
|
||||
|
||||
\return The slope limit for the controller.
|
||||
|
||||
\see PxControllerDesc.slopeLimit
|
||||
*/
|
||||
virtual PxF32 getSlopeLimit() const =0;
|
||||
|
||||
/**
|
||||
\brief Sets the slope limit.
|
||||
|
||||
\note This feature can not be enabled at runtime, i.e. if the slope limit is zero when creating the CCT
|
||||
(which disables the feature) then changing the slope limit at runtime will not have any effect, and the call
|
||||
will be ignored.
|
||||
|
||||
\param[in] slopeLimit The slope limit for the controller.
|
||||
|
||||
\see PxControllerDesc.slopeLimit
|
||||
*/
|
||||
virtual void setSlopeLimit(PxF32 slopeLimit) =0;
|
||||
|
||||
/**
|
||||
\brief Flushes internal geometry cache.
|
||||
|
||||
The character controller uses caching in order to speed up collision testing. The cache is
|
||||
automatically flushed when a change to static objects is detected in the scene. For example when a
|
||||
static shape is added, updated, or removed from the scene, the cache is automatically invalidated.
|
||||
|
||||
However there may be situations that cannot be automatically detected, and those require manual
|
||||
invalidation of the cache. Currently the user must call this when the filtering behavior changes (the
|
||||
PxControllerFilters parameter of the PxController::move call). While the controller in principle
|
||||
could detect a change in these parameters, it cannot detect a change in the behavior of the filtering
|
||||
function.
|
||||
|
||||
\see PxController.move
|
||||
*/
|
||||
virtual void invalidateCache() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve the scene associated with the controller.
|
||||
|
||||
\return The physics scene
|
||||
*/
|
||||
virtual PxScene* getScene() = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the user data associated with this controller.
|
||||
|
||||
\return The user pointer associated with the controller.
|
||||
|
||||
\see PxControllerDesc.userData
|
||||
*/
|
||||
virtual void* getUserData() const = 0;
|
||||
|
||||
/**
|
||||
\brief Sets the user data associated with this controller.
|
||||
|
||||
\param[in] userData The user pointer associated with the controller.
|
||||
|
||||
\see PxControllerDesc.userData
|
||||
*/
|
||||
virtual void setUserData(void* userData) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns information about the controller's internal state.
|
||||
|
||||
\param[out] state The controller's internal state
|
||||
|
||||
\see PxControllerState
|
||||
*/
|
||||
virtual void getState(PxControllerState& state) const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the controller's internal statistics.
|
||||
|
||||
\param[out] stats The controller's internal statistics
|
||||
|
||||
\see PxControllerStats
|
||||
*/
|
||||
virtual void getStats(PxControllerStats& stats) const = 0;
|
||||
|
||||
/**
|
||||
\brief Resizes the controller.
|
||||
|
||||
This function attempts to resize the controller to a given size, while making sure the bottom
|
||||
position of the controller remains constant. In other words the function modifies both the
|
||||
height and the (center) position of the controller. This is a helper function that can be used
|
||||
to implement a 'crouch' functionality for example.
|
||||
|
||||
\param[in] height Desired controller's height
|
||||
*/
|
||||
virtual void resize(PxReal height) = 0;
|
||||
|
||||
protected:
|
||||
PX_INLINE PxController() {}
|
||||
virtual ~PxController() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
125
engine/third_party/physx/include/characterkinematic/PxControllerBehavior.h
vendored
Normal file
125
engine/third_party/physx/include/characterkinematic/PxControllerBehavior.h
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONTROLLER_BEHAVIOR_H
|
||||
#define PX_CONTROLLER_BEHAVIOR_H
|
||||
|
||||
#include "PxFiltering.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxShape;
|
||||
class PxObstacle;
|
||||
class PxController;
|
||||
|
||||
/**
|
||||
\brief specifies controller behavior
|
||||
*/
|
||||
struct PxControllerBehaviorFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eCCT_CAN_RIDE_ON_OBJECT = (1<<0), //!< Controller can ride on touched object (i.e. when this touched object is moving horizontally). \note The CCT vs. CCT case is not supported.
|
||||
eCCT_SLIDE = (1<<1), //!< Controller should slide on touched object
|
||||
eCCT_USER_DEFINED_RIDE = (1<<2) //!< Disable all code dealing with controllers riding on objects, let users define it outside of the SDK.
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Bitfield that contains a set of raised flags defined in PxControllerBehaviorFlag.
|
||||
|
||||
\see PxControllerBehaviorFlag
|
||||
*/
|
||||
typedef PxFlags<PxControllerBehaviorFlag::Enum, PxU8> PxControllerBehaviorFlags;
|
||||
PX_FLAGS_OPERATORS(PxControllerBehaviorFlag::Enum, PxU8)
|
||||
|
||||
/**
|
||||
\brief User behavior callback.
|
||||
|
||||
This behavior callback is called to customize the controller's behavior w.r.t. touched shapes.
|
||||
*/
|
||||
class PxControllerBehaviorCallback
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Retrieve behavior flags for a shape.
|
||||
|
||||
When the CCT touches a shape, the CCT's behavior w.r.t. this shape can be customized by users.
|
||||
This function retrieves the desired PxControllerBehaviorFlag flags capturing the desired behavior.
|
||||
|
||||
\param[in] shape The shape the CCT is currently touching
|
||||
\param[in] actor The actor owning the shape
|
||||
|
||||
\return Desired behavior flags for the given shape
|
||||
|
||||
\see PxControllerBehaviorFlag
|
||||
*/
|
||||
virtual PxControllerBehaviorFlags getBehaviorFlags(const PxShape& shape, const PxActor& actor) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve behavior flags for a controller.
|
||||
|
||||
When the CCT touches a controller, the CCT's behavior w.r.t. this controller can be customized by users.
|
||||
This function retrieves the desired PxControllerBehaviorFlag flags capturing the desired behavior.
|
||||
|
||||
\note The flag PxControllerBehaviorFlag::eCCT_CAN_RIDE_ON_OBJECT is not supported.
|
||||
|
||||
\param[in] controller The controller the CCT is currently touching
|
||||
|
||||
\return Desired behavior flags for the given controller
|
||||
|
||||
\see PxControllerBehaviorFlag
|
||||
*/
|
||||
virtual PxControllerBehaviorFlags getBehaviorFlags(const PxController& controller) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve behavior flags for an obstacle.
|
||||
|
||||
When the CCT touches an obstacle, the CCT's behavior w.r.t. this obstacle can be customized by users.
|
||||
This function retrieves the desired PxControllerBehaviorFlag flags capturing the desired behavior.
|
||||
|
||||
\param[in] obstacle The obstacle the CCT is currently touching
|
||||
|
||||
\return Desired behavior flags for the given obstacle
|
||||
|
||||
\see PxControllerBehaviorFlag
|
||||
*/
|
||||
virtual PxControllerBehaviorFlags getBehaviorFlags(const PxObstacle& obstacle) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PxControllerBehaviorCallback(){}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
296
engine/third_party/physx/include/characterkinematic/PxControllerManager.h
vendored
Normal file
296
engine/third_party/physx/include/characterkinematic/PxControllerManager.h
vendored
Normal file
@@ -0,0 +1,296 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONTROLLER_MANAGER_H
|
||||
#define PX_CONTROLLER_MANAGER_H
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxFlags.h"
|
||||
#include "foundation/PxErrorCallback.h"
|
||||
#include "common/PxRenderBuffer.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxPhysics;
|
||||
class PxScene;
|
||||
class PxController;
|
||||
class PxControllerDesc;
|
||||
class PxObstacleContext;
|
||||
class PxControllerFilterCallback;
|
||||
|
||||
/**
|
||||
\brief specifies debug-rendering flags
|
||||
*/
|
||||
struct PxControllerDebugRenderFlag
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eTEMPORAL_BV = (1<<0), //!< Temporal bounding volume around controllers
|
||||
eCACHED_BV = (1<<1), //!< Cached bounding volume around controllers
|
||||
eOBSTACLES = (1<<2), //!< User-defined obstacles
|
||||
|
||||
eNONE = 0,
|
||||
eALL = 0xffffffff
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Bitfield that contains a set of raised flags defined in PxControllerDebugRenderFlag.
|
||||
|
||||
\see PxControllerDebugRenderFlag
|
||||
*/
|
||||
typedef PxFlags<PxControllerDebugRenderFlag::Enum, PxU32> PxControllerDebugRenderFlags;
|
||||
PX_FLAGS_OPERATORS(PxControllerDebugRenderFlag::Enum, PxU32)
|
||||
|
||||
|
||||
/**
|
||||
\brief Manages an array of character controllers.
|
||||
|
||||
\see PxController PxBoxController PxCapsuleController
|
||||
*/
|
||||
class PxControllerManager
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Releases the controller manager.
|
||||
|
||||
\note This will release all associated controllers and obstacle contexts.
|
||||
|
||||
\note This function is required to be called to release foundation usage.
|
||||
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the scene the manager is adding the controllers to.
|
||||
|
||||
\return The associated physics scene.
|
||||
*/
|
||||
virtual PxScene& getScene() const = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of controllers that are being managed.
|
||||
|
||||
\return The number of controllers.
|
||||
*/
|
||||
virtual PxU32 getNbControllers() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve one of the controllers in the manager.
|
||||
|
||||
\param index the index of the controller to return
|
||||
\return The controller with the specified index.
|
||||
*/
|
||||
virtual PxController* getController(PxU32 index) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates a new character controller.
|
||||
|
||||
\param[in] desc The controllers descriptor
|
||||
\return The new controller
|
||||
|
||||
\see PxController PxController.release() PxControllerDesc
|
||||
*/
|
||||
virtual PxController* createController(const PxControllerDesc& desc) = 0;
|
||||
|
||||
/**
|
||||
\brief Releases all the controllers that are being managed.
|
||||
*/
|
||||
virtual void purgeControllers() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves debug data.
|
||||
|
||||
\return The render buffer filled with debug-render data
|
||||
|
||||
\see PxControllerManager.setDebugRenderingFlags()
|
||||
*/
|
||||
virtual PxRenderBuffer& getRenderBuffer() = 0;
|
||||
|
||||
/**
|
||||
\brief Sets debug rendering flags
|
||||
|
||||
\param[in] flags The debug rendering flags (combination of PxControllerDebugRenderFlags)
|
||||
|
||||
\see PxControllerManager.getRenderBuffer() PxControllerDebugRenderFlags
|
||||
*/
|
||||
virtual void setDebugRenderingFlags(PxControllerDebugRenderFlags flags) = 0;
|
||||
|
||||
/**
|
||||
\brief Returns the number of obstacle contexts that are being managed.
|
||||
|
||||
\return The number of obstacle contexts.
|
||||
*/
|
||||
virtual PxU32 getNbObstacleContexts() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieve one of the obstacle contexts in the manager.
|
||||
|
||||
\param index The index of the obstacle context to retrieve.
|
||||
\return The obstacle context with the specified index.
|
||||
*/
|
||||
virtual PxObstacleContext* getObstacleContext(PxU32 index) = 0;
|
||||
|
||||
/**
|
||||
\brief Creates an obstacle context.
|
||||
|
||||
\return New obstacle context
|
||||
|
||||
\see PxObstacleContext
|
||||
*/
|
||||
virtual PxObstacleContext* createObstacleContext() = 0;
|
||||
|
||||
/**
|
||||
\brief Computes character-character interactions.
|
||||
|
||||
This function is an optional helper to properly resolve interactions between characters, in case they overlap (which can happen for gameplay reasons, etc).
|
||||
|
||||
You should call this once per frame, before your PxController::move() calls. The function will not move the characters directly, but it will
|
||||
compute overlap information for each character that will be used in the next move() call.
|
||||
|
||||
You need to provide a proper time value here so that interactions are resolved in a way that do not depend on the framerate.
|
||||
|
||||
If you only have one character in the scene, or if you can guarantee your characters will never overlap, then you do not need to call this function.
|
||||
|
||||
\note Releasing the manager will automatically release all the associated obstacle contexts.
|
||||
|
||||
\param[in] elapsedTime Elapsed time since last call
|
||||
\param[in] cctFilterCb Filtering callback for CCT-vs-CCT interactions
|
||||
*/
|
||||
virtual void computeInteractions(PxF32 elapsedTime, PxControllerFilterCallback* cctFilterCb=NULL) = 0;
|
||||
|
||||
/**
|
||||
\brief Enables or disables runtime tessellation.
|
||||
|
||||
Large triangles can create accuracy issues in the sweep code, which in turn can lead to characters not sliding smoothly
|
||||
against geometries, or even penetrating them. This feature allows one to reduce those issues by tessellating large
|
||||
triangles at runtime, before performing sweeps against them. The amount of tessellation is controlled by the 'maxEdgeLength' parameter.
|
||||
Any triangle with at least one edge length greater than the maxEdgeLength will get recursively tessellated, until resulting triangles are small enough.
|
||||
|
||||
This features only applies to triangle meshes, convex meshes, heightfields and boxes.
|
||||
|
||||
\param[in] flag True/false to enable/disable runtime tessellation.
|
||||
\param[in] maxEdgeLength Max edge length allowed before tessellation kicks in.
|
||||
*/
|
||||
virtual void setTessellation(bool flag, float maxEdgeLength) = 0;
|
||||
|
||||
/**
|
||||
\brief Enables or disables the overlap recovery module.
|
||||
|
||||
The overlap recovery module can be used to depenetrate CCTs from static objects when an overlap is detected. This can happen
|
||||
in three main cases:
|
||||
- when the CCT is directly spawned or teleported in another object
|
||||
- when the CCT algorithm fails due to limited FPU accuracy
|
||||
- when the "up vector" is modified, making the rotated CCT shape overlap surrounding objects
|
||||
|
||||
When activated, the CCT module will automatically try to resolve the penetration, and move the CCT to a safe place where it does
|
||||
not overlap other objects anymore. This only concerns static objects, dynamic objects are ignored by the recovery module.
|
||||
|
||||
When the recovery module is not activated, it is possible for the CCTs to go through static objects. By default, the recovery
|
||||
module is enabled.
|
||||
|
||||
The recovery module currently works with all geometries except heightfields.
|
||||
|
||||
\param[in] flag True/false to enable/disable overlap recovery module.
|
||||
*/
|
||||
virtual void setOverlapRecoveryModule(bool flag) = 0;
|
||||
|
||||
/**
|
||||
\brief Enables or disables the precise sweeps.
|
||||
|
||||
Precise sweeps are more accurate, but also potentially slower than regular sweeps.
|
||||
|
||||
By default, precise sweeps are enabled.
|
||||
|
||||
\param[in] flag True/false to enable/disable precise sweeps.
|
||||
*/
|
||||
virtual void setPreciseSweeps(bool flag) = 0;
|
||||
|
||||
/**
|
||||
\brief Enables or disables vertical sliding against ceilings.
|
||||
|
||||
Geometry is seen as "ceilings" when the following condition is met:
|
||||
|
||||
dot product(contact normal, up direction)<0.0f
|
||||
|
||||
This flag controls whether characters should slide vertically along the geometry in that case.
|
||||
|
||||
By default, sliding is allowed.
|
||||
|
||||
\param[in] flag True/false to enable/disable sliding.
|
||||
*/
|
||||
virtual void setPreventVerticalSlidingAgainstCeiling(bool flag) = 0;
|
||||
|
||||
/**
|
||||
\brief Shift the origin of the character controllers and obstacle objects by the specified vector.
|
||||
|
||||
The positions of all character controllers, obstacle objects and the corresponding data structures will get adjusted to reflect the shifted origin location
|
||||
(the shift vector will get subtracted from all character controller and obstacle object positions).
|
||||
|
||||
\note It is the user's responsibility to keep track of the summed total origin shift and adjust all input/output to/from PhysXCharacterKinematic accordingly.
|
||||
|
||||
\note This call will not automatically shift the PhysX scene and its objects. You need to call PxScene::shiftOrigin() separately to keep the systems in sync.
|
||||
|
||||
\param[in] shift Translation vector to shift the origin by.
|
||||
*/
|
||||
virtual void shiftOrigin(const PxVec3& shift) = 0;
|
||||
|
||||
protected:
|
||||
PxControllerManager() {}
|
||||
virtual ~PxControllerManager() {}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Creates the controller manager.
|
||||
|
||||
\param[in] scene PhysX scene. You can only create one PxControllerManager per scene.
|
||||
\param[in] lockingEnabled Enables/disables internal locking.
|
||||
|
||||
\return New controller manager, or NULL in case of failure (e.g. when a manager has already been created for that scene)
|
||||
|
||||
The character controller is informed by #PxDeletionListener::onRelease() when actors or shapes are released, and updates its internal
|
||||
caches accordingly. If character controller movement or a call to #PxControllerManager::shiftOrigin() may overlap with actor/shape releases,
|
||||
internal data structures must be guarded against concurrent access.
|
||||
|
||||
Locking guarantees thread safety in such scenarios.
|
||||
|
||||
\note locking may result in significant slowdown for release of actors or shapes.
|
||||
|
||||
By default, locking is disabled.
|
||||
*/
|
||||
PX_C_EXPORT physx::PxControllerManager* PX_CALL_CONV PxCreateControllerManager(physx::PxScene& scene, bool lockingEnabled = false);
|
||||
|
||||
#endif
|
||||
|
||||
186
engine/third_party/physx/include/characterkinematic/PxControllerObstacles.h
vendored
Normal file
186
engine/third_party/physx/include/characterkinematic/PxControllerObstacles.h
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_CONTROLLER_OBSTACLES_H
|
||||
#define PX_CONTROLLER_OBSTACLES_H
|
||||
|
||||
#include "characterkinematic/PxExtended.h"
|
||||
#include "geometry/PxGeometry.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxControllerManager;
|
||||
|
||||
#define PX_INVALID_OBSTACLE_HANDLE 0xffffffff
|
||||
|
||||
/**
|
||||
\brief Base class for obstacles.
|
||||
|
||||
\see PxBoxObstacle PxCapsuleObstacle PxObstacleContext
|
||||
*/
|
||||
class PxObstacle
|
||||
{
|
||||
protected:
|
||||
PxObstacle() :
|
||||
mType (PxGeometryType::eINVALID),
|
||||
mUserData (NULL),
|
||||
mPos (0.0, 0.0, 0.0),
|
||||
mRot (PxQuat(PxIdentity))
|
||||
{}
|
||||
|
||||
PxGeometryType::Enum mType;
|
||||
public:
|
||||
|
||||
PX_FORCE_INLINE PxGeometryType::Enum getType() const { return mType; }
|
||||
|
||||
void* mUserData;
|
||||
PxExtendedVec3 mPos;
|
||||
PxQuat mRot;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A box obstacle.
|
||||
|
||||
\see PxObstacle PxCapsuleObstacle PxObstacleContext
|
||||
*/
|
||||
class PxBoxObstacle : public PxObstacle
|
||||
{
|
||||
public:
|
||||
PxBoxObstacle() :
|
||||
mHalfExtents(0.0f)
|
||||
{ mType = PxGeometryType::eBOX; }
|
||||
|
||||
PxVec3 mHalfExtents;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A capsule obstacle.
|
||||
|
||||
\see PxBoxObstacle PxObstacle PxObstacleContext
|
||||
*/
|
||||
class PxCapsuleObstacle : public PxObstacle
|
||||
{
|
||||
public:
|
||||
PxCapsuleObstacle() :
|
||||
mHalfHeight (0.0f),
|
||||
mRadius (0.0f)
|
||||
{ mType = PxGeometryType::eCAPSULE; }
|
||||
|
||||
PxReal mHalfHeight;
|
||||
PxReal mRadius;
|
||||
};
|
||||
|
||||
typedef PxU32 PxObstacleHandle;
|
||||
|
||||
/**
|
||||
\brief Context class for obstacles.
|
||||
|
||||
An obstacle context class contains and manages a set of user-defined obstacles.
|
||||
|
||||
\see PxBoxObstacle PxCapsuleObstacle PxObstacle
|
||||
*/
|
||||
class PxObstacleContext
|
||||
{
|
||||
public:
|
||||
PxObstacleContext() {}
|
||||
virtual ~PxObstacleContext() {}
|
||||
|
||||
/**
|
||||
\brief Releases the context.
|
||||
*/
|
||||
virtual void release() = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves the controller manager associated with this context.
|
||||
|
||||
\return The associated controller manager
|
||||
*/
|
||||
virtual PxControllerManager& getControllerManager() const = 0;
|
||||
|
||||
/**
|
||||
\brief Adds an obstacle to the context.
|
||||
|
||||
\param [in] obstacle Obstacle data for the new obstacle. The data gets copied.
|
||||
|
||||
\return Handle for newly-added obstacle
|
||||
*/
|
||||
virtual PxObstacleHandle addObstacle(const PxObstacle& obstacle) = 0;
|
||||
|
||||
/**
|
||||
\brief Removes an obstacle from the context.
|
||||
|
||||
\param [in] handle Handle for the obstacle object that needs to be removed.
|
||||
|
||||
\return True if success
|
||||
*/
|
||||
virtual bool removeObstacle(PxObstacleHandle handle) = 0;
|
||||
|
||||
/**
|
||||
\brief Updates data for an existing obstacle.
|
||||
|
||||
\param [in] handle Handle for the obstacle object that needs to be updated.
|
||||
\param [in] obstacle New obstacle data
|
||||
|
||||
\return True if success
|
||||
*/
|
||||
virtual bool updateObstacle(PxObstacleHandle handle, const PxObstacle& obstacle) = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves number of obstacles in the context.
|
||||
|
||||
\return Number of obstacles in the context
|
||||
*/
|
||||
virtual PxU32 getNbObstacles() const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves desired obstacle.
|
||||
|
||||
\param [in] i Obstacle index
|
||||
|
||||
\return Desired obstacle
|
||||
*/
|
||||
virtual const PxObstacle* getObstacle(PxU32 i) const = 0;
|
||||
|
||||
/**
|
||||
\brief Retrieves desired obstacle by given handle.
|
||||
|
||||
\param [in] handle Obstacle handle
|
||||
|
||||
\return Desired obstacle
|
||||
*/
|
||||
virtual const PxObstacle* getObstacleByHandle(PxObstacleHandle handle) const = 0;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
82
engine/third_party/physx/include/characterkinematic/PxExtended.h
vendored
Normal file
82
engine/third_party/physx/include/characterkinematic/PxExtended.h
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_EXTENDED_H
|
||||
#define PX_EXTENDED_H
|
||||
|
||||
// This needs to be included in Foundation just for the debug renderer
|
||||
|
||||
#include "PxPhysXConfig.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxAssert.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
// This has to be done here since it also changes the top-level "Px" and "Np" APIs
|
||||
#define PX_BIG_WORLDS
|
||||
|
||||
#ifdef PX_BIG_WORLDS
|
||||
typedef PxVec3d PxExtendedVec3;
|
||||
typedef double PxExtended;
|
||||
#define PX_MAX_EXTENDED PX_MAX_F64
|
||||
|
||||
PX_FORCE_INLINE PxVec3 toVec3(const PxExtendedVec3& v)
|
||||
{
|
||||
return PxVec3(float(v.x), float(v.y), float(v.z));
|
||||
}
|
||||
|
||||
// Computes the single-precision difference between two extended-precision points
|
||||
PX_INLINE PxVec3 diff(const PxExtendedVec3& p1, const PxExtendedVec3& p0)
|
||||
{
|
||||
return PxVec3(float(p1.x - p0.x), float(p1.y - p0.y), float(p1.z - p0.z));
|
||||
}
|
||||
#else
|
||||
typedef PxVec3 PxExtendedVec3;
|
||||
typedef float PxExtended;
|
||||
#define PX_MAX_EXTENDED PX_MAX_F32
|
||||
|
||||
PX_FORCE_INLINE PxVec3 toVec3(const PxExtendedVec3& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
// Computes the single-precision difference between two extended-precision points
|
||||
PX_INLINE PxVec3 diff(const PxExtendedVec3& p1, const PxExtendedVec3& p0)
|
||||
{
|
||||
return p1 - p0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user