PxCapsuleController
Defined in include/characterkinematic/PxCapsuleController.h
-
class PxCapsuleController : public PxController
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)
h = height
r = radiusp = center of capsule
top sphere center = p.y + h*0.5
bottom sphere center = p.y - h*0.5
top capsule point = p.y + h*0.5 + r
bottom capsule point = p.y - h*0.5 - rPublic Functions
-
virtual PxF32 getRadius() const = 0
Gets controller’s radius.
See also
PxCapsuleControllerDesc.radius setRadius()
- Returns
The radius of the controller.
-
virtual bool setRadius(PxF32 radius) = 0
Sets controller’s radius.
See also
PxCapsuleControllerDesc.radius getRadius()
Warning
this doesn’t check for collisions.
- Parameters
radius – [in] The new radius for the controller.
- Returns
Currently always true.
-
virtual PxF32 getHeight() const = 0
Gets controller’s height.
See also
PxCapsuleControllerDesc.height setHeight()
- Returns
The height of the capsule controller.
-
virtual bool setHeight(PxF32 height) = 0
Resets controller’s height.
See also
PxCapsuleControllerDesc.height getHeight()
Warning
this doesn’t check for collisions.
- Parameters
height – [in] The new height for the controller.
- Returns
Currently always true.
-
virtual PxCapsuleClimbingMode::Enum getClimbingMode() const = 0
Gets controller’s climbing mode.
See also
PxCapsuleControllerDesc.climbingMode setClimbingMode()
- Returns
The capsule controller’s climbing mode.
-
virtual bool setClimbingMode(PxCapsuleClimbingMode::Enum mode) = 0
Sets controller’s climbing mode.
See also
PxCapsuleControllerDesc.climbingMode getClimbingMode()
- Parameters
mode – [in] The capsule controller’s climbing mode.
-
virtual PxControllerShapeType::Enum getType() const = 0
Return the type of controller.
See also
PxControllerType
-
virtual void release() = 0
Releases the controller.
-
virtual PxControllerCollisionFlags move(const PxVec3 &disp, PxF32 minDist, PxF32 elapsedTime, const PxControllerFilters &filters, const PxObstacleContext *obstacles = NULL) = 0
Moves the character using a “collide-and-slide” algorithm.
- Parameters
disp – [in] Displacement vector
minDist – [in] 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.
elapsedTime – [in] Time elapsed since last call
filters – [in] User-defined filters for this move
obstacles – [in] Potential additional obstacles the CCT should collide with.
- Returns
Collision flags, collection of PxControllerCollisionFlags
-
virtual bool setPosition(const PxExtendedVec3 &position) = 0
Sets controller’s position.
The position controlled by this function is the center of the collision shape.
To move the character under normal conditions use the move() function.
See also
PxControllerDesc.position getPosition() getFootPosition() setFootPosition() move()
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.
- Parameters
position – [in] The new (center) positon for the controller.
- Returns
Currently always returns true.
-
virtual const PxExtendedVec3 &getPosition() const = 0
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.
See also
PxControllerDesc.position setPosition() getFootPosition() setFootPosition() move()
- Returns
The controller’s center position
-
virtual bool setFootPosition(const PxExtendedVec3 &position) = 0
Set controller’s foot position.
The position controlled by this function is the bottom of the collision shape, a.k.a. the foot position.
To move the character under normal conditions use the move() function.
See also
PxControllerDesc.position setPosition() getPosition() getFootPosition() move()
Note
The foot position takes the contact offset into account
Warning
This is a ‘teleport’ function, it doesn’t check for collisions.
- Parameters
position – [in] The new (bottom) positon for the controller.
- Returns
Currently always returns true.
-
virtual PxExtendedVec3 getFootPosition() const = 0
Retrieve the “foot” position of the controller, i.e.
the position of the bottom of the CCT’s shape.
See also
PxControllerDesc.position setPosition() getPosition() setFootPosition() move()
Note
The foot position takes the contact offset into account
- Returns
The controller’s foot position
-
virtual PxRigidDynamic *getActor() const = 0
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.
- Returns
the actor associated with the controller.
-
virtual void setStepOffset(const PxF32 offset) = 0
The step height.
See also
PxControllerDesc.stepOffset
- Parameters
offset – [in] The new step offset for the controller.
-
virtual PxF32 getStepOffset() const = 0
Retrieve the step height.
See also
setStepOffset()
- Returns
The step offset for the controller.
-
virtual void setNonWalkableMode(PxControllerNonWalkableMode::Enum flag) = 0
Sets the non-walkable mode for the CCT.
See also
PxControllerNonWalkableMode
- Parameters
flag – [in] The new value of the non-walkable mode.
-
virtual PxControllerNonWalkableMode::Enum getNonWalkableMode() const = 0
Retrieves the non-walkable mode for the CCT.
See also
PxControllerNonWalkableMode
- Returns
The current non-walkable mode.
-
virtual PxF32 getContactOffset() const = 0
Retrieve the contact offset.
See also
PxControllerDesc.contactOffset
- Returns
The contact offset for the controller.
-
virtual void setContactOffset(PxF32 offset) = 0
Sets the contact offset.
See also
PxControllerDesc.contactOffset
- Parameters
offset – [in] The contact offset for the controller.
-
virtual PxVec3 getUpDirection() const = 0
Retrieve the ‘up’ direction.
See also
PxControllerDesc.upDirection
- Returns
The up direction for the controller.
-
virtual void setUpDirection(const PxVec3 &up) = 0
Sets the ‘up’ direction.
See also
PxControllerDesc.upDirection
- Parameters
up – [in] The up direction for the controller.
-
virtual PxF32 getSlopeLimit() const = 0
Retrieve the slope limit.
See also
PxControllerDesc.slopeLimit
- Returns
The slope limit for the controller.
-
virtual void setSlopeLimit(PxF32 slopeLimit) = 0
Sets the slope limit.
See also
PxControllerDesc.slopeLimit
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.
- Parameters
slopeLimit – [in] The slope limit for the controller.
-
virtual void invalidateCache() = 0
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 also
PxController.move
-
virtual PxScene *getScene() = 0
Retrieve the scene associated with the controller.
- Returns
The physics scene
-
virtual void *getUserData() const = 0
Returns the user data associated with this controller.
See also
PxControllerDesc.userData
- Returns
The user pointer associated with the controller.
-
virtual void setUserData(void *userData) = 0
Sets the user data associated with this controller.
See also
PxControllerDesc.userData
- Parameters
userData – [in] The user pointer associated with the controller.
-
virtual void getState(PxControllerState &state) const = 0
Returns information about the controller’s internal state.
See also
PxControllerState
- Parameters
state – [out] The controller’s internal state
-
virtual void getStats(PxControllerStats &stats) const = 0
Returns the controller’s internal statistics.
See also
PxControllerStats
- Parameters
stats – [out] The controller’s internal statistics
-
virtual void resize(PxReal height) = 0
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.
- Parameters
height – [in] Desired controller’s height
-
virtual PxF32 getRadius() const = 0