PxImmediateMode.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-2019 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 #ifndef PX_PHYSICS_IMMEDIATE_MODE
31 #define PX_PHYSICS_IMMEDIATE_MODE
32 
35 #include "PxPhysXConfig.h"
36 #include "solver/PxSolverDefs.h"
38 
39 #if !PX_DOXYGEN
40 namespace physx
41 {
42 #endif
43 
44 #if !PX_DOXYGEN
45 namespace immediate
46 {
47 #endif
48 
53  {
54  PX_ALIGN(16, PxVec3 linearVelocity);
66  };
67 
72  {
73  public:
81  virtual bool recordContacts(const Gu::ContactPoint* contactPoints, const PxU32 nbContacts, const PxU32 index) = 0;
82 
83  virtual ~PxContactRecorder(){}
84  };
85 
94  PX_C_EXPORT PX_PHYSX_CORE_API void PxConstructSolverBodies(const PxRigidBodyData* inRigidData, PxSolverBodyData* outSolverBodyData, const PxU32 nbBodies, const PxVec3& gravity, const PxReal dt);
95 
102 
118  PX_C_EXPORT PX_PHYSX_CORE_API PxU32 PxBatchConstraints(const PxSolverConstraintDesc* solverConstraintDescs, const PxU32 nbConstraints, PxSolverBody* solverBodies, PxU32 nbBodies, PxConstraintBatchHeader* outBatchHeaders,
119  PxSolverConstraintDesc* outOrderedConstraintDescs);
120 
139  PxConstraintAllocator& allocator, PxReal invDt, PxReal bounceThreshold, PxReal frictionOffsetThreshold, PxReal correlationDistance);
140 
152 
164  PX_C_EXPORT PX_PHYSX_CORE_API bool PxCreateJointConstraintsWithShaders(PxConstraintBatchHeader* batchHeader, const PxU32 nbBatchHeaders, PxConstraint** constraints, PxSolverConstraintPrepDesc* jointDescs, PxConstraintAllocator& allocator, PxReal dt, PxReal invDt);
165 
178  PX_C_EXPORT PX_PHYSX_CORE_API void PxSolveConstraints(const PxConstraintBatchHeader* batchHeaders, const PxU32 nbBatchHeaders, const PxSolverConstraintDesc* solverConstraintDescs, PxSolverBody* solverBodies,
179  PxVec3* linearMotionVelocity, PxVec3* angularMotionVelocity, const PxU32 nbSolverBodies, const PxU32 nbPositionIterations, const PxU32 nbVelocityIterations);
180 
191  PX_C_EXPORT PX_PHYSX_CORE_API void PxIntegrateSolverBodies(PxSolverBodyData* solverBodyData, PxSolverBody* solverBody, const PxVec3* linearMotionVelocity, const PxVec3* angularMotionState, const PxU32 nbBodiesToIntegrate, PxReal dt);
192 
213  PX_C_EXPORT PX_PHYSX_CORE_API bool PxGenerateContacts(const PxGeometry* const * geom0, const PxGeometry* const * geom1, const PxTransform* pose0, const PxTransform* pose1, PxCache* contactCache, const PxU32 nbPairs, PxContactRecorder& contactRecorder,
214  const PxReal contactDistance, const PxReal meshContactMargin, const PxReal toleranceLength, PxCacheAllocator& allocator);
215 
216 #if !PX_DOXYGEN
217 }
218 #endif
219 
220 #if !PX_DOXYGEN
221 }
222 #endif
223 
225 #endif
226 
Definition: GuContactBuffer.h:37
Callback class to record contact points produced by immediate::PxGenerateContacts.
Definition: PxImmediateMode.h:71
Definition: PxSolverDefs.h:181
PxU32 pad
96 Padding for 16-byte alignment
Definition: PxImmediateMode.h:65
Definition: PxSolverDefs.h:79
virtual ~PxContactRecorder()
Definition: PxImmediateMode.h:83
PxTransform body2World
76 World space transform
Definition: PxImmediateMode.h:60
PxVec3 invInertia
44 Mass-space inverse interia diagonal vector
Definition: PxImmediateMode.h:58
PxU8 nbContacts
Definition: PxContact.h:462
float PxReal
Definition: PxSimpleTypes.h:78
PX_C_EXPORT PX_PHYSX_CORE_API void PxConstructStaticSolverBody(const PxTransform &globalPose, PxSolverBodyData &solverBodyData)
Constructs a PxSolverBodyData structure for a static body at a given pose.
#define PX_C_EXPORT
Definition: Pxc.h:54
PX_C_EXPORT PX_PHYSX_CORE_API PxU32 PxBatchConstraints(const PxSolverConstraintDesc *solverConstraintDescs, const PxU32 nbConstraints, PxSolverBody *solverBodies, PxU32 nbBodies, PxConstraintBatchHeader *outBatchHeaders, PxSolverConstraintDesc *outOrderedConstraintDescs)
Groups together sets of independent PxSolverConstraintDesc objects to be solved using SIMD SOA approa...
PxReal maxAngularVelocitySq
92 Squared maximum angular velocity
Definition: PxImmediateMode.h:64
PxReal angularDamping
84 Angular damping coefficient
Definition: PxImmediateMode.h:62
Definition: PxSolverDefs.h:227
#define PX_PHYSX_CORE_API
Definition: PxPhysXCommonConfig.h:59
PxReal maxLinearVelocitySq
88 Squared maximum linear velocity
Definition: PxImmediateMode.h:63
PX_C_EXPORT PX_PHYSX_CORE_API bool PxCreateContactConstraints(PxConstraintBatchHeader *batchHeader, const PxU32 nbHeaders, PxSolverContactDesc *contactDescs, PxConstraintAllocator &allocator, PxReal invDt, PxReal bounceThreshold, PxReal frictionOffsetThreshold, PxReal correlationDistance)
Creates a set of contact constraint blocks. Note that, depending the results of PxBatchConstraints, each batchHeader may refer to up to 4 solverConstraintDescs. This function will allocate both constraint and friction patch data via the PxConstraintAllocator provided. Constraint data is only valid until PxSolveConstraints has completed. Friction data is to be retained and provided by the application for friction correlation.
A geometry object.
Definition: PxGeometry.h:75
PX_C_EXPORT PX_PHYSX_CORE_API void PxConstructSolverBodies(const PxRigidBodyData *inRigidData, PxSolverBodyData *outSolverBodyData, const PxU32 nbBodies, const PxVec3 &gravity, const PxReal dt)
Constructs a PxSolverBodyData structure based on rigid body properties. Applies gravity, damping and clamps maximum velocity.
Definition: PxCollisionDefs.h:65
PX_C_EXPORT PX_PHYSX_CORE_API bool PxCreateJointConstraintsWithShaders(PxConstraintBatchHeader *batchHeader, const PxU32 nbBatchHeaders, PxConstraint **constraints, PxSolverConstraintPrepDesc *jointDescs, PxConstraintAllocator &allocator, PxReal dt, PxReal invDt)
Creates a set of joint constraint blocks. This function runs joint shaders defined inside PxConstrain...
PX_C_EXPORT PX_PHYSX_CORE_API void PxIntegrateSolverBodies(PxSolverBodyData *solverBodyData, PxSolverBody *solverBody, const PxVec3 *linearMotionVelocity, const PxVec3 *angularMotionState, const PxU32 nbBodiesToIntegrate, PxReal dt)
Integrates a rigid body, returning the new velocities and transforms. After this function has been ca...
PxReal invMass
16 Inverse mass
Definition: PxImmediateMode.h:55
class representing a rigid euclidean transform as a quaternion and a vector
Definition: PxTransform.h:48
A plugin class for implementing constraints.
Definition: PxConstraint.h:108
Definition: PxSolverDefs.h:198
PxVec3 angularVelocity
28 Angular velocity
Definition: PxImmediateMode.h:56
PxReal linearDamping
80 Linear damping coefficient
Definition: PxImmediateMode.h:61
PX_C_EXPORT PX_PHYSX_CORE_API bool PxCreateJointConstraints(PxConstraintBatchHeader *batchHeader, const PxU32 nbHeaders, PxSolverConstraintPrepDesc *jointDescs, PxConstraintAllocator &allocator, PxReal dt, PxReal invDt)
Creates a set of joint constraint blocks. Note that, depending the results of PxBatchConstraints, the batchHeader may refer to up to 4 solverConstraintDescs.
Definition: PxSolverDefs.h:62
PX_C_EXPORT PX_PHYSX_CORE_API void PxSolveConstraints(const PxConstraintBatchHeader *batchHeaders, const PxU32 nbBatchHeaders, const PxSolverConstraintDesc *solverConstraintDescs, PxSolverBody *solverBodies, PxVec3 *linearMotionVelocity, PxVec3 *angularMotionVelocity, const PxU32 nbSolverBodies, const PxU32 nbPositionIterations, const PxU32 nbVelocityIterations)
Iteratively solves the set of constraints defined by the provided PxConstraintBatchHeader and PxSolve...
A structure to cache contact information produced by LL contact gen functions.
Definition: PxCollisionDefs.h:49
Structure to store rigid body properties.
Definition: PxImmediateMode.h:52
#define PX_ALIGN(alignment, decl)
Definition: PxPreprocessor.h:396
PX_C_EXPORT PX_PHYSX_CORE_API bool PxGenerateContacts(const PxGeometry *const *geom0, const PxGeometry *const *geom1, const PxTransform *pose0, const PxTransform *pose1, PxCache *contactCache, const PxU32 nbPairs, PxContactRecorder &contactRecorder, const PxReal contactDistance, const PxReal meshContactMargin, const PxReal toleranceLength, PxCacheAllocator &allocator)
Performs contact generation for a given pair of geometries at the specified poses. Produced contacts are stored in the provided Gu::ContactBuffer. Information is cached in PxCache structure to accelerate future contact generation between pairs. This cache data is valid only as long as the memory provided by PxCacheAllocator has not been released/re-used. Recommendation is to retain that data for a single simulation frame, discarding cached data after 2 frames. If the cached memory has been released/re-used prior to the corresponding pair having contact generation performed again, it is the application's responsibility to reset the PxCache.
Definition: PxSolverDefs.h:111
PxReal maxDepenetrationVelocity
32 Maximum de-penetration velocity
Definition: PxImmediateMode.h:57
uint32_t PxU32
Definition: Px.h:48
3 Element vector class.
Definition: PxVec3.h:49
Definition: PxSolverDefs.h:103
PxReal maxContactImpulse
48 Maximum permissable contact impulse
Definition: PxImmediateMode.h:59