PxDeformableVolumeExt
Defined in include/extensions/PxDeformableVolumeExt.h
-
class PxDeformableVolumeExt
Utility functions for use with PxDeformableVolume and subclasses.
Public Static Functions
-
static void updateMass(PxDeformableVolume &deformableVolume, const PxReal density, const PxReal maxInvMassRatio, PxVec4 *simPositionsPinned)
Computes the deformable volume’s vertex masses from the provided density and the volume of the tetrahedra.
The buffers affected by this operation can be obtained from the deformable volume using the methods getSimPositionInvMassBufferD() and getSimVelocityBufferD()
The inverse mass is stored in the 4th component (the first three components are x, y, z coordinates) of the simulation mesh’s position buffer.
See also
PxDeformableVolume PxDeformableVolume::getSimPositionInvMassBufferD()
- Parameters
deformableVolume – [in] The deformable volume which will get its mass updated
density – [in] The density to used to calculate the mass from the body’s volume
maxInvMassRatio – [in] Maximum allowed ratio defined as max(vertexMasses) / min(vertexMasses) where vertexMasses is a list of float values with a mass for every vertex in the simulation mesh
simPositionsPinned – [in] A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh.
-
static void setMass(PxDeformableVolume &deformableVolume, const PxReal mass, const PxReal maxInvMassRatio, PxVec4 *simPositionsPinned)
Computes the deformable volume’s vertex masses such that the sum of all masses is equal to the provided mass.
The buffers affected by this operation can be obtained from the deformable volume using the methods getSimPositionInvMassBufferD()) and getSimVelocityBufferD()
The inverse mass is stored in the 4th component (the first three components are x, y, z coordinates) of the simulation mesh’s position buffer.
See also
PxDeformableVolume PxDeformableVolume::getSimPositionInvMassBufferD()
- Parameters
deformableVolume – [in] The deformable volume which will get its mass updated
mass – [in] The deformable volume’s mass
maxInvMassRatio – [in] Maximum allowed ratio defined as max(vertexMasses) / min(vertexMasses) where vertexMasses is a list of float values with a mass for every vertex in the simulation mesh
simPositionsPinned – [in] A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh.
-
static void transform(PxDeformableVolume &deformableVolume, const PxTransform &transform, const PxReal scale, PxVec4 *simPositionsPinned, PxVec4 *simVelocitiesPinned, PxVec4 *collPositionsPinned, PxVec4 *restPositionsPinned)
Transforms a deformable volume.
The buffers affected by this operation can be obtained from the deformable volume using the methods getSimPositionInvMassBufferD() and getSimVelocityBufferD()
Applies a transformation to the simulation mesh’s positions an velocities. Velocities only get rotated and scaled (translation is not applicable to direction vectors). It does not modify the body’s mass. If the method is called multiple times, the transformation will compound with the ones previously applied.
See also
PxDeformableVolume
- Parameters
deformableVolume – [in] The deformable volume which is transformed
transform – [in] The transform to apply
scale – [in] A scaling factor
simPositionsPinned – [in] A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh.
simVelocitiesPinned – [in] A pointer to a pinned host memory buffer containing velocities for each vertex of the simulation mesh.
collPositionsPinned – [in] A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the collision mesh.
restPositionsPinned – [in] A pointer to a pinned host memory buffer containing rest positions of the collision mesh.
-
static void updateEmbeddedCollisionMesh(PxDeformableVolume &deformableVolume, PxVec4 *simPositionsPinned, PxVec4 *collPositionsPinned)
Updates the collision mesh’s vertex positions to match the simulation mesh’s transformation and scale.
The buffer affected by this operation can be obtained from the deformable volume using the method getPositionInvMassBufferD()
See also
PxDeformableVolume
- Parameters
deformableVolume – [in] The deformable volume which will get its collision mesh vertices updated
simPositionsPinned – [in] A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh.
collPositionsPinned – [in] A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the collision mesh.
-
static void copyToDevice(PxDeformableVolume &deformableVolume, PxDeformableVolumeDataFlags flags, PxVec4 *simPositionsPinned, PxVec4 *simVelocitiesPinned, PxVec4 *collPositionsPinned, PxVec4 *restPositionsPinned, CUstream stream = CUstream(0))
Uploads prepared deformable volume data to the GPU.
It ensures that the embedded collision mesh matches the simulation mesh’s transformation and scale.
See also
PxDeformableVolume
- Parameters
deformableVolume – [in] The deformable volume which will perform the data upload
flags – [in] Specifies which buffers the data transfer should include
simPositionsPinned – [in] A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the simulation mesh.
simVelocitiesPinned – [in] A pointer to a pinned host memory buffer containing velocities for each vertex of the simulation mesh.
collPositionsPinned – [in] A pointer to a pinned host memory buffer containing positions and inverse masses for each vertex of the collision mesh.
restPositionsPinned – [in] A pointer to a pinned host memory buffer containing rest positions of the collision mesh.
stream – [in] A cuda stream to perform the copies.
-
static PxDeformableVolumeMesh *createDeformableVolumeMesh(const PxCookingParams ¶ms, const PxSimpleTriangleMesh &surfaceMesh, PxU32 numVoxelsAlongLongestAABBAxis, PxInsertionCallback &insertionCallback, const bool validate = true)
Creates a full deformable volume mesh matching the shape given as input.
Uses a voxel mesh for FEM simulation and a surface-matching mesh for collision detection.
See also
PxDeformableVolumeMesh
- Parameters
params – [in] Cooking params instance required for mesh processing
surfaceMesh – [in] Input triangle mesh that represents the surface of the deformable volume
numVoxelsAlongLongestAABBAxis – [in] The number of voxels along the longest bounding box axis
insertionCallback – [in] The insertion interface from PxPhysics
validate – [in] If set to true the input triangle mesh will get analyzed to find possible deficiencies
- Returns
Deformable volume mesh if cooking was successful, NULL otherwise
-
static inline PxDeformableVolumeMesh *createSoftBodyMesh(const PxCookingParams ¶ms, const PxSimpleTriangleMesh &surfaceMesh, PxU32 numVoxelsAlongLongestAABBAxis, PxInsertionCallback &insertionCallback, const bool validate = true)
Deprecated.
See also
createDeformableVolumeMesh
-
static PxDeformableVolumeMesh *createDeformableVolumeMeshNoVoxels(const PxCookingParams ¶ms, const PxSimpleTriangleMesh &surfaceMesh, PxInsertionCallback &insertionCallback, PxReal maxWeightRatioInTet = 1.5f, const bool validate = true)
Creates a full deformable volume mesh matching the shape given as input.
Uses the same surface-matching mesh for collision detection and FEM simulation.
See also
PxDeformableVolumeMesh
- Parameters
params – [in] Cooking params instance required for mesh processing
surfaceMesh – [in] Input triangle mesh that represents the surface of the deformable volume
insertionCallback – [in] The insertion interface from PxPhysics
maxWeightRatioInTet – [in] Upper limit for the ratio of node weights that are adjacent to the same tetrahedron. The closer to one (while remaining larger than one), the more stable the simulation.
validate – [in] If set to true the input triangle mesh will get analyzed to find possible deficiencies
- Returns
Deformable volume mesh if cooking was successful, NULL otherwise
-
static inline PxDeformableVolumeMesh *createSoftBodyMeshNoVoxels(const PxCookingParams ¶ms, const PxSimpleTriangleMesh &surfaceMesh, PxInsertionCallback &insertionCallback, PxReal maxWeightRatioInTet = 1.5f, const bool validate = true)
Deprecated.
See also
createDeformableVolumeMeshNoVoxels
-
static PxDeformableVolume *createDeformableVolumeFromMesh(PxDeformableVolumeMesh *deformableVolumeMesh, const PxTransform &transform, const PxDeformableVolumeMaterial &material, PxCudaContextManager &cudaContextManager, PxReal density = 100.0f, PxReal scale = 1.0f)
Creates a deformable volume instance from a deformable volume mesh.
See also
PxDeformableVolumeMesh, PxDeformableVolume
- Parameters
deformableVolumeMesh – [in] The deformable volume mesh
transform – [in] The transform that defines initial position and orientation of the deformable volume
material – [in] The material
cudaContextManager – [in] A cuda context manager
density – [in] The density used to compute the mass properties
scale – [in] The scaling of the deformable volume
- Returns
Deformable volume instance
-
static inline PxDeformableVolume *createSoftBodyFromMesh(PxDeformableVolumeMesh *deformableVolumeMesh, const PxTransform &transform, const PxDeformableVolumeMaterial &material, PxCudaContextManager &cudaContextManager, PxReal density = 100.0f, PxU32 solverIterationCount = 30, const PxFEMParameters &femParams = PxFEMParameters(), PxReal scale = 1.0f)
Deprecated.
See also
createDeformableVolumeFromMesh
-
static PxDeformableVolume *createDeformableVolumeBox(const PxTransform &transform, const PxVec3 &boxDimensions, const PxDeformableVolumeMaterial &material, PxCudaContextManager &cudaContextManager, PxReal maxEdgeLength = -1.0f, PxReal density = 100.0f, PxU32 numVoxelsAlongLongestAABBAxis = 10, PxReal scale = 1.0f)
Creates a deformable volume instance with a box shape.
See also
PxDeformableVolumeMesh, PxDeformableVolume
- Parameters
transform – [in] The transform that defines initial position and orientation of the deformable volume
boxDimensions – [in] The dimensions (side lengths) of the box shape
material – [in] The material
cudaContextManager – [in] A cuda context manager
maxEdgeLength – [in] The maximal length of a triangle edge. Subdivision will get applied until the edge length criteria is matched. -1 means no subdivision is applied.
density – [in] The density used to compute the mass properties
numVoxelsAlongLongestAABBAxis – [in] The number of voxels to use for the simulation mesh along the longest bounding box dimension
scale – [in] The scaling of the deformable volume
- Returns
Deformable volume instance
-
static inline PxDeformableVolume *createSoftBodyBox(const PxTransform &transform, const PxVec3 &boxDimensions, const PxDeformableVolumeMaterial &material, PxCudaContextManager &cudaContextManager, PxReal maxEdgeLength = -1.0f, PxReal density = 100.0f, PxU32 solverIterationCount = 30, const PxFEMParameters &femParams = PxFEMParameters(), PxU32 numVoxelsAlongLongestAABBAxis = 10, PxReal scale = 1.0f)
Deprecated.
See also
createDeformableVolumeBox
-
static void allocateAndInitializeHostMirror(PxDeformableVolume &deformableVolume, PxCudaContextManager *cudaContextManager, PxVec4 *&simPositionInvMassPinned, PxVec4 *&simVelocityPinned, PxVec4 *&collPositionInvMassPinned, PxVec4 *&restPositionPinned)
allocates and initializes pinned host memory buffers from an actor with shape.
See also
PxDeformableVolume
- Parameters
deformableVolume – [in] A PxDeformableVolume that has a valid shape attached to it.
cudaContextManager – [in] The PxCudaContextManager of the scene this deformable volume will be simulated in
simPositionInvMassPinned – [in] A reference to a pointer for the return value of the simPositionInvMassPinned buffer, will be set by this function.
simVelocityPinned – [in] A reference to a pointer for the return value of the simVelocityPinned buffer, will be set by this function.
collPositionInvMassPinned – [in] A reference to a pointer for the return value of the collPositionInvMassPinned buffer, will be set by this function.
restPositionPinned – [in] A reference to a pointer for the return value of the restPositionPinned buffer, will be set by this function.
-
static void relaxDeformableVolumeMesh(const PxVec4 *verticesOriginal, PxVec4 *verticesDeformed, PxU32 nbVertices, const PxU32 *tetrahedra, PxU32 nbTetraheda, const bool *vertexIsFixed = NULL, PxU32 numIterations = 200)
Given a set of points and a set of tetrahedra, it finds the equilibrium state of the deformable volume.
Every input point is either fixed or can move freely.
- Parameters
verticesOriginal – [in] Mesh vertex positions in undeformed original state.
verticesDeformed – [in] Mesh vertex positions in new deformed state. Only fixed vertices must have their final location, all other locations will get updated by the method.
nbVertices – [in] The number of vertices.
tetrahedra – [in] The tetrahedra.
nbTetraheda – [in] The number of tetrahedra.
vertexIsFixed – [in] Optional input that specifies which vertex is fixed and which one can move to relax the tension. If not provided, vertices from verticesOriginal which have a .w value of 0 will be considered fixed.
numIterations – [in] The number of stress relaxation iterations to run.
-
static inline void relaxSoftBodyMesh(const PxVec4 *verticesOriginal, PxVec4 *verticesDeformed, PxU32 nbVertices, const PxU32 *tetrahedra, PxU32 nbTetraheda, const bool *vertexIsFixed = NULL, PxU32 numIterations = 200)
Deprecated.
See also
relaxDeformableVolumeMesh
-
static void convertCollisionToSimulationTet(PxDeformableVolume &deformableVolume, PxU32 tetId, const PxVec4 &tetBarycentric, PxU32 &outTetId, PxVec4 &outTetBarycentric)
Converts the tet id and barycentric from the collision mesh to the tet id and barycentric of the simulation mesh.
- Parameters
deformableVolume – [in] The deformable volume to perform the operation on.
tetId – [in] The tet id of the deformable volume’s collision mesh.
tetBarycentric – [in] The barycentric coordinates of the tetrahedron specified with tetId.
outTetId – [out] The tet id of the deformable volume’s simulation mesh.
outTetBarycentric – [out] The barycentric coordinates of the tetrahedron specified with outTetId.
-
static void updateMass(PxDeformableVolume &deformableVolume, const PxReal density, const PxReal maxInvMassRatio, PxVec4 *simPositionsPinned)