RavEngine
Loading...
Searching...
No Matches
PxRigidBodyExt.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_RIGID_BODY_EXT_H
30#define PX_RIGID_BODY_EXT_H
35#include "PxPhysXConfig.h"
36#include "PxRigidBody.h"
37#include "PxQueryReport.h"
38#include "PxQueryFiltering.h"
39#include "extensions/PxMassProperties.h"
40
41#if !PX_DOXYGEN
42namespace physx
43{
44#endif
45
46class PxScene;
47struct PxQueryCache;
48class PxShape;
49
57{
58public:
92 static bool updateMassAndInertia(PxRigidBody& body, const PxReal* shapeDensities, PxU32 shapeDensityCount, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false);
93
107 static bool updateMassAndInertia(PxRigidBody& body, PxReal density, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false);
108
130 static bool setMassAndUpdateInertia(PxRigidBody& body, const PxReal* shapeMasses, PxU32 shapeMassCount, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false);
131
150 static bool setMassAndUpdateInertia(PxRigidBody& body, PxReal mass, const PxVec3* massLocalPose = NULL, bool includeNonSimShapes = false);
151
161 static PxMassProperties computeMassPropertiesFromShapes(const PxShape* const* shapes, PxU32 shapeCount);
162
189 static void addForceAtPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true);
190
217 static void addForceAtLocalPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true);
218
245 static void addLocalForceAtPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true);
246
273 static void addLocalForceAtLocalPos(PxRigidBody& body, const PxVec3& force, const PxVec3& pos, PxForceMode::Enum mode = PxForceMode::eFORCE, bool wakeup = true);
274
285 static PxVec3 getVelocityAtPos(const PxRigidBody& body, const PxVec3& pos);
286
297 static PxVec3 getLocalVelocityAtLocalPos(const PxRigidBody& body, const PxVec3& pos);
298
309 static PxVec3 getVelocityAtOffset(const PxRigidBody& body, const PxVec3& pos);
310
326 static void computeVelocityDeltaFromImpulse(const PxRigidBody& body, const PxVec3& impulsiveForce, const PxVec3& impulsiveTorque, PxVec3& deltaLinearVelocity, PxVec3& deltaAngularVelocity);
327
344 static void computeVelocityDeltaFromImpulse(const PxRigidBody& body, const PxTransform& globalPose, const PxVec3& point, const PxVec3& impulse, const PxReal invMassScale,
345 const PxReal invInertiaScale, PxVec3& deltaLinearVelocity, PxVec3& deltaAngularVelocity);
346
361 static void computeLinearAngularImpulse(const PxRigidBody& body, const PxTransform& globalPose, const PxVec3& point, const PxVec3& impulse, const PxReal invMassScale,
362 const PxReal invInertiaScale, PxVec3& linearImpulse, PxVec3& angularImpulse);
363
392 static bool linearSweepSingle(
393 PxRigidBody& body, PxScene& scene, const PxVec3& unitDir, const PxReal distance,
394 PxHitFlags outputFlags,
395 PxSweepHit& closestHit, PxU32& shapeIndex,
396 const PxQueryFilterData& filterData = PxQueryFilterData(),
397 PxQueryFilterCallback* filterCall = NULL,
398 const PxQueryCache* cache = NULL,
399 const PxReal inflation=0.0f);
400
433 static PxU32 linearSweepMultiple(
434 PxRigidBody& body, PxScene& scene, const PxVec3& unitDir, const PxReal distance,
435 PxHitFlags outputFlags,
436 PxSweepHit* touchHitBuffer, PxU32* touchHitShapeIndices, PxU32 touchHitBufferSize,
437 PxSweepHit& block, PxI32& blockingShapeIndex, bool& overflow,
438 const PxQueryFilterData& filterData = PxQueryFilterData(),
439 PxQueryFilterCallback* filterCall = NULL,
440 const PxQueryCache* cache = NULL, const PxReal inflation = 0.0f);
441};
442
443#if !PX_DOXYGEN
444} // namespace physx
445#endif
446
448#endif
Utility class to compute and manipulate mass and inertia tensor properties.
Definition PxMassProperties.h:65
Scene query filtering callbacks.
Definition PxQueryFiltering.h:175
utility functions for use with PxRigidBody and subclasses
Definition PxRigidBodyExt.h:57
static PxVec3 getLocalVelocityAtLocalPos(const PxRigidBody &body, const PxVec3 &pos)
Computes the velocity of a point given in local coordinates if it were attached to the specified body...
Definition ExtRigidBodyExt.cpp:462
static PxMassProperties computeMassPropertiesFromShapes(const PxShape *const *shapes, PxU32 shapeCount)
Compute the mass, inertia tensor and center of mass from a list of shapes.
Definition ExtRigidBodyExt.cpp:381
static bool setMassAndUpdateInertia(PxRigidBody &body, const PxReal *shapeMasses, PxU32 shapeMassCount, const PxVec3 *massLocalPose=NULL, bool includeNonSimShapes=false)
Computation of mass properties for a rigid body actor.
Definition ExtRigidBodyExt.cpp:371
static PxVec3 getVelocityAtOffset(const PxRigidBody &body, const PxVec3 &pos)
Computes the velocity of a point (offset from the origin of the body) given in world coordinates if i...
Definition ExtRigidBodyExt.cpp:471
static void addLocalForceAtLocalPos(PxRigidBody &body, const PxVec3 &force, const PxVec3 &pos, PxForceMode::Enum mode=PxForceMode::eFORCE, bool wakeup=true)
Applies a force (or impulse) defined in the actor local coordinate frame, acting at a particular poin...
Definition ExtRigidBodyExt.cpp:436
static bool updateMassAndInertia(PxRigidBody &body, const PxReal *shapeDensities, PxU32 shapeDensityCount, const PxVec3 *massLocalPose=NULL, bool includeNonSimShapes=false)
Computation of mass properties for a rigid body actor.
Definition ExtRigidBodyExt.cpp:311
static void addForceAtLocalPos(PxRigidBody &body, const PxVec3 &force, const PxVec3 &pos, PxForceMode::Enum mode=PxForceMode::eFORCE, bool wakeup=true)
Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in ...
Definition ExtRigidBodyExt.cpp:421
static void addLocalForceAtPos(PxRigidBody &body, const PxVec3 &force, const PxVec3 &pos, PxForceMode::Enum mode=PxForceMode::eFORCE, bool wakeup=true)
Applies a force (or impulse) defined in the actor local coordinate frame, acting at a particular poin...
Definition ExtRigidBodyExt.cpp:429
static void computeLinearAngularImpulse(const PxRigidBody &body, const PxTransform &globalPose, const PxVec3 &point, const PxVec3 &impulse, const PxReal invMassScale, const PxReal invInertiaScale, PxVec3 &linearImpulse, PxVec3 &angularImpulse)
Computes the linear and angular impulse vectors for a given impulse at a world space position taking ...
Definition ExtRigidBodyExt.cpp:494
static PxU32 linearSweepMultiple(PxRigidBody &body, PxScene &scene, const PxVec3 &unitDir, const PxReal distance, PxHitFlags outputFlags, PxSweepHit *touchHitBuffer, PxU32 *touchHitShapeIndices, PxU32 touchHitBufferSize, PxSweepHit &block, PxI32 &blockingShapeIndex, bool &overflow, const PxQueryFilterData &filterData=PxQueryFilterData(), PxQueryFilterCallback *filterCall=NULL, const PxQueryCache *cache=NULL, const PxReal inflation=0.0f)
Performs a linear sweep through space with the body's geometry objects, returning all overlaps.
Definition ExtRigidBodyExt.cpp:570
static void computeVelocityDeltaFromImpulse(const PxRigidBody &body, const PxVec3 &impulsiveForce, const PxVec3 &impulsiveTorque, PxVec3 &deltaLinearVelocity, PxVec3 &deltaAngularVelocity)
Compute the change to linear and angular velocity that would occur if an impulsive force and torque w...
Definition ExtRigidBodyExt.cpp:502
static void addForceAtPos(PxRigidBody &body, const PxVec3 &force, const PxVec3 &pos, PxForceMode::Enum mode=PxForceMode::eFORCE, bool wakeup=true)
Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in ...
Definition ExtRigidBodyExt.cpp:416
static PxVec3 getVelocityAtPos(const PxRigidBody &body, const PxVec3 &pos)
Computes the velocity of a point given in world coordinates if it were attached to the specified body...
Definition ExtRigidBodyExt.cpp:453
static bool linearSweepSingle(PxRigidBody &body, PxScene &scene, const PxVec3 &unitDir, const PxReal distance, PxHitFlags outputFlags, PxSweepHit &closestHit, PxU32 &shapeIndex, const PxQueryFilterData &filterData=PxQueryFilterData(), PxQueryFilterCallback *filterCall=NULL, const PxQueryCache *cache=NULL, const PxReal inflation=0.0f)
Performs a linear sweep through space with the body's geometry objects.
Definition ExtRigidBodyExt.cpp:534
PxRigidBody is a base class shared between dynamic rigid body objects.
Definition PxRigidBody.h:199
A scene is a collection of bodies and constraints which can interact.
Definition PxScene.h:178
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
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Enum
Definition PxForceMode.h:51
@ eFORCE
parameter has unit of mass * length / time^2, i.e., a force
Definition PxForceMode.h:52
single hit cache for scene queries.
Definition PxQueryReport.h:264
Scene query filtering data.
Definition PxQueryFiltering.h:138
Definition PxQueryReport.h:68