RavEngine
Loading...
Searching...
No Matches
PxShapeExt.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_SHAPE_EXT_H
30#define PX_SHAPE_EXT_H
35#include "PxPhysXConfig.h"
36
37#include "PxShape.h"
38#include "PxRigidActor.h"
39#include "geometry/PxGeometryQuery.h"
40#include "PxQueryReport.h"
41
42#if !PX_DOXYGEN
43namespace physx
44{
45#endif
46
54{
55public:
64 static PX_INLINE PxTransform getGlobalPose(const PxShape& shape, const PxRigidActor& actor)
65 {
66 return actor.getGlobalPose() * shape.getLocalPose();
67 }
68
84 static PX_INLINE PxU32 raycast(const PxShape& shape, const PxRigidActor& actor,
85 const PxVec3& rayOrigin, const PxVec3& rayDir, PxReal maxDist, PxHitFlags hitFlags,
86 PxU32 maxHits, PxRaycastHit* rayHits)
87 {
89 rayOrigin, rayDir, shape.getGeometry(), getGlobalPose(shape, actor), maxDist, hitFlags, maxHits, rayHits);
90 }
91
103 static PX_INLINE bool overlap(const PxShape& shape, const PxRigidActor& actor,
104 const PxGeometry& otherGeom, const PxTransform& otherGeomPose)
105 {
106 return PxGeometryQuery::overlap(shape.getGeometry(), getGlobalPose(shape, actor), otherGeom, otherGeomPose);
107 }
108
126 static PX_INLINE bool sweep(const PxShape& shape, const PxRigidActor& actor,
127 const PxVec3& unitDir, const PxReal distance, const PxGeometry& otherGeom, const PxTransform& otherGeomPose,
128 PxSweepHit& sweepHit, PxHitFlags hitFlags)
129 {
130 return PxGeometryQuery::sweep(unitDir, distance, otherGeom, otherGeomPose, shape.getGeometry(), getGlobalPose(shape, actor), sweepHit, hitFlags);
131 }
132
133
145 static PX_INLINE PxBounds3 getWorldBounds(const PxShape& shape, const PxRigidActor& actor, float inflation=1.01f)
146 {
147 return PxGeometryQuery::getWorldBounds(shape.getGeometry(), getGlobalPose(shape, actor), inflation);
148 }
149
150};
151
152#if !PX_DOXYGEN
153} // namespace physx
154#endif
155
157#endif
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
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, PxGeomRaycastHit *PX_RESTRICT rayHits, PxU32 stride, PxGeometryQueryFlags queryFlags=PxGeometryQueryFlag::eDEFAULT, PxRaycastThreadContext *threadContext=NULL)
Raycast test against a geometry object.
Definition GuGeometryQuery.cpp:184
PX_DEPRECATED static PX_PHYSX_COMMON_API PxBounds3 getWorldBounds(const PxGeometry &geom, const PxTransform &pose, float inflation=1.01f)
get the bounds for a geometry object
Definition GuGeometryQuery.cpp:316
static PX_PHYSX_COMMON_API bool overlap(const PxGeometry &geom0, const PxTransform &pose0, const PxGeometry &geom1, const PxTransform &pose1, PxGeometryQueryFlags queryFlags=PxGeometryQueryFlag::eDEFAULT, PxOverlapThreadContext *threadContext=NULL)
Overlap test for two geometry objects.
Definition GuGeometryQuery.cpp:174
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, PxGeomSweepHit &sweepHit, PxHitFlags hitFlags=PxHitFlag::eDEFAULT, const PxReal inflation=0.0f, PxGeometryQueryFlags queryFlags=PxGeometryQueryFlag::eDEFAULT, PxSweepThreadContext *threadContext=NULL)
Sweep a specified geometry object in space and test for collision with a given object.
Definition GuGeometryQuery.cpp:92
A geometry object.
Definition PxGeometry.h:79
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
utility functions for use with PxShape
Definition PxShapeExt.h:54
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:126
static PX_INLINE PxTransform getGlobalPose(const PxShape &shape, const PxRigidActor &actor)
Retrieves the world space pose of the shape.
Definition PxShapeExt.h:64
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:103
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:84
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:145
Abstract class for collision shapes.
Definition PxShape.h:146
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition PxQueryReport.h:66
Definition PxQueryReport.h:68