PxCustomGeometry

Defined in include/geometry/PxCustomGeometry.h

Structs

  • Callbacks: Custom geometry callbacks structure.

  • Type: The type of a custom geometry.

class PxCustomGeometry : public PxGeometry

Custom geometry class.

This class allows user to create custom geometries by providing a set of virtual callback functions.

Public Functions

inline PxCustomGeometry()

Default constructor.

Creates an empty object with a NULL callbacks pointer.

inline PxCustomGeometry(Callbacks &_callbacks)

Constructor.

inline PxCustomGeometry(const PxCustomGeometry &that)

Copy constructor.

Parameters

that[in] Other object

inline void operator=(const PxCustomGeometry &that)

Assignment operator.

inline bool isValid() const

Returns true if the geometry is valid.

See also

PxRigidActor::createShape, PxPhysics::createShape

Returns

True if the current settings are valid for shape creation.

inline Type getCustomType() const

Returns the custom type of the custom geometry.

inline PxGeometryType::Enum getType() const

Returns the type of the geometry.

Returns

The type of the object.

Public Members

Callbacks *callbacks

A reference to the callbacks object.

float mTypePadding

Public Static Functions

static PxU32 getUniqueID()

For internal use.

Protected Attributes

PxGeometryType::Enum mType
struct Callbacks

Custom geometry callbacks structure.

User should inherit this and implement all pure virtual functions.

Public Functions

virtual Type getCustomType() const = 0

Return custom type.

The type purpose is for user to differentiate custom geometries. Not used by PhysX.

Note

User should use DECLARE_CUSTOM_GEOMETRY_TYPE and IMPLEMENT_CUSTOM_GEOMETRY_TYPE intead of overwriting this function.

Returns

Unique ID of a custom geometry type.

virtual PxBounds3 getLocalBounds(const PxGeometry &geometry) const = 0

Return local bounds.

Parameters

geometry[in] This geometry.

Returns

Bounding box in the geometry local space.

virtual bool generateContacts(const PxGeometry &geom0, const PxGeometry &geom1, const PxTransform &pose0, const PxTransform &pose1, const PxReal contactDistance, const PxReal meshContactMargin, const PxReal toleranceLength, PxContactBuffer &contactBuffer) const = 0

Contacts generation.

Generate collision contacts between two geometries in given poses.

Parameters
  • geom0[in] This custom geometry

  • geom1[in] The other geometry

  • pose0[in] This custom geometry pose

  • pose1[in] The other geometry pose

  • contactDistance[in] The distance at which contacts begin to be generated between the pairs

  • meshContactMargin[in] The mesh contact margin.

  • toleranceLength[in] The toleranceLength. Used for scaling distance-based thresholds internally to produce appropriate results given simulations in different units

  • contactBuffer[out] A buffer to write contacts to.

Returns

True if there are contacts. False otherwise.

virtual PxU32 raycast(const PxVec3 &origin, const PxVec3 &unitDir, const PxGeometry &geom, const PxTransform &pose, PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, PxGeomRaycastHit *rayHits, PxU32 stride, PxRaycastThreadContext *threadContext) const = 0

Raycast.

Cast a ray against the geometry in given pose.

Parameters
  • origin[in] Origin of the ray.

  • unitDir[in] Normalized direction of the ray.

  • geom[in] This custom geometry

  • pose[in] This custom geometry pose

  • maxDist[in] Length of the ray. Has to be in the [0, inf) range.

  • hitFlags[in] Specifies which properties per hit should be computed and returned via the hit callback.

  • maxHits[in] max number of returned hits = size of ‘rayHits’ buffer

  • rayHits[out] Ray hits.

  • stride[in] Ray hit structure stride.

  • threadContext[in] Optional user-defined per-thread context.

Returns

Number of hits.

virtual bool overlap(const PxGeometry &geom0, const PxTransform &pose0, const PxGeometry &geom1, const PxTransform &pose1, PxOverlapThreadContext *threadContext) const = 0

Overlap.

Test if geometries overlap.

Parameters
  • geom0[in] This custom geometry

  • pose0[in] This custom geometry pose

  • geom1[in] The other geometry

  • pose1[in] The other geometry pose

  • threadContext[in] Optional user-defined per-thread context.

Returns

True if there is overlap. False otherwise.

virtual bool sweep(const PxVec3 &unitDir, const PxReal maxDist, const PxGeometry &geom0, const PxTransform &pose0, const PxGeometry &geom1, const PxTransform &pose1, PxGeomSweepHit &sweepHit, PxHitFlags hitFlags, const PxReal inflation, PxSweepThreadContext *threadContext) const = 0

Sweep.

Sweep geom1 against geom0.

Parameters
  • unitDir[in] Normalized direction of the sweep. geom1 is swept along this direction.

  • maxDist[in] Length of the sweep. Has to be in the [0, inf) range.

  • geom0[in] This custom geometry

  • pose0[in] This custom geometry pose

  • geom1[in] The other geometry

  • pose1[in] The other geometry pose

  • sweepHit[out] Used to report the sweep hit.

  • hitFlags[in] Specifies which properties per hit should be computed and returned via the hit callback.

  • inflation[in] This parameter creates a skin around the swept geometry which increases its extents for sweeping.

  • threadContext[in] Optional user-defined per-thread context.

Returns

True if there is hit. False otherwise.

virtual void visualize(const PxGeometry &geometry, PxRenderOutput &out, const PxTransform &absPose, const PxBounds3 &cullbox) const = 0

Visualize custom geometry for debugging.

Optional.

Parameters
  • geometry[in] This geometry.

  • out[in] Render output.

  • absPose[in] Geometry absolute transform.

  • cullbox[in] Region to visualize.

virtual void computeMassProperties(const PxGeometry &geometry, PxMassProperties &massProperties) const = 0

Compute custom geometry mass properties.

For geometries usable with dynamic rigidbodies.

Parameters
  • geometry[in] This geometry.

  • massProperties[out] Mass properties to compute.

virtual bool usePersistentContactManifold(const PxGeometry &geometry, PxReal &breakingThreshold) const = 0

Compatible with PhysX’s PCM feature.

Allows to optimize contact generation.

Parameters
  • geometry[in] This geometry.

  • breakingThreshold[out] The threshold to trigger contacts re-generation.

inline virtual ~Callbacks()
struct Type

The type of a custom geometry.

Allows to identify a particular kind of it.

Public Functions

inline Type()

Default constructor.

inline Type(const Type &t)

Default constructor.

inline Type &operator=(const Type &t)

Assigment operator.

inline bool operator==(const Type &t) const

Equality operator.

inline bool operator!=(const Type &t) const

Inequality operator.

Public Static Functions

static inline Type INVALID()

Invalid type.