PxSoftBodyExt
Defined in include/extensions/PxSoftBodyExt.h

class PxSoftBodyExt
utility functions for use with PxSoftBody and subclasses
Public Static Functions

static void updateMass(PxSoftBody &softBody, const PxReal density, const PxReal maxInvMassRatio)
Computes the SoftBody’s vertex masses from the provided density and the volume of the tetrahedra.
The buffers affected by this operation can be obtained from the SoftBody using the methods getSimPositionInvMassCPU() and getSimVelocityInvMassCPU()
The inverse mass is stored in the 4th component (the first three components are x, y, z coordinates) of the simulation mesh’s position and velocity buffer. Performance optimizations are the reason why the mass inverse is stored in two locations.
 Parameters
softBody – [in] The soft body 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

static void setMass(PxSoftBody &softBody, const PxReal mass, const PxReal maxInvMassRatio)
Computes the SoftBody’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 SoftBody using the methods getSimPositionInvMassCPU() and getSimVelocityInvMassCPU()
The inverse mass is stored in the 4th component (the first three components are x, y, z coordinates) of the simulation mesh’s position and velocity buffer. Performance optimizations are the reason why the mass inverse is stored in two locations.
 Parameters
softBody – [in] The soft body which will get its mass updated
mass – [in] The SoftBody’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

static void transform(PxSoftBody &softBody, const PxTransform &transform, const PxReal scale)
Transforms a SoftBody.
The buffers affected by this operation can be obtained from the SoftBody using the methods getSimPositionInvMassCPU() and getSimVelocityInvMassCPU()
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.
 Parameters
softBody – [in] The soft body which is transformed
transform – [in] The transform to apply
scale – [in] A scaling factor

static void updateEmbeddedCollisionMesh(PxSoftBody &softBody)
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 SoftBody using the method getPositionInvMassCPU()
 Parameters
softBody – [in] The soft body which will get its collision mesh vertices updated

static void commit(PxSoftBody &softBody, PxSoftBodyDataFlags flags, bool flush = false)
Uploads prepared SoftBody data to the GPU.
It ensures that the embedded collision mesh matches the simulation mesh’s transformation and scale.
See also
 Parameters
softBody – [in] The soft body which will perform the data upload
flags – [in] Specifies which buffers the data transfer should include
flush – [in] If set to true, the upload will get processed immediately, otherwise it will take place before the data is needed for calculations on the GPU

static PxSoftBodyMesh *createSoftBodyMesh(const PxCookingParams ¶ms, const PxSimpleTriangleMesh &surfaceMesh, PxU32 numVoxelsAlongLongestAABBAxis, PxInsertionCallback &insertionCallback, const bool validate = true)
Creates a full SoftBody mesh matching the shape given as input.
Uses a voxel mesh for FEM simulation and a surfacematching mesh for collision detection.
See also
 Parameters
params – [in] Cooking params instance required for mesh processing
surfaceMesh – [in] Input triangle mesh that represents the surface of the SoftBody
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
SoftBody mesh if cooking was successful, NULL otherwise

static PxSoftBodyMesh *createSoftBodyMeshNoVoxels(const PxCookingParams ¶ms, const PxSimpleTriangleMesh &surfaceMesh, PxInsertionCallback &insertionCallback, PxReal maxWeightRatioInTet = 1.5f, const bool validate = true)
Creates a full SoftBody mesh matching the shape given as input.
Uses the same surfacematching mesh for collision detection and FEM simulation.
See also
 Parameters
params – [in] Cooking params instance required for mesh processing
surfaceMesh – [in] Input triangle mesh that represents the surface of the SoftBody
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
SoftBody mesh if cooking was successful, NULL otherwise

static PxSoftBody *createSoftBodyFromMesh(PxSoftBodyMesh *softBodyMesh, const PxTransform &transform, const PxFEMSoftBodyMaterial &material, PxCudaContextManager &cudaContextManager, PxReal density = 100.0f, PxU32 solverIterationCount = 30, const PxFEMParameters &femParams = PxFEMParameters(), PxReal scale = 1.0f)
Creates a SoftBody instance from a SoftBody mesh.
See also
 Parameters
softBodyMesh – [in] The SoftBody mesh
transform – [in] The transform that defines initial position and orientation of the SoftBody
material – [in] The material
cudaContextManager – [in] A cuda context manager
density – [in] The density used to compute the mass properties
solverIterationCount – [in] The number of iterations the solver should apply during simulation
femParams – [in] Additional parameters to specify e. g. damping
scale – [in] The scaling of the SoftBody
 Returns
SoftBody instance

static PxSoftBody *createSoftBodyBox(const PxTransform &transform, const PxVec3 &boxDimensions, const PxFEMSoftBodyMaterial &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)
Creates a SoftBody instance with a box shape.
See also
 Parameters
transform – [in] The transform that defines initial position and orientation of the SoftBody
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
solverIterationCount – [in] The number of iterations the solver should apply during simulation
femParams – [in] Additional parameters to specify e. g. damping
numVoxelsAlongLongestAABBAxis – [in] The number of voxels to use for the simulation mesh along the longest bounding box dimension
scale – [in] The scaling of the SoftBody
 Returns
SoftBody instance

static void updateMass(PxSoftBody &softBody, const PxReal density, const PxReal maxInvMassRatio)