RavEngine
Loading...
Searching...
No Matches
CustomConvex.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 CUSTOM_CONVEX_H
30#define CUSTOM_CONVEX_H
31
32#include "PxPhysicsAPI.h"
33
35{
36 float margin;
37
38 CustomConvex(float margin);
39
40 // override PxCustomGeometry::Callbacks
41
43 virtual bool generateContacts(const physx::PxGeometry& geom0, const physx::PxGeometry& geom1, const physx::PxTransform& pose0, const physx::PxTransform& pose1,
44 const physx::PxReal contactDistance, const physx::PxReal meshContactMargin, const physx::PxReal toleranceLength,
45 physx::PxContactBuffer& contactBuffer) const;
46 virtual physx::PxU32 raycast(const physx::PxVec3& origin, const physx::PxVec3& unitDir, const physx::PxGeometry& geom, const physx::PxTransform& pose,
47 physx::PxReal maxDist, physx::PxHitFlags hitFlags, physx::PxU32 maxHits, physx::PxGeomRaycastHit* rayHits, physx::PxU32 stride, physx::PxRaycastThreadContext*) const;
48 virtual bool overlap(const physx::PxGeometry& geom0, const physx::PxTransform& pose0, const physx::PxGeometry& geom1, const physx::PxTransform& pose1, physx::PxOverlapThreadContext*) const;
49 virtual bool sweep(const physx::PxVec3& unitDir, const physx::PxReal maxDist,
50 const physx::PxGeometry& geom0, const physx::PxTransform& pose0, const physx::PxGeometry& geom1, const physx::PxTransform& pose1,
51 physx::PxGeomSweepHit& sweepHit, physx::PxHitFlags hitFlags, const physx::PxReal inflation, physx::PxSweepThreadContext*) const;
53 virtual bool usePersistentContactManifold(const physx::PxGeometry&, physx::PxReal&) const { return true; }
54
55 // override PxGjkQuery::Support
56
57 virtual physx::PxReal getMargin() const;
58};
60{
61 float height, radius;
62
63 CustomCylinder(float _height, float _radius, float _margin) : CustomConvex(_margin), height(_height), radius(_radius) {}
64
65 // override PxCustomGeometry::Callbacks
66
68
69 virtual void computeMassProperties(const physx::PxGeometry& geometry, physx::PxMassProperties& massProperties) const;
70
71 // override PxGjkQuery::Support
72
73 virtual physx::PxVec3 supportLocal(const physx::PxVec3& dir) const;
74};
76{
77 float height, radius;
78
79 CustomCone(float _height, float _radius, float _margin) : CustomConvex(_margin), height(_height), radius(_radius) {}
80
81 // override PxCustomGeometry::Callbacks
82
84
85 virtual void computeMassProperties(const physx::PxGeometry& geometry, physx::PxMassProperties& massProperties) const;
86
87 // override PxGjkQuery::Support
88
89 virtual physx::PxVec3 supportLocal(const physx::PxVec3& dir) const;
90};
91
92#endif
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
Definition PxContactBuffer.h:42
A geometry object.
Definition PxGeometry.h:79
Utility class to compute and manipulate mass and inertia tensor properties.
Definition PxMassProperties.h:65
Definition PxRenderOutput.h:50
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 DECLARE_CUSTOM_GEOMETRY_TYPE
Used in pair with IMPLEMENT_CUSTOM_GEOMETRY_TYPE to overwrite Callbacks::getCustomType() callback.
Definition PxCustomGeometry.h:291
Definition CustomConvex.h:76
virtual physx::PxVec3 supportLocal(const physx::PxVec3 &dir) const
Return the farthest point on the user defined shape's core in given direction.
Definition CustomConvex.cpp:248
virtual DECLARE_CUSTOM_GEOMETRY_TYPE void computeMassProperties(const physx::PxGeometry &geometry, physx::PxMassProperties &massProperties) const
Compute custom geometry mass properties. For geometries usable with dynamic rigidbodies.
Definition CustomConvex.cpp:238
Definition CustomConvex.h:35
virtual bool overlap(const physx::PxGeometry &geom0, const physx::PxTransform &pose0, const physx::PxGeometry &geom1, const physx::PxTransform &pose1, physx::PxOverlapThreadContext *) const
Overlap. Test if geometries overlap.
Definition CustomConvex.cpp:155
virtual physx::PxBounds3 getLocalBounds(const physx::PxGeometry &) const
Return local bounds.
Definition CustomConvex.cpp:44
virtual bool generateContacts(const physx::PxGeometry &geom0, const physx::PxGeometry &geom1, const physx::PxTransform &pose0, const physx::PxTransform &pose1, const physx::PxReal contactDistance, const physx::PxReal meshContactMargin, const physx::PxReal toleranceLength, physx::PxContactBuffer &contactBuffer) const
Contacts generation. Generate collision contacts between two geometries in given poses.
Definition CustomConvex.cpp:52
virtual void visualize(const physx::PxGeometry &, physx::PxRenderOutput &, const physx::PxTransform &, const physx::PxBounds3 &) const
Visualize custom geometry for debugging. Optional.
Definition CustomConvex.h:52
virtual physx::PxReal getMargin() const
Return the user defined shape margin. Margin should be greater than or equal to 0.
Definition CustomConvex.cpp:206
virtual bool usePersistentContactManifold(const physx::PxGeometry &, physx::PxReal &) const
Compatible with PhysX's PCM feature. Allows to optimize contact generation.
Definition CustomConvex.h:53
Definition CustomConvex.h:60
virtual DECLARE_CUSTOM_GEOMETRY_TYPE void computeMassProperties(const physx::PxGeometry &geometry, physx::PxMassProperties &massProperties) const
Compute custom geometry mass properties. For geometries usable with dynamic rigidbodies.
Definition CustomConvex.cpp:217
virtual physx::PxVec3 supportLocal(const physx::PxVec3 &dir) const
Return the farthest point on the user defined shape's core in given direction.
Definition CustomConvex.cpp:226
Custom geometry callbacks structure. User should inherit this and implement all pure virtual function...
Definition PxCustomGeometry.h:102
Stores results of raycast queries.
Definition PxGeometryHit.h:151
Stores results of sweep queries.
Definition PxGeometryHit.h:175
Abstract interface for a user defined shape GJK mapping support. A user defined shape consists of a c...
Definition PxGjkQuery.h:55
A per-thread context passed to low-level query functions.
Definition PxGeometryQueryContext.h:52