RavEngine
Loading...
Searching...
No Matches
physx::PxSoftBodyExt Class Reference

utility functions for use with PxSoftBody and subclasses More...

#include <PxSoftBodyExt.h>

Static Public Member 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.
 
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.
 
static void transform (PxSoftBody &softBody, const PxTransform &transform, const PxReal scale)
 Transforms a SoftBody.
 
static void updateEmbeddedCollisionMesh (PxSoftBody &softBody)
 Updates the collision mesh's vertex positions to match the simulation mesh's transformation and scale.
 
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.
 
static PxSoftBodyMesh * createSoftBodyMesh (const PxCookingParams &params, 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 surface-matching mesh for collision detection.
 
static PxSoftBodyMesh * createSoftBodyMeshNoVoxels (const PxCookingParams &params, 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 surface-matching mesh for collision detection and FEM simulation.
 
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.
 
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.
 

Detailed Description

utility functions for use with PxSoftBody and subclasses

Member Function Documentation

◆ commit()

void PxSoftBodyExt::commit ( PxSoftBody &  softBody,
PxSoftBodyDataFlags  flags,
bool  flush = false 
)
static

Uploads prepared SoftBody data to the GPU. It ensures that the embedded collision mesh matches the simulation mesh's transformation and scale.

Parameters
[in]softBodyThe soft body which will perform the data upload
[in]flagsSpecifies which buffers the data transfer should include
[in]flushIf set to true, the upload will get processed immediately, otherwise it will take place before the data is needed for calculations on the GPU
See also
PxSoftBody

◆ createSoftBodyBox()

PxSoftBody * PxSoftBodyExt::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 
)
static

Creates a SoftBody instance with a box shape.

Parameters
[in]transformThe transform that defines initial position and orientation of the SoftBody
[in]boxDimensionsThe dimensions (side lengths) of the box shape
[in]materialThe material
[in]cudaContextManagerA cuda context manager
[in]maxEdgeLengthThe maximal length of a triangle edge. Subdivision will get applied until the edge length criteria is matched. -1 means no subdivision is applied.
[in]densityThe density used to compute the mass properties
[in]solverIterationCountThe number of iterations the solver should apply during simulation
[in]femParamsAdditional parameters to specify e. g. damping
[in]numVoxelsAlongLongestAABBAxisThe number of voxels to use for the simulation mesh along the longest bounding box dimension
[in]scaleThe scaling of the SoftBody
Returns
SoftBody instance
See also
PxSoftBodyMesh, PxSoftBody

◆ createSoftBodyFromMesh()

PxSoftBody * PxSoftBodyExt::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 
)
static

Creates a SoftBody instance from a SoftBody mesh.

Parameters
[in]softBodyMeshThe SoftBody mesh
[in]transformThe transform that defines initial position and orientation of the SoftBody
[in]materialThe material
[in]cudaContextManagerA cuda context manager
[in]densityThe density used to compute the mass properties
[in]solverIterationCountThe number of iterations the solver should apply during simulation
[in]femParamsAdditional parameters to specify e. g. damping
[in]scaleThe scaling of the SoftBody
Returns
SoftBody instance
See also
PxSoftBodyMesh, PxSoftBody

◆ createSoftBodyMesh()

PxSoftBodyMesh * PxSoftBodyExt::createSoftBodyMesh ( const PxCookingParams &  params,
const PxSimpleTriangleMesh &  surfaceMesh,
PxU32  numVoxelsAlongLongestAABBAxis,
PxInsertionCallback &  insertionCallback,
const bool  validate = true 
)
static

Creates a full SoftBody mesh matching the shape given as input. Uses a voxel mesh for FEM simulation and a surface-matching mesh for collision detection.

Parameters
[in]paramsCooking params instance required for mesh processing
[in]surfaceMeshInput triangle mesh that represents the surface of the SoftBody
[in]numVoxelsAlongLongestAABBAxisThe number of voxels along the longest bounding box axis
[in]insertionCallbackThe insertion interface from PxPhysics
[in]validateIf set to true the input triangle mesh will get analyzed to find possible deficiencies
Returns
SoftBody mesh if cooking was successful, NULL otherwise
See also
PxSoftBodyMesh

◆ createSoftBodyMeshNoVoxels()

PxSoftBodyMesh * PxSoftBodyExt::createSoftBodyMeshNoVoxels ( const PxCookingParams &  params,
const PxSimpleTriangleMesh &  surfaceMesh,
PxInsertionCallback &  insertionCallback,
PxReal  maxWeightRatioInTet = 1.5f,
const bool  validate = true 
)
static

Creates a full SoftBody mesh matching the shape given as input. Uses the same surface-matching mesh for collision detection and FEM simulation.

Parameters
[in]paramsCooking params instance required for mesh processing
[in]surfaceMeshInput triangle mesh that represents the surface of the SoftBody
[in]insertionCallbackThe insertion interface from PxPhysics
[in]maxWeightRatioInTetUpper 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.
[in]validateIf set to true the input triangle mesh will get analyzed to find possible deficiencies
Returns
SoftBody mesh if cooking was successful, NULL otherwise
See also
PxSoftBodyMesh

◆ setMass()

void PxSoftBodyExt::setMass ( PxSoftBody &  softBody,
const PxReal  mass,
const PxReal  maxInvMassRatio 
)
static

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
[in]softBodyThe soft body which will get its mass updated
[in]massThe SoftBody's mass
[in]maxInvMassRatioMaximum 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
See also
PxSoftBody PxSoftBody::getSimPositionInvMassCPU() PxSoftBody::getSimVelocityInvMassCPU()

◆ transform()

void PxSoftBodyExt::transform ( PxSoftBody &  softBody,
const PxTransform &  transform,
const PxReal  scale 
)
static

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
[in]softBodyThe soft body which is transformed
[in]transformThe transform to apply
[in]scaleA scaling factor
See also
PxSoftBody PxSoftBody::getSimPositionInvMassCPU() PxSoftBody::getSimVelocityInvMassCPU()

◆ updateEmbeddedCollisionMesh()

void PxSoftBodyExt::updateEmbeddedCollisionMesh ( PxSoftBody &  softBody)
static

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
[in]softBodyThe soft body which will get its collision mesh vertices updated
See also
PxSoftBody PxSoftBody::getPositionInvMassCPU()

◆ updateMass()

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

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
[in]softBodyThe soft body which will get its mass updated
[in]densityThe density to used to calculate the mass from the body's volume
[in]maxInvMassRatioMaximum 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
See also
PxSoftBody PxSoftBody::getSimPositionInvMassCPU() PxSoftBody::getSimVelocityInvMassCPU()

The documentation for this class was generated from the following files: