PxShapeExt.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
27 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29 
30 
31 #ifndef PX_PHYSICS_EXTENSIONS_SHAPE_H
32 #define PX_PHYSICS_EXTENSIONS_SHAPE_H
33 
37 #include "PxPhysXConfig.h"
38 
39 #include "PxShape.h"
40 #include "PxRigidActor.h"
42 
43 #if !PX_DOXYGEN
44 namespace physx
45 {
46 #endif
47 
55 {
56 public:
65  static PX_INLINE PxTransform getGlobalPose(const PxShape& shape, const PxRigidActor& actor)
66  {
67  return actor.getGlobalPose() * shape.getLocalPose();
68  }
69 
85  static PX_INLINE PxU32 raycast(const PxShape& shape, const PxRigidActor& actor,
86  const PxVec3& rayOrigin, const PxVec3& rayDir, PxReal maxDist, PxHitFlags hitFlags,
87  PxU32 maxHits, PxRaycastHit* rayHits)
88  {
90  rayOrigin, rayDir, shape.getGeometry().any(), getGlobalPose(shape, actor), maxDist, hitFlags, maxHits, rayHits);
91  }
92 
104  static PX_INLINE bool overlap(const PxShape& shape, const PxRigidActor& actor,
105  const PxGeometry& otherGeom, const PxTransform& otherGeomPose)
106  {
107  return PxGeometryQuery::overlap(shape.getGeometry().any(), getGlobalPose(shape, actor), otherGeom, otherGeomPose);
108  }
109 
127  static PX_INLINE bool sweep(const PxShape& shape, const PxRigidActor& actor,
128  const PxVec3& unitDir, const PxReal distance, const PxGeometry& otherGeom, const PxTransform& otherGeomPose,
129  PxSweepHit& sweepHit, PxHitFlags hitFlags)
130  {
131  return PxGeometryQuery::sweep(unitDir, distance, otherGeom, otherGeomPose, shape.getGeometry().any(), getGlobalPose(shape, actor), sweepHit, hitFlags);
132  }
133 
134 
146  static PX_INLINE PxBounds3 getWorldBounds(const PxShape& shape, const PxRigidActor& actor, float inflation=1.01f)
147  {
148  return PxGeometryQuery::getWorldBounds(shape.getGeometry().any(), getGlobalPose(shape, actor), inflation);
149  }
150 
151 };
152 
153 #if !PX_DOXYGEN
154 } // namespace physx
155 #endif
156 
158 #endif
Definition: GuContactBuffer.h:37
utility functions for use with PxShape
Definition: PxShapeExt.h:54
Abstract class for collision shapes.
Definition: PxShape.h:142
float PxReal
Definition: PxSimpleTypes.h:78
PX_FORCE_INLINE PxGeometry & any()
Definition: PxGeometryHelpers.h:72
static PX_INLINE bool sweep(const PxShape &shape, const PxRigidActor &actor, const PxVec3 &unitDir, const PxReal distance, const PxGeometry &otherGeom, const PxTransform &otherGeomPose, PxSweepHit &sweepHit, PxHitFlags hitFlags)
Sweep a geometry object against the shape.
Definition: PxShapeExt.h:127
A geometry object.
Definition: PxGeometry.h:75
static PX_PHYSX_COMMON_API PxU32 raycast(const PxVec3 &origin, const PxVec3 &unitDir, const PxGeometry &geom, const PxTransform &pose, PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, PxRaycastHit *PX_RESTRICT rayHits)
Raycast test against a geometry object.
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition: PxRigidActor.h:58
static PX_PHYSX_COMMON_API bool sweep(const PxVec3 &unitDir, const PxReal maxDist, const PxGeometry &geom0, const PxTransform &pose0, const PxGeometry &geom1, const PxTransform &pose1, PxSweepHit &sweepHit, PxHitFlags hitFlags=PxHitFlag::eDEFAULT, const PxReal inflation=0.f)
Sweep a specified geometry object in space and test for collision with a given object.
static PX_INLINE PxU32 raycast(const PxShape &shape, const PxRigidActor &actor, const PxVec3 &rayOrigin, const PxVec3 &rayDir, PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, PxRaycastHit *rayHits)
Raycast test against the shape.
Definition: PxShapeExt.h:85
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
static PX_INLINE bool overlap(const PxShape &shape, const PxRigidActor &actor, const PxGeometry &otherGeom, const PxTransform &otherGeomPose)
Test overlap between the shape and a geometry object.
Definition: PxShapeExt.h:104
static PX_PHYSX_COMMON_API bool overlap(const PxGeometry &geom0, const PxTransform &pose0, const PxGeometry &geom1, const PxTransform &pose1)
Overlap test for two geometry objects.
Class representing 3D range or axis aligned bounding box.
Definition: PxBounds3.h:58
static PX_INLINE PxTransform getGlobalPose(const PxShape &shape, const PxRigidActor &actor)
Retrieves the world space pose of the shape.
Definition: PxShapeExt.h:65
static PX_PHYSX_COMMON_API PxBounds3 getWorldBounds(const PxGeometry &geom, const PxTransform &pose, float inflation=1.01f)
get the bounds for a geometry object
virtual PxTransform getGlobalPose() const =0
Retrieves the actors world space transform.
Stores results of sweep queries.
Definition: PxQueryReport.h:199
Stores results of raycast queries.
Definition: PxQueryReport.h:173
uint32_t PxU32
Definition: Px.h:48
virtual PxTransform getLocalPose() const =0
Retrieves the pose of the shape in actor space, i.e. relative to the actor they are owned by...
virtual PxGeometryHolder getGeometry() const =0
Retrieve the geometry from the shape in a PxGeometryHolder wrapper class.
static PX_INLINE PxBounds3 getWorldBounds(const PxShape &shape, const PxRigidActor &actor, float inflation=1.01f)
Retrieves the axis aligned bounding box enclosing the shape.
Definition: PxShapeExt.h:146
#define PX_INLINE
Definition: PxPreprocessor.h:349
3 Element vector class.
Definition: PxVec3.h:49