PxBounds3

Defined in include/foundation/PxBounds3.h

class PxBounds3

Class representing 3D range or axis aligned bounding box.

Stored as minimum and maximum extent corners. Alternate representation would be center and dimensions. May be empty or nonempty. For nonempty bounds, minimum <= maximum has to hold for all axes. Empty bounds have to be represented as minimum = PX_MAX_BOUNDS_EXTENTS and maximum = -PX_MAX_BOUNDS_EXTENTS for all axes. All other representations are invalid and the behavior is undefined.

Public Functions

inline PxBounds3()

Default constructor, not performing any initialization for performance reason.

Remark

Use empty() function below to construct empty bounds.

inline PxBounds3(const PxVec3 &minimum, const PxVec3 &maximum)

Construct from two bounding points.

inline void operator=(const PxBounds3 &other)
inline PxBounds3(const PxBounds3 &other)
inline void setEmpty()

Sets empty to true.

inline void setMaximal()

Sets the bounds to maximum size [-PX_MAX_BOUNDS_EXTENTS, PX_MAX_BOUNDS_EXTENTS].

inline void include(const PxVec3 &v)

expands the volume to include v

Parameters

v – Point to expand to.

inline void include(const PxBounds3 &b)

expands the volume to include b.

Parameters

b – Bounds to perform union with.

inline bool isEmpty() const
inline bool intersects(const PxBounds3 &b) const

indicates whether the intersection of this and b is empty or not.

Parameters

b – Bounds to test for intersection.

inline bool intersects1D(const PxBounds3 &a, uint32_t axis) const

computes the 1D-intersection between two AABBs, on a given axis.

Parameters
  • a – the other AABB

  • axis – the axis (0, 1, 2)

inline bool contains(const PxVec3 &v) const

indicates if these bounds contain v.

Parameters

v – Point to test against bounds.

inline bool isInside(const PxBounds3 &box) const

checks a box is inside another box.

Parameters

box – the other AABB

inline PxVec3 getCenter() const

returns the center of this axis aligned box.

inline float getCenter(uint32_t axis) const

get component of the box’s center along a given axis

inline float getExtents(uint32_t axis) const

get component of the box’s extents along a given axis

inline PxVec3 getDimensions() const

returns the dimensions (width/height/depth) of this axis aligned box.

inline PxVec3 getExtents() const

returns the extents, which are half of the width/height/depth.

inline void scaleSafe(float scale)

scales the AABB.

This version is safe to call for empty bounds.

Parameters

scale – Factor to scale AABB by.

inline void scaleFast(float scale)

scales the AABB.

Calling this method for empty bounds leads to undefined behavior. Use scaleSafe() instead.

Parameters

scale – Factor to scale AABB by.

inline void fattenSafe(float distance)

fattens the AABB in all 3 dimensions by the given distance.

This version is safe to call for empty bounds.

inline void fattenFast(float distance)

fattens the AABB in all 3 dimensions by the given distance.

Calling this method for empty bounds leads to undefined behavior. Use fattenSafe() instead.

inline bool isFinite() const

checks that the AABB values are not NaN

inline bool isValid() const

checks that the AABB values describe a valid configuration.

inline PxVec3 closestPoint(const PxVec3 &p) const

Finds the closest point in the box to the point p.

If p is contained, this will be p, otherwise it will be the closest point on the surface of the box.

Public Members

PxVec3 minimum
PxVec3 maximum

Public Static Functions

static inline PxBounds3 empty()

Return empty bounds.

static inline PxBounds3 boundsOfPoints(const PxVec3 &v0, const PxVec3 &v1)

returns the AABB containing v0 and v1.

Parameters
  • v0 – first point included in the AABB.

  • v1 – second point included in the AABB.

static inline PxBounds3 centerExtents(const PxVec3 &center, const PxVec3 &extent)

returns the AABB from center and extents vectors.

Parameters
  • center – Center vector

  • extent – Extents vector

static inline PxBounds3 basisExtent(const PxVec3 &center, const PxMat33 &basis, const PxVec3 &extent)

Construct from center, extent, and (not necessarily orthogonal) basis.

static inline PxBounds3 poseExtent(const PxTransform &pose, const PxVec3 &extent)

Construct from pose and extent.

static inline PxBounds3 transformSafe(const PxMat33 &matrix, const PxBounds3 &bounds)

gets the transformed bounds of the passed AABB (resulting in a bigger AABB).

This version is safe to call for empty bounds.

Parameters
  • matrix[in] Transform to apply, can contain scaling as well

  • bounds[in] The bounds to transform.

static inline PxBounds3 transformFast(const PxMat33 &matrix, const PxBounds3 &bounds)

gets the transformed bounds of the passed AABB (resulting in a bigger AABB).

Calling this method for empty bounds leads to undefined behavior. Use transformSafe() instead.

Parameters
  • matrix[in] Transform to apply, can contain scaling as well

  • bounds[in] The bounds to transform.

static inline PxBounds3 transformSafe(const PxTransform &transform, const PxBounds3 &bounds)

gets the transformed bounds of the passed AABB (resulting in a bigger AABB).

This version is safe to call for empty bounds.

Parameters
  • transform[in] Transform to apply, can contain scaling as well

  • bounds[in] The bounds to transform.

static inline PxBounds3 transformFast(const PxTransform &transform, const PxBounds3 &bounds)

gets the transformed bounds of the passed AABB (resulting in a bigger AABB).

Calling this method for empty bounds leads to undefined behavior. Use transformSafe() instead.

Parameters
  • transform[in] Transform to apply, can contain scaling as well

  • bounds[in] The bounds to transform.