RavEngine
Loading...
Searching...
No Matches
PxSoftBody.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_SOFT_BODY_H
30#define PX_SOFT_BODY_H
34#include "PxFEMParameter.h"
35#include "PxActor.h"
36#include "PxConeLimitedConstraint.h"
37
38#if !PX_DOXYGEN
39namespace physx
40{
41#endif
42
43#if PX_VC
44#pragma warning(push)
45#pragma warning(disable : 4435)
46#endif
47
48 class PxCudaContextManager;
49 class PxBuffer;
50 class PxTetrahedronMesh;
51 class PxSoftBodyAuxData;
52 class PxFEMCloth;
53 class PxParticleBuffer;
54
58 #define PX_MAX_TETID 0x000fffff
59
66 {
78 };
79
80 typedef PxFlags<PxSoftBodyData::Enum, PxU32> PxSoftBodyDataFlags;
81
86 {
96 };
97
98 typedef PxFlags<PxSoftBodyFlag::Enum, PxU32> PxSoftBodyFlags;
99
103 class PxSoftBody : public PxActor
104 {
105 public:
106
107 virtual ~PxSoftBody() {}
108
115 virtual void setSoftBodyFlag(PxSoftBodyFlag::Enum flag, bool val) = 0;
116
122 virtual void setSoftBodyFlags(PxSoftBodyFlags flags) = 0;
123
129 virtual PxSoftBodyFlags getSoftBodyFlag() const = 0;
130
136 virtual void setParameter(const PxFEMParameters parameters) = 0;
137
143 virtual PxFEMParameters getParameter() const = 0;
144
162 virtual void readData(PxSoftBodyData::Enum flags, PxBuffer& buffer, bool flush = false) = 0;
163
180 virtual void readData(PxSoftBodyData::Enum flags, bool flush = false) = 0;
181
200 virtual void writeData(PxSoftBodyData::Enum flags, PxBuffer& buffer, bool flush = false) = 0;
201
219 virtual void writeData(PxSoftBodyData::Enum flags, bool flush = false) = 0;
220
226 virtual PxCudaContextManager* getCudaContextManager() const = 0;
227
243 virtual void setWakeCounter(PxReal wakeCounterValue) = 0;
244
252 virtual PxReal getWakeCounter() const = 0;
253
281 virtual bool isSleeping() const = 0;
282
300 virtual void setSolverIterationCounts(PxU32 minPositionIters, PxU32 minVelocityIters = 1) = 0;
301
307 virtual void getSolverIterationCounts(PxU32& minPositionIters, PxU32& minVelocityIters) const = 0;
308
309
316 virtual PxShape* getShape() = 0;
317
318
327
336
346
347
357 virtual bool attachShape(PxShape& shape) = 0;
358
370 virtual bool attachSimulationMesh(PxTetrahedronMesh& simulationMesh, PxSoftBodyAuxData& softBodyAuxData) = 0;
371
379 virtual void detachShape() = 0;
380
388 virtual void detachSimulationMesh() = 0;
389
395 virtual void release() = 0;
396
405 virtual void addParticleFilter(PxPBDParticleSystem* particlesystem, const PxParticleBuffer* buffer, PxU32 particleId, PxU32 tetId) = 0;
406
415 virtual void removeParticleFilter(PxPBDParticleSystem* particlesystem, const PxParticleBuffer* buffer, PxU32 particleId, PxU32 tetId) = 0;
416
429 virtual PxU32 addParticleAttachment(PxPBDParticleSystem* particlesystem, const PxParticleBuffer* buffer, PxU32 particleId, PxU32 tetId, const PxVec4& barycentric) = 0;
430
431
440 virtual void removeParticleAttachment(PxPBDParticleSystem* particlesystem, PxU32 handle) = 0;
441
448 virtual void addRigidFilter(PxRigidActor* actor, PxU32 vertId) = 0;
449
456 virtual void removeRigidFilter(PxRigidActor* actor, PxU32 vertId) = 0;
457
471 virtual PxU32 addRigidAttachment(PxRigidActor* actor, PxU32 vertId, const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint = NULL) = 0;
472
483 virtual void removeRigidAttachment(PxRigidActor* actor, PxU32 handle) = 0;
484
491 virtual void addTetRigidFilter(PxRigidActor* actor, PxU32 tetIdx) = 0;
492
499 virtual void removeTetRigidFilter(PxRigidActor* actor, PxU32 tetIdx) = 0;
500
515 virtual PxU32 addTetRigidAttachment(PxRigidActor* actor, PxU32 tetIdx, const PxVec4& barycentric, const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint = NULL) = 0;
516
524 virtual void addSoftBodyFilter(PxSoftBody* otherSoftBody, PxU32 otherTetIdx, PxU32 tetIdx1) = 0;
525
533 virtual void removeSoftBodyFilter(PxSoftBody* otherSoftBody, PxU32 otherTetIdx, PxU32 tetIdx1) = 0;
534
543 virtual void addSoftBodyFilters(PxSoftBody* otherSoftBody, PxU32* otherTetIndices, PxU32* tetIndices, PxU32 tetIndicesSize) = 0;
544
553 virtual void removeSoftBodyFilters(PxSoftBody* otherSoftBody, PxU32* otherTetIndices, PxU32* tetIndices, PxU32 tetIndicesSize) = 0;
554
568 virtual PxU32 addSoftBodyAttachment(PxSoftBody* softbody0, PxU32 tetIdx0, const PxVec4& tetBarycentric0, PxU32 tetIdx1, const PxVec4& tetBarycentric1,
569 PxConeLimitedConstraint* constraint = NULL) = 0;
570
580 virtual void removeSoftBodyAttachment(PxSoftBody* softbody0, PxU32 handle) = 0;
581
590 virtual void addClothFilter(PxFEMCloth* cloth, PxU32 triIdx, PxU32 tetIdx) = 0;
591
600 virtual void removeClothFilter(PxFEMCloth* cloth, PxU32 triIdx, PxU32 tetIdx) = 0;
601
602
620 virtual PxU32 addClothAttachment(PxFEMCloth* cloth, PxU32 triIdx, const PxVec4& triBarycentric, PxU32 tetIdx, const PxVec4& tetBarycentric,
621 PxConeLimitedConstraint* constraint = NULL) = 0;
622
635 virtual void removeClothAttachment(PxFEMCloth* cloth, PxU32 handle) = 0;
636
650
677
689
701
714 virtual PxBounds3 getWorldBounds(float inflation = 1.01f) const = 0;
715
721 virtual PxU32 getGpuSoftBodyIndex() = 0;
722
723 virtual const char* getConcreteTypeName() const PX_OVERRIDE { return "PxSoftBody"; }
724
725
726 protected:
727 PX_INLINE PxSoftBody(PxType concreteType, PxBaseFlags baseFlags) : PxActor(concreteType, baseFlags) {}
728 PX_INLINE PxSoftBody(PxBaseFlags baseFlags) : PxActor(baseFlags) {}
729 virtual bool isKindOf(const char* name) const PX_OVERRIDE { return !::strcmp("PxSoftBody", name) || PxActor::isKindOf(name); }
730 };
731
732#if PX_VC
733#pragma warning(pop)
734#endif
735
736
737#if !PX_DOXYGEN
738} // namespace physx
739#endif
740
742#endif
PxActor is the base class for the main simulation objects in the physics SDK.
Definition PxActor.h:201
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition PxActor.h:368
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
Buffer for delayed bulk read and write operations supporting host and GPU device memory spaces.
Definition PxBuffer.h:66
A particle system that uses the position based dynamics(PBD) solver.
Definition PxPBDParticleSystem.h:57
The shared base class for all particle buffers, can be instantiated directly to simulate granular and...
Definition PxParticleBuffer.h:81
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
Abstract class for collision shapes.
Definition PxShape.h:146
A data container providing mass, rest pose and other information required for softbody simulation.
Definition PxTetrahedronMesh.h:70
Represents a FEM softbody including everything to calculate its definition like geometry and material...
Definition PxSoftBody.h:104
virtual void addTetRigidFilter(PxRigidActor *actor, PxU32 tetIdx)=0
Creates collision filter between a tetrahedron in a soft body and a rigid body.
virtual bool isSleeping() const =0
Returns true if this soft body is sleeping.
virtual bool attachSimulationMesh(PxTetrahedronMesh &simulationMesh, PxSoftBodyAuxData &softBodyAuxData)=0
Attaches a simulation mesh.
virtual PxReal getWakeCounter() const =0
Returns the wake counter of the soft body.
virtual void removeClothFilter(PxFEMCloth *cloth, PxU32 triIdx, PxU32 tetIdx)=0
Removes collision filter between a tetrahedron in a soft body and a triangle in a cloth.
virtual PxU32 addSoftBodyAttachment(PxSoftBody *softbody0, PxU32 tetIdx0, const PxVec4 &tetBarycentric0, PxU32 tetIdx1, const PxVec4 &tetBarycentric1, PxConeLimitedConstraint *constraint=NULL)=0
Creates an attachment between two soft bodies.
virtual void addRigidFilter(PxRigidActor *actor, PxU32 vertId)=0
Creates a collision filter between a vertex in a soft body and a rigid body.
virtual void removeRigidAttachment(PxRigidActor *actor, PxU32 handle)=0
Releases a rigid attachment between a soft body and a rigid body. Be aware that destroying the rigid ...
virtual PxU32 getGpuSoftBodyIndex()=0
Returns the GPU soft body index.
virtual void writeData(PxSoftBodyData::Enum flags, PxBuffer &buffer, bool flush=false)=0
Issues a write command to the PxSoftBody.
virtual const char * getConcreteTypeName() const PX_OVERRIDE
Returns string name of dynamic type.
Definition PxSoftBody.h:723
virtual void setSoftBodyFlag(PxSoftBodyFlag::Enum flag, bool val)=0
Set a single softbody flag.
virtual void detachSimulationMesh()=0
Detaches the simulation mesh.
virtual PxSoftBodyAuxData * getSoftBodyAuxData()=0
Retrieves the simulation state pointer.
virtual void setWakeCounter(PxReal wakeCounterValue)=0
Sets the wake counter for the soft body.
virtual PxBounds3 getWorldBounds(float inflation=1.01f) const =0
Retrieves the axis aligned bounding box enclosing the soft body.
virtual PxBuffer * getPositionInvMassCPU()=0
Access to the vertices of the collision mesh on the host.
virtual void removeParticleFilter(PxPBDParticleSystem *particlesystem, const PxParticleBuffer *buffer, PxU32 particleId, PxU32 tetId)=0
Removes a collision filter between a particle and a tetrahedron in the soft body's collision mesh.
virtual void readData(PxSoftBodyData::Enum flags, bool flush=false)=0
Issues a read command to the PxSoftBody.
virtual void addParticleFilter(PxPBDParticleSystem *particlesystem, const PxParticleBuffer *buffer, PxU32 particleId, PxU32 tetId)=0
Creates a collision filter between a particle and a tetrahedron in the soft body's collision mesh.
virtual void getSolverIterationCounts(PxU32 &minPositionIters, PxU32 &minVelocityIters) const =0
Retrieves the solver iteration counts.
virtual PxCudaContextManager * getCudaContextManager() const =0
Return the cuda context manager.
virtual PxShape * getShape()=0
Retrieves the shape pointer belonging to the actor.
virtual void detachShape()=0
Detaches the shape.
virtual void readData(PxSoftBodyData::Enum flags, PxBuffer &buffer, bool flush=false)=0
Issues a read command to the PxSoftBody.
virtual PxTetrahedronMesh * getCollisionMesh()=0
Retrieve the collision mesh pointer.
virtual bool attachShape(PxShape &shape)=0
Attaches a shape.
virtual PxBuffer * getKinematicTargetCPU()=0
Access to the vertices of the simulation mesh on the host.
virtual PxU32 addParticleAttachment(PxPBDParticleSystem *particlesystem, const PxParticleBuffer *buffer, PxU32 particleId, PxU32 tetId, const PxVec4 &barycentric)=0
Creates an attachment between a particle and a soft body. Be aware that destroying the particle syste...
virtual void removeParticleAttachment(PxPBDParticleSystem *particlesystem, PxU32 handle)=0
Removes an attachment between a particle and a soft body. Be aware that destroying the particle syste...
virtual void setParameter(const PxFEMParameters parameters)=0
Set parameter for FEM internal solve.
virtual PxU32 addRigidAttachment(PxRigidActor *actor, PxU32 vertId, const PxVec3 &actorSpacePose, PxConeLimitedConstraint *constraint=NULL)=0
Creates a rigid attachment between a soft body and a rigid body. Be aware that destroying the rigid b...
virtual void removeSoftBodyFilter(PxSoftBody *otherSoftBody, PxU32 otherTetIdx, PxU32 tetIdx1)=0
Removes collision filter between a tetrahedron in a soft body and a tetrahedron in other soft body.
virtual void setSolverIterationCounts(PxU32 minPositionIters, PxU32 minVelocityIters=1)=0
Sets the solver iteration counts for the body.
virtual PxU32 addClothAttachment(PxFEMCloth *cloth, PxU32 triIdx, const PxVec4 &triBarycentric, PxU32 tetIdx, const PxVec4 &tetBarycentric, PxConeLimitedConstraint *constraint=NULL)=0
Creates an attachment between a soft body and a cloth. Be aware that destroying the rigid body before...
virtual void release()=0
Releases the softbody.
virtual PxU32 addTetRigidAttachment(PxRigidActor *actor, PxU32 tetIdx, const PxVec4 &barycentric, const PxVec3 &actorSpacePose, PxConeLimitedConstraint *constraint=NULL)=0
Creates a rigid attachment between a soft body and a rigid body. Be aware that destroying the rigid b...
virtual void removeTetRigidFilter(PxRigidActor *actor, PxU32 tetIdx)=0
Removes collision filter between a tetrahedron in a soft body and a rigid body.
virtual void addSoftBodyFilter(PxSoftBody *otherSoftBody, PxU32 otherTetIdx, PxU32 tetIdx1)=0
Creates collision filter between a tetrahedron in a soft body and a tetrahedron in another soft body.
virtual void removeClothAttachment(PxFEMCloth *cloth, PxU32 handle)=0
Releases an attachment between a cloth and a soft body. Be aware that destroying the cloth before des...
virtual bool isKindOf(const char *name) const PX_OVERRIDE
Returns whether a given type name matches with the type of this instance.
Definition PxSoftBody.h:729
virtual PxTetrahedronMesh * getSimulationMesh()=0
Retrieves the simulation mesh pointer.
virtual PxSoftBodyFlags getSoftBodyFlag() const =0
Get the softbody flags.
virtual void writeData(PxSoftBodyData::Enum flags, bool flush=false)=0
Issues a write command to the PxSoftBody.
virtual void setSoftBodyFlags(PxSoftBodyFlags flags)=0
Set the softbody flags.
virtual void addSoftBodyFilters(PxSoftBody *otherSoftBody, PxU32 *otherTetIndices, PxU32 *tetIndices, PxU32 tetIndicesSize)=0
Creates collision filters between a tetrahedron in a soft body with another soft body.
virtual PxFEMParameters getParameter() const =0
Get parameter for FEM internal solve.
virtual void removeSoftBodyFilters(PxSoftBody *otherSoftBody, PxU32 *otherTetIndices, PxU32 *tetIndices, PxU32 tetIndicesSize)=0
Removes collision filters between a tetrahedron in a soft body with another soft body.
virtual void removeRigidFilter(PxRigidActor *actor, PxU32 vertId)=0
Removes a collision filter between a vertex in a soft body and a rigid body.
virtual PxBuffer * getSimVelocityInvMassCPU()=0
Access to the velocities of the simulation mesh on the host.
virtual PxBuffer * getRestPositionInvMassCPU()=0
Access to the rest vertices of the collision mesh on the host.
virtual void removeSoftBodyAttachment(PxSoftBody *softbody0, PxU32 handle)=0
Releases an attachment between a soft body and the other soft body. Be aware that destroying the soft...
virtual PxBuffer * getSimPositionInvMassCPU()=0
Access to the vertices of the simulation mesh on the host.
virtual void addClothFilter(PxFEMCloth *cloth, PxU32 triIdx, PxU32 tetIdx)=0
Creates collision filter between a tetrahedron in a soft body and a triangle in a cloth.
A tetramedron mesh, also called a 'tetrahedron soup'.
Definition PxTetrahedronMesh.h:115
3 Element vector class.
Definition PxVec3.h:50
Definition PxVec4.h:50
#define PX_OVERRIDE
Definition PxPreprocessor.h:375
#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
A constraint descriptor for limiting movement to a conical region.
Definition PxConeLimitedConstraint.h:48
Set of parameters to control the sleeping and collision behavior of FEM based objects.
Definition PxFEMParameter.h:45
Identifies input and output buffers for PxSoftBody.
Definition PxSoftBody.h:66
Enum
Definition PxSoftBody.h:68
@ eSIM_KINEMATIC_TARGET
Flag to request access to the simulation mesh's kinematic target position.
Definition PxSoftBody.h:74
@ eSIM_POSITION_INVMASS
Flag to request access to the simulation mesh's positions and inverse masses.
Definition PxSoftBody.h:72
@ eSIM_VELOCITY
Flag to request access to the simulation mesh's velocities and inverse masses.
Definition PxSoftBody.h:73
@ ePOSITION_INVMASS
Flag to request access to the collision mesh's positions; read only.
Definition PxSoftBody.h:71
Flags to enable or disable special modes of a SoftBody.
Definition PxSoftBody.h:86
Enum
Definition PxSoftBody.h:88
@ eDISABLE_SELF_COLLISION
Determines if self collision will be detected and resolved.
Definition PxSoftBody.h:89
@ eDISPLAY_SIM_MESH
Enable debug rendering to display the simulation mesh.
Definition PxSoftBody.h:92
@ eENABLE_CCD
Enables support for continuous collision detection.
Definition PxSoftBody.h:91
@ eKINEMATIC
Enables support for kinematic motion of the collision and simulation mesh.
Definition PxSoftBody.h:93
@ eCOMPUTE_STRESS_TENSOR
Enables computation of a Cauchy stress tensor for every tetrahedron in the simulation mesh....
Definition PxSoftBody.h:90
@ ePARTIALLY_KINEMATIC
Enables partially kinematic motion of the collisios and simulation mesh.
Definition PxSoftBody.h:94