30#ifndef PXFOUNDATION_PXBOUNDS3_H
31#define PXFOUNDATION_PXBOUNDS3_H
37#include "foundation/PxTransform.h"
38#include "foundation/PxMat33.h"
46#define PX_MAX_BOUNDS_EXTENTS (PX_MAX_REAL * 0.25f)
264: minimum(minimum_), maximum(maximum_)
270 return PxBounds3(PxVec3(PX_MAX_BOUNDS_EXTENTS), PxVec3(-PX_MAX_BOUNDS_EXTENTS));
280 return PxBounds3(v0.minimum(v1), v0.maximum(v1));
285 return PxBounds3(center - extent, center + extent);
292 PxVec3 c0 = basis.column0 * extent.x;
293 PxVec3 c1 = basis.column1 * extent.y;
294 PxVec3 c2 = basis.column2 * extent.z;
302 return PxBounds3(center - w, center + w);
307 return basisExtent(pose.p, PxMat33(pose.q), extent);
312 minimum = PxVec3(PX_MAX_BOUNDS_EXTENTS);
313 maximum = PxVec3(-PX_MAX_BOUNDS_EXTENTS);
318 minimum = PxVec3(-PX_MAX_BOUNDS_EXTENTS);
319 maximum = PxVec3(PX_MAX_BOUNDS_EXTENTS);
332 minimum = minimum.
minimum(b.minimum);
333 maximum = maximum.
maximum(b.maximum);
339 return minimum.x > maximum.x;
344 PX_SHARED_ASSERT(
isValid() && b.isValid());
345 return !(b.minimum.x > maximum.x || minimum.x > b.maximum.x || b.minimum.y > maximum.y || minimum.y > b.maximum.y ||
346 b.minimum.z > maximum.z || minimum.z > b.maximum.z);
351 PX_SHARED_ASSERT(
isValid() && a.isValid());
352 return maximum[axis] >= a.minimum[axis] && a.maximum[axis] >= minimum[axis];
359 return !(v.x < minimum.x || v.x > maximum.x || v.y < minimum.y || v.y > maximum.y || v.z < minimum.z ||
365 PX_SHARED_ASSERT(
isValid() && box.isValid());
366 if(box.minimum.x > minimum.x)
368 if(box.minimum.y > minimum.y)
370 if(box.minimum.z > minimum.z)
372 if(box.maximum.x < maximum.x)
374 if(box.maximum.y < maximum.y)
376 if(box.maximum.z < maximum.z)
384 return (minimum + maximum) * 0.5f;
390 return (minimum[axis] + maximum[axis]) * 0.5f;
396 return (maximum[axis] - minimum[axis]) * 0.5f;
402 return maximum - minimum;
434 minimum.x -= distance;
435 minimum.y -= distance;
436 minimum.z -= distance;
438 maximum.x += distance;
439 maximum.y += distance;
440 maximum.z += distance;
445 PX_SHARED_ASSERT(bounds.isValid());
446 return !bounds.isEmpty() ?
transformFast(matrix, bounds) : bounds;
451 PX_SHARED_ASSERT(bounds.isValid());
457 PX_SHARED_ASSERT(bounds.isValid());
458 return !bounds.isEmpty() ?
transformFast(transform, bounds) : bounds;
463 PX_SHARED_ASSERT(bounds.isValid());
469 return (
isFinite() && (((minimum.x <= maximum.x) && (minimum.y <= maximum.y) && (minimum.z <= maximum.z)) ||
470 ((minimum.x == PX_MAX_BOUNDS_EXTENTS) && (minimum.y == PX_MAX_BOUNDS_EXTENTS) &&
471 (minimum.z == PX_MAX_BOUNDS_EXTENTS) && (maximum.x == -PX_MAX_BOUNDS_EXTENTS) &&
472 (maximum.y == -PX_MAX_BOUNDS_EXTENTS) && (maximum.z == -PX_MAX_BOUNDS_EXTENTS))));
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 basisExtent(const PxVec3 ¢er, const PxMat33 &basis, const PxVec3 &extent)
Construct from center, extent, and (not necessarily orthogonal) basis.
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 transformFast(const PxMat33 &matrix, const PxBounds3 &bounds)
gets the transformed bounds of the passed AABB (resulting in a bigger AABB).
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 basisExtent(const PxVec3 ¢er, const PxMat33 &basis, const PxVec3 &extent)
Construct from center, extent, and (not necessarily orthogonal) basis.
Definition PxBounds3.h:305
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 transformSafe(const PxTransform &transform, const PxBounds3 &bounds)
gets the transformed bounds of the passed AABB (resulting in a bigger AABB).
PX_CUDA_CALLABLE PX_FORCE_INLINE float getCenter(uint32_t axis) const
get component of the box's center along a given axis
PX_CUDA_CALLABLE PX_FORCE_INLINE void fattenSafe(float distance)
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getExtents() const
returns the extents, which are half of the width/height/depth.
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 poseExtent(const PxTransform &pose, const PxVec3 &extent)
Construct from pose and extent.
PX_CUDA_CALLABLE PX_FORCE_INLINE void include(const PxVec3 &v)
expands the volume to include v
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getDimensions() const
returns the dimensions (width/height/depth) of this axis aligned box.
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isValid() const
PX_CUDA_CALLABLE PX_FORCE_INLINE void scaleSafe(float scale)
scales the AABB.
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 transformSafe(const PxMat33 &matrix, const PxBounds3 &bounds)
gets the transformed bounds of the passed AABB (resulting in a bigger AABB).
Definition PxBounds3.h:458
PX_CUDA_CALLABLE PX_FORCE_INLINE void setMaximal()
Sets the bounds to maximum size [-PX_MAX_BOUNDS_EXTENTS, PX_MAX_BOUNDS_EXTENTS].
static PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 empty()
Return empty bounds.
PX_CUDA_CALLABLE PX_FORCE_INLINE bool intersects(const PxBounds3 &b) const
indicates whether the intersection of this and b is empty or not.
static PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 empty()
Return empty bounds.
Definition PxBounds3.h:284
PX_CUDA_CALLABLE PX_FORCE_INLINE void fattenFast(float distance)
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 transformFast(const PxTransform &transform, const PxBounds3 &bounds)
gets the transformed bounds of the passed AABB (resulting in a bigger AABB).
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getCenter() const
returns the center of this axis aligned box.
PX_CUDA_CALLABLE PX_FORCE_INLINE bool intersects1D(const PxBounds3 &a, uint32_t axis) const
computes the 1D-intersection between two AABBs, on a given axis.
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 transformFast(const PxMat33 &matrix, const PxBounds3 &bounds)
gets the transformed bounds of the passed AABB (resulting in a bigger AABB).
Definition PxBounds3.h:464
static PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 boundsOfPoints(const PxVec3 &v0, const PxVec3 &v1)
returns the AABB containing v0 and v1.
PX_CUDA_CALLABLE PX_FORCE_INLINE void scaleFast(float scale)
scales the AABB.
PX_CUDA_CALLABLE PX_FORCE_INLINE void include(const PxBounds3 &b)
expands the volume to include b.
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isInside(const PxBounds3 &box) const
checks a box is inside another box.
static PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 centerExtents(const PxVec3 ¢er, const PxVec3 &extent)
returns the AABB from center and extents vectors.
Definition PxBounds3.h:299
PX_CUDA_CALLABLE PX_FORCE_INLINE bool contains(const PxVec3 &v) const
indicates if these bounds contain v.
PX_CUDA_CALLABLE PX_FORCE_INLINE float getExtents(uint32_t axis) const
get component of the box's extents along a given axis
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 transformSafe(const PxMat33 &matrix, const PxBounds3 &bounds)
gets the transformed bounds of the passed AABB (resulting in a bigger AABB).
PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3(const PxVec3 &minimum, const PxVec3 &maximum)
Construct from two bounding points.
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 poseExtent(const PxTransform &pose, const PxVec3 &extent)
Construct from pose and extent.
Definition PxBounds3.h:320
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isFinite() const
static PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 centerExtents(const PxVec3 ¢er, const PxVec3 &extent)
returns the AABB from center and extents vectors.
PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3()
Default constructor, not performing any initialization for performance reason.
Definition PxBounds3.h:65
static PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 boundsOfPoints(const PxVec3 &v0, const PxVec3 &v1)
returns the AABB containing v0 and v1.
Definition PxBounds3.h:294
PX_CUDA_CALLABLE PX_FORCE_INLINE void setEmpty()
Sets empty to true.
3x3 matrix class
Definition PxMat33.h:91
3 Element vector class.
Definition PxVec3.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 maximum(const PxVec3 &v) const
element-wise maximum
Definition PxVec3.h:360
PX_CUDA_CALLABLE PX_INLINE bool isFinite() const
returns true if all 3 elems of the vector are finite (not NAN or INF, etc.)
Definition PxVec3.h:156
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 minimum(const PxVec3 &v) const
element-wise minimum
Definition PxVec3.h:344
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_INLINE
Definition PxPreprocessor.h:320
transform(pattern)
Definition docopt.py:72
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxAbs(float a)
abs returns the absolute value of its argument.
Definition PxMath.h:109