| FLEX 1.1.0

Data Structures | Typedefs | Enumerations | Functions
NvFlexExt.h File Reference

Go to the source code of this file.

## Data Structures
struct | NvFlexVector< T >
struct | NvFlexExtMovingFrame
struct | NvFlexExtAsset
struct | NvFlexExtInstance
struct | NvFlexExtTearingParticleClone
struct | NvFlexExtTearingMeshEdit
struct | NvFlexExtParticleData
struct | NvFlexExtTriangleData
struct | NvFlexExtShapeData
struct | NvFlexExtForceField

## Typedefs
typedef struct NvFlexExtContainer | NvFlexExtContainer
typedef struct NvFlexExtForceFieldCallback | NvFlexExtForceFieldCallback

## Enumerations
enum | NvFlexExtForceMode { eNvFlexExtModeForce = 0, eNvFlexExtModeImpulse = 1, eNvFlexExtModeVelocityChange = 2 }

## Functions
NV_FLEX_API void | NvFlexExtMovingFrameInit (NvFlexExtMovingFrame *frame, const float *worldTranslation, const float *worldRotation)
NV_FLEX_API void | NvFlexExtMovingFrameUpdate (NvFlexExtMovingFrame *frame, const float *worldTranslation, const float *worldRotation, float dt)
NV_FLEX_API void | NvFlexExtMovingFrameApply (NvFlexExtMovingFrame *frame, float *positions, float *velocities, int numParticles, float linearScale, float angularScale, float dt)
NV_FLEX_API int | NvFlexExtCreateWeldedMeshIndices (const float *vertices, int numVertices, int *uniqueVerts, int *originalToUniqueMap, float threshold)
NV_FLEX_API NvFlexExtAsset * | NvFlexExtCreateClothFromMesh (const float *particles, int numParticles, const int *indices, int numTriangles, float stretchStiffness, float bendStiffness, float tetherStiffness, float tetherGive, float pressure)
NV_FLEX_API NvFlexExtAsset * | NvFlexExtCreateTearingClothFromMesh (const float *particles, int numParticles, int maxParticles, const int *indices, int numTriangles, float stretchStiffness, float bendStiffness, float pressure)
NV_FLEX_API void | NvFlexExtDestroyTearingCloth (NvFlexExtAsset *asset)
NV_FLEX_API void | NvFlexExtTearClothMesh (NvFlexExtAsset *asset, float maxStrain, int maxSplits, NvFlexExtTearingParticleClone *particleCopies, int *numParticleCopies, int maxCopies, NvFlexExtTearingMeshEdit *triangleEdits, int *numTriangleEdits, int maxEdits)
NV_FLEX_API NvFlexExtAsset * | NvFlexExtCreateRigidFromMesh (const float *vertices, int numVertices, const int *indices, int numTriangleIndices, float radius, float expand)
NV_FLEX_API NvFlexExtAsset * | NvFlexExtCreateSoftFromMesh (const float *vertices, int numVertices, const int *indices, int numTriangleIndices, float particleSpacing, float volumeSampling, float surfaceSampling, float clusterSpacing, float clusterRadius, float clusterStiffness, float linkRadius, float linkStiffness, float globalStiffness)
NV_FLEX_API void | NvFlexExtDestroyAsset (NvFlexExtAsset *asset)
NV_FLEX_API void | NvFlexExtCreateSoftMeshSkinning (const float *vertices, int numVertices, const float *bones, int numBones, float falloff, float maxDistance, float *skinningWeights, int *skinningIndices)
NV_FLEX_API NvFlexExtContainer * | NvFlexExtCreateContainer (NvFlexLibrary *lib, NvFlexSolver *solver, int maxParticles)
NV_FLEX_API void | NvFlexExtDestroyContainer (NvFlexExtContainer *container)
NV_FLEX_API int | NvFlexExtAllocParticles (NvFlexExtContainer *container, int n, int *indices)
NV_FLEX_API void | NvFlexExtFreeParticles (NvFlexExtContainer *container, int n, const int *indices)
NV_FLEX_API int | NvFlexExtGetActiveList (NvFlexExtContainer *container, int *indices)
NV_FLEX_API NvFlexExtParticleData | NvFlexExtMapParticleData (NvFlexExtContainer *container)
NV_FLEX_API void | NvFlexExtUnmapParticleData (NvFlexExtContainer *container)
NV_FLEX_API NvFlexExtTriangleData | NvFlexExtMapTriangleData (NvFlexExtContainer *container)
NV_FLEX_API void | NvFlexExtUnmapTriangleData (NvFlexExtContainer *container)
NV_FLEX_API NvFlexExtShapeData | NvFlexExtMapShapeData (NvFlexExtContainer *container)
NV_FLEX_API void | NvFlexExtUnmapShapeData (NvFlexExtContainer *container)
NV_FLEX_API NvFlexExtInstance * | NvFlexExtCreateInstance (NvFlexExtContainer *container, NvFlexExtParticleData *particleData, const NvFlexExtAsset *asset, const float *transform, float vx, float vy, float vz, int phase, float invMassScale)
NV_FLEX_API void | NvFlexExtDestroyInstance (NvFlexExtContainer *container, const NvFlexExtInstance *instance)
NV_FLEX_API void | NvFlexExtNotifyAssetChanged (NvFlexExtContainer *container, const NvFlexExtAsset *asset)
NV_FLEX_API void | NvFlexExtTickContainer (NvFlexExtContainer *container, float dt, int numSubsteps, bool enableTimers=false)
NV_FLEX_API void | NvFlexExtPushToDevice (NvFlexExtContainer *container)
NV_FLEX_API void | NvFlexExtPullFromDevice (NvFlexExtContainer *container)
NV_FLEX_API void | NvFlexExtUpdateInstances (NvFlexExtContainer *container)
NV_FLEX_API NvFlexExtForceFieldCallback * | NvFlexExtCreateForceFieldCallback (NvFlexSolver *solver)
NV_FLEX_API void | NvFlexExtDestroyForceFieldCallback (NvFlexExtForceFieldCallback *callback)
NV_FLEX_API void | NvFlexExtSetForceFields (NvFlexExtForceFieldCallback *callback, const NvFlexExtForceField *forceFields, int numForceFields)

## Detailed Description

The main include file for the Flex extensions API, this is a collection of helper functions for asset creation, scene management, and sample code that builds on the Flex core API.

## Data Structure Documentation

struct NvFlexExtMovingFrame

Helper struct for storing the state of a moving frame, see NvFlexExtMovingFrameInit()

Data Fields
float | position[3] |
float | rotation[4] |
float | velocity[3] |
float | omega[3] |
float | acceleration[3] |
float | tau[3] |
float | delta[4][4] |

struct NvFlexExtAsset

Represents a group of particles and constraints, each asset can be instanced into a container using NvFlexExtCreateInstance()

Data Fields
float * | particles | Local space particle positions, x,y,z,1/mass.
int | numParticles | Number of particles.
int | maxParticles | Maximum number of particles, allows extra space for tearable assets which duplicate particles.
int * | springIndices | Spring indices.
float * | springCoefficients | Spring coefficients.
float * | springRestLengths | Spring rest-lengths.
int | numSprings | Number of springs.
int * | shapeIndices | The indices of the shape matching constraints.
int | numShapeIndices | Total number of indices for shape constraints.
int * | shapeOffsets | Each entry stores the end of the shape's indices in the indices array (exclusive prefix sum of shape lengths)
float * | shapeCoefficients | The stiffness coefficient for each shape.
float * | shapeCenters | The position of the center of mass of each shape, an array of vec3s mNumShapes in length.
int | numShapes | The number of shape matching constraints.
int * | triangleIndices | Indexed triangle mesh indices for clothing.
int | numTriangles | Number of triangles.
bool | inflatable | Whether an inflatable constraint should be added.
float | inflatableVolume | The rest volume for the inflatable constraint.
float | inflatablePressure | How much over the rest volume the inflatable should attempt to maintain.
float | inflatableStiffness | How stiff the inflatable is.

struct NvFlexExtInstance

Represents an instance of a FlexAsset in a container

Data Fields
int * | particleIndices | Simulation particle indices.
int | numParticles | Number of simulation particles.
int | triangleIndex | Index in the container's triangle array.
int | shapeIndex | Index in the container's shape body constraints array.
int | inflatableIndex | Index in the container's inflatables array.
float * | shapeTranslations | Shape matching group translations (vec3s)
float * | shapeRotations | Shape matching group rotations (quaternions)
const NvFlexExtAsset * | asset | Source asset used to create this instance.
void * | userData | User data pointer.

struct NvFlexExtTearingParticleClone

Particles and vertices may need to be copied during tearing. Because the user may maintain particle data outside of Flex, this structure describes how to update the particle data. The application should copy each existing particle given by srcIndex (in the asset's particle array) to the destIndex (also in the asset's array).

Data Fields
int | srcIndex |
int | destIndex |

struct NvFlexExtTearingMeshEdit

The mesh topology may need to be updated to reference new particles during tearing. Because the user may maintain mesh topology outside of Flex, this structure describes the necessary updates that should be performed on the mesh. The triIndex member is the index of the index to be updated, e.g.: a triIndex value of 4 refers to the index 1 vertex (4%3) of the index 1 triangle (4/3). This entry in the indices array should be updated to point to the newParticleIndex.

Data Fields
int | triIndex |
int | newParticleIndex |

struct NvFlexExtParticleData

Data Fields
float * | particles | Receives a pointer to the particle position / mass data.
float * | restParticles | Receives a pointer to the particle's rest position (used for self collision culling)
float * | velocities | Receives a pointer to the particle velocity data.
int * | phases | Receives a pointer to the particle phase data.
float * | normals | Receives a pointer to the particle normal data with 16 byte stride in format [nx, ny, nz, nw].
const float * | lower | Receive a pointer to the particle lower bounds [x, y, z].
const float * | upper | Receive a pointer to the particle upper bounds [x, y, z].

struct NvFlexExtTriangleData

Data Fields
int * | indices | Receives a pointer to the array of triangle index data.
float * | normals | Receives a pointer to an array of triangle normal data stored with 16 byte stride, i.e.: [nx, ny, nz].

struct NvFlexExtShapeData

Data Fields
float * | rotations | Receives a pointer to the array quaternion rotation data in [x, y z, w] format.
float * | positions | Receives a pointer to an array of shape body translations in [x, y, z] format.
int | n | Number of valid tranforms.

struct NvFlexExtForceField

Force field data, currently just supports radial fields

Data Fields
float | mPosition[3] | Center of force field.
float | mRadius | Radius of the force field.
float | mStrength | Strength of the force field.
NvFlexExtForceMode | mMode | Mode of field application.
bool | mLinearFalloff | Linear or no falloff.

## Typedef Documentation

typedef struct NvFlexExtContainer NvFlexExtContainer

Opaque type representing a simulation

typedef struct NvFlexExtForceFieldCallback NvFlexExtForceFieldCallback

Opaque type representing a force field callback structure that ecapsulates the force field kernels and associated data applied as a callback during the Flex update

## Enumeration Type Documentation

enum NvFlexExtForceMode

Controls the way that force fields affect particles

Enumerator
eNvFlexExtModeForce | Apply field value as a force.
eNvFlexExtModeImpulse | Apply field value as an impulse.
eNvFlexExtModeVelocityChange | Apply field value as a velocity change.

## Function Documentation

NV_FLEX_API void NvFlexExtMovingFrameInit | ( | NvFlexExtMovingFrame * | frame,
|  | const float * | worldTranslation,
|  | const float * | worldRotation
| ) |  |

Creates a new moving frame struct. This helper method is used to calculate inertial forces for particles inside an attached parent frame. For example, when simulating cloth attached to the character, we would like to perform a local space simulation of the cloth to avoid excessive stretching and collision issues during fast animations. However, we would still like the cloth to respond to character movements in at least a limited, or controlled fashion. The NvFlexExtMovingFrame provides a way to include or remove these inertial forces. The basic usage is as follows:

NvFlexExtMovingFrame frame;
NvFlexExtMovingFrameInit(&frame, initialTranslation, initialRotation);
const linearInertiaScale = 0.25f;
const angularInertiaScale 0.5;
while(simulating)
{
float3 newPosition;
float4 newRotation;
// move parent frame (character / emitter) according to application's animation system
Animate(newPosition, newRotation);
// update the frame
NvFlexExtMovingFrameUpdate(frame, newPosition, newRotation, dt);
// apply inertial forces and update particles
NvFlexExtMovingFrameApply(frame, particlePositions, particleVelocities, numParticles, linearInertiaScale, angularInertiaScale, dt);
}

Parameters

  [in] | frame | A pointer to a user-allocated NvFlexExtMovingFrame struct
  [in] | worldTranslation | A pointer to a vec3 storing the frame's initial translation in world space
  [in] | worldRotation | A pointer to a quaternion storing the frame's initial rotation in world space

NV_FLEX_API void NvFlexExtMovingFrameUpdate | ( | NvFlexExtMovingFrame * | frame,
|  | const float * | worldTranslation,
|  | const float * | worldRotation,
|  | float | dt
| ) |  |

NV_FLEX_API void NvFlexExtMovingFrameApply | ( | NvFlexExtMovingFrame * | frame,
|  | float * | positions,
|  | float * | velocities,
|  | int | numParticles,
|  | float | linearScale,
|  | float | angularScale,
|  | float | dt
| ) |  |

NV_FLEX_API int NvFlexExtCreateWeldedMeshIndices | ( | const float * | vertices,
|  | int | numVertices,
|  | int * | uniqueVerts,
|  | int * | originalToUniqueMap,
|  | float | threshold
| ) |  |

Create an index buffer of unique vertices in the mesh (collapses vertices in the same position even if they have different normals / texcoords). This can be used to create simulation meshes from render meshes, and is typically done as a pre-pass before calling NvFlexExtCreateClothFromMesh().

Parameters

  [in] | vertices | A pointer to an array of float3 positions
  [in] | numVertices | The number of vertices in the mesh
  [out] | uniqueVerts | A list of unique mesh vertex indices, should be numVertices in length (worst case all verts are unique)
  [out] | originalToUniqueMap | Mapping from the original vertex index to the unique vertex index, should be numVertices in length
  [in] | threshold | The distance below which two vertices are considered duplicates

Returns
  The number of unique vertices in the mesh

NV_FLEX_API NvFlexExtAsset* NvFlexExtCreateClothFromMesh | ( | const float * | particles,
|  | int | numParticles,
|  | const int * | indices,
|  | int | numTriangles,
|  | float | stretchStiffness,
|  | float | bendStiffness,
|  | float | tetherStiffness,
|  | float | tetherGive,
|  | float | pressure
| ) |  |

Create a cloth asset consisting of stretch and bend distance constraints given an indexed triangle mesh. Stretch constraints will be placed along triangle edges, while bending constraints are placed over two edges.

Parameters

  [in] | particles | Positions and masses of the particles in the format [x, y, z, 1/m]
  [in] | numParticles | The number of particles
  [in] | indices | The triangle indices, these should be 'welded' using NvFlexExtCreateWeldedMeshIndices() first
  [in] | numTriangles | The number of triangles
  [in] | stretchStiffness | The stiffness coefficient for stretch constraints
  [in] | bendStiffness | The stiffness coefficient used for bending constraints
  [in] | tetherStiffness | If > 0.0f then the function will create tethers attached to particles with zero inverse mass. These are unilateral, long-range attachments, which can greatly reduce stretching even at low iteration counts.
  [in] | tetherGive | Because tether constraints are so effective at reducing stiffness, it can be useful to allow a small amount of extension before the constraint activates.
  [in] | pressure | If > 0.0f then a volume (pressure) constraint will also be added to the asset, the rest volume and stiffness will be automatically computed by this function

Returns
  A pointer to an asset structure holding the particles and constraints

NV_FLEX_API NvFlexExtAsset* NvFlexExtCreateTearingClothFromMesh | ( | const float * | particles,
|  | int | numParticles,
|  | int | maxParticles,
|  | const int * | indices,
|  | int | numTriangles,
|  | float | stretchStiffness,
|  | float | bendStiffness,
|  | float | pressure
| ) |  |

Create a cloth asset consisting of stretch and bend distance constraints given an indexed triangle mesh. This creates an asset with the same structure as NvFlexExtCreateClothFromMesh(), however tether constraints are not supported, and additional information regarding mesh topology will be stored with the asset to allow tearing.

Note
  : Typically each instance of a tearable cloth mesh will have it's own asset. This is because the asset holds the topology of the mesh which is unique for each instance.

Parameters

  [in] | particles | Positions and masses of the particles in the format [x, y, z, 1/m]
  [in] | numParticles | The number of particles
  [in] | maxParticles | The maximum number of particles for this asset, this will limit the amount of tearing that can be performed.
  [in] | indices | The triangle indices, these should be 'welded' using NvFlexExtCreateWeldedMeshIndices() first
  [in] | numTriangles | The number of triangles
  [in] | stretchStiffness | The stiffness coefficient for stretch constraints
  [in] | bendStiffness | The stiffness coefficient used for bending constraints
  [in] | pressure | If > 0.0f then a volume (pressure) constraint will also be added to the asset, the rest volume and stiffness will be automatically computed by this function

Returns
  A pointer to an asset structure holding the particles and constraints

NV_FLEX_API void NvFlexExtDestroyTearingCloth | ( | NvFlexExtAsset * | asset | ) |

Destroy an asset created with NvFlexExtCreateTearingClothFromMesh()

Parameters

  [in] | asset | The asset to be destroyed.

NV_FLEX_API void NvFlexExtTearClothMesh | ( | NvFlexExtAsset * | asset,
|  | float | maxStrain,
|  | int | maxSplits,
|  | NvFlexExtTearingParticleClone * | particleCopies,
|  | int * | numParticleCopies,
|  | int | maxCopies,
|  | NvFlexExtTearingMeshEdit * | triangleEdits,
|  | int * | numTriangleEdits,
|  | int | maxEdits
| ) |  |

Perform cloth mesh tearing, this function will calculate the strain on each distance constraint and perform splits if it is above a certain strain threshold (i.e.: length/restLength > maxStrain).

Parameters

  [in] | asset | The asset describing the cloth constraint network, this must be created with NvFlexExtCreateTearingClothFromMesh()
  [in] | maxStrain | The maximum allowable strain on each edge
  [in] | maxSplits | The maximum number of constraint breaks that will be performed, this controls the 'rate' of mesh tearing
  [in] | particleCopies | Pointer to an array of NvFlexExtTearingParticleClone structures that describe the particle copies that need to be performed
  [in] | numParticleCopies | Pointer to an integer that will have the number of copies performed written to it
  [in] | maxCopies | The maximum number of particle copies that will be performed, multiple particles copies may be performed in response to one split
  [in] | triangleEdits | Pointer to an array of NvFlexExtTearingMeshEdit structures that describe the topology updates that need to be performed
  [in] | numTriangleEdits | Pointer to an integer that will have the number of topology updates written to it
  [in] | maxEdits | The maximum number of index buffer edits that will be output

NV_FLEX_API NvFlexExtAsset* NvFlexExtCreateRigidFromMesh | ( | const float * | vertices,
|  | int | numVertices,
|  | const int * | indices,
|  | int | numTriangleIndices,
|  | float | radius,
|  | float | expand
| ) |  |

Create a shape body asset from a closed triangle mesh. The mesh is first voxelized at a spacing specified by the radius, and particles are placed at occupied voxels.

Parameters

  [in] | vertices | Vertices of the triangle mesh
  [in] | numVertices | The number of vertices
  [in] | indices | The triangle indices
  [in] | numTriangleIndices | The number of triangles indices (triangles*3)
  [in] | radius | The spacing used for voxelization, note that the number of voxels grows proportional to the inverse cube of radius, currently this method limits construction to resolutions < 64^3
  [in] | expand | Particles will be moved inwards (if negative) or outwards (if positive) from the surface of the mesh according to this factor

Returns
  A pointer to an asset structure holding the particles and constraints

NV_FLEX_API NvFlexExtAsset* NvFlexExtCreateSoftFromMesh | ( | const float * | vertices,
|  | int | numVertices,
|  | const int * | indices,
|  | int | numTriangleIndices,
|  | float | particleSpacing,
|  | float | volumeSampling,
|  | float | surfaceSampling,
|  | float | clusterSpacing,
|  | float | clusterRadius,
|  | float | clusterStiffness,
|  | float | linkRadius,
|  | float | linkStiffness,
|  | float | globalStiffness
| ) |  |

Create a shape body asset from a closed triangle mesh. The mesh is first voxelized at a spacing specified by the radius, and particles are placed at occupied voxels.

Parameters

  [in] | vertices | Vertices of the triangle mesh
  [in] | numVertices | The number of vertices
  [in] | indices | The triangle indices
  [in] | numTriangleIndices | The number of triangles indices (triangles*3)
  [in] | particleSpacing | The spacing to use when creating particles
  [in] | volumeSampling | Control the resolution the mesh is voxelized at in order to generate interior sampling, if the mesh is not closed then this should be set to zero and surface sampling should be used instead
  [in] | surfaceSampling | Controls how many samples are taken of the mesh surface, this is useful to ensure fine features of the mesh are represented by particles, or if the mesh is not closed
  [in] | clusterSpacing | The spacing for shape-matching clusters, should be at least the particle spacing
  [in] | clusterRadius | Controls the overall size of the clusters, this controls how much overlap the clusters have which affects how smooth the final deformation is, if parts of the body are detaching then it means the clusters are not overlapping sufficiently to form a fully connected set of clusters
  [in] | clusterStiffness | Controls the stiffness of the resulting clusters
  [in] | linkRadius | Any particles below this distance will have additional distance constraints created between them
  [in] | linkStiffness | The stiffness of distance links
  [in] | globalStiffness | If this parameter is > 0.0f, adds an additional global cluster that consists of all particles in the shape. The stiffness of this cluster is the globalStiffness.

Returns
  A pointer to an asset structure holding the particles and constraints

NV_FLEX_API void NvFlexExtDestroyAsset | ( | NvFlexExtAsset * | asset | ) |

Frees all memory associated with an asset created by one of the creation methods param[in] asset The asset to destroy.

NV_FLEX_API void NvFlexExtCreateSoftMeshSkinning | ( | const float * | vertices,
|  | int | numVertices,
|  | const float * | bones,
|  | int | numBones,
|  | float | falloff,
|  | float | maxDistance,
|  | float * | skinningWeights,
|  | int * | skinningIndices
| ) |  |

Creates information for linear blend skining a graphics mesh to a set of transforms (bones)

Parameters

  [in] | vertices | Vertices of the triangle mesh
  [in] | numVertices | The number of vertices
  [in] | bones | Pointer to an array of vec3 positions representing the bone positions
  [in] | numBones | Then number of bones
  [in] | falloff | The speed at which the bone's influence on a vertex falls off with distance
  [in] | maxDistance | The maximum distance a bone can be from a vertex before it will not influence it any more
  [out] | skinningWeights | The normalized weights for each bone, there are up to 4 weights per-vertex so this should be numVertices*4 in length
  [out] | skinningIndices | The indices of each bone corresponding to the skinning weight, will be -1 if this weight is not used

NV_FLEX_API NvFlexExtContainer* NvFlexExtCreateContainer | ( | NvFlexLibrary * | lib,
|  | NvFlexSolver * | solver,
|  | int | maxParticles
| ) |  |

Creates a wrapper object around a Flex solver that can hold assets / instances, the container manages sending and retrieving partical data from the solver

Parameters

  [in] | lib | The library instance to use
  [in] | solver | The solver to wrap
  [in] | maxParticles | The maximum number of particles to manage

Returns
  A pointer to the new container

NV_FLEX_API void NvFlexExtDestroyContainer | ( | NvFlexExtContainer * | container | ) |

Frees all memory associated with a container

Parameters

  [in] | container | The container to destroy

NV_FLEX_API int NvFlexExtAllocParticles | ( | NvFlexExtContainer * | container,
|  | int | n,
|  | int * | indices
| ) |  |

Allocates particles in the container.

Parameters

  [in] | container | The container to allocate out of
  [in] | n | The number of particles to allocate
  [out] | indices | An n-length array of ints that will store the indices to the allocated particles

NV_FLEX_API void NvFlexExtFreeParticles | ( | NvFlexExtContainer * | container,
|  | int | n,
|  | const int * | indices
| ) |  |

Free allocated particles

Parameters

  [in] | container | The container to free from
  [in] | n | The number of particles to free
  [in] | indices | The indices of the particles to free

NV_FLEX_API int NvFlexExtGetActiveList | ( | NvFlexExtContainer * | container,
|  | int * | indices
| ) |  |

Retrives the indices of all active particles

Parameters

  [in] | container | The container to free from
  [out] | indices | Returns the number of active particles

Returns
  The number of active particles

NV_FLEX_API NvFlexExtParticleData NvFlexExtMapParticleData | ( | NvFlexExtContainer * | container | ) |

Returns pointers to the internal data stored by the container. These are host-memory pointers, and will remain valid NvFlexExtUnmapParticleData() is called.

Parameters

  container | The container whose data should be accessed

NV_FLEX_API void NvFlexExtUnmapParticleData | ( | NvFlexExtContainer * | container | ) |

NV_FLEX_API NvFlexExtTriangleData NvFlexExtMapTriangleData | ( | NvFlexExtContainer * | container | ) |

Access triangle constraint data, see NvFlexExtGetParticleData() for notes on ownership.

Parameters

  container | The container to retrive from

NV_FLEX_API void NvFlexExtUnmapTriangleData | ( | NvFlexExtContainer * | container | ) |

Unmap triangle data, see NvFlexExtMapTriangleData()

NV_FLEX_API NvFlexExtShapeData NvFlexExtMapShapeData | ( | NvFlexExtContainer * | container | ) |

Access shape body constraint data, see NvFlexExtGetParticleData() for notes on ownership.

Parameters

  container | The container to retrive from

NV_FLEX_API void NvFlexExtUnmapShapeData | ( | NvFlexExtContainer * | container | ) |

Unmap shape transform data, see NvFlexExtMapShapeData()

NV_FLEX_API NvFlexExtInstance* NvFlexExtCreateInstance | ( | NvFlexExtContainer * | container,
|  | NvFlexExtParticleData * | particleData,
|  | const NvFlexExtAsset * | asset,
|  | const float * | transform,
|  | float | vx,
|  | float | vy,
|  | float | vz,
|  | int | phase,
|  | float | invMassScale
| ) |  |

Creates an instance of an asset, the container will internally store a reference to the asset so it should remain valid for the instance lifetime. This method will allocate particles for the asset, assign their initial positions, velocity and phase.

Parameters

  [in] | container | The container to spawn into
  [in] | particleData | Pointer to a mapped particle data struct, returned from NvFlexExtMapParticleData()
  [in] | asset | The asset to be spawned
  [in] | transform | A pointer to a 4x4 column major, column vector transform that specifies the initial world space configuration of the particles
  [in] | vx | The velocity of the particles along the x axis
  [in] | vy | The velocity of the particles along the y axis
  [in] | vz | The velocity of the particles along the z axis
  [in] | phase | The phase used for the particles
  [in] | invMassScale | A factor applied to the per particle inverse mass

Returns
  A pointer to the instance of the asset

NV_FLEX_API void NvFlexExtDestroyInstance | ( | NvFlexExtContainer * | container,
|  | const NvFlexExtInstance * | instance
| ) |  |

Destoy an instance of an asset

Parameters

  [in] | container | The container the instance belongs to
  [in] | instance | The instance to destroy

NV_FLEX_API void NvFlexExtNotifyAssetChanged | ( | NvFlexExtContainer * | container,
|  | const NvFlexExtAsset * | asset
| ) |  |

Notifies the container that asset data has changed and needs to be sent to the GPU this should be called if the constrains for an existing asset are modified by the user

Parameters

  [in] | container | The container the instance referencing the asset belongs to
  [in] | asset | The asset which was modified (can be NULL)

NV_FLEX_API void NvFlexExtTickContainer | ( | NvFlexExtContainer * | container,
|  | float | dt,
|  | int | numSubsteps,
|  | bool | enableTimers = `false`
| ) |  |

Updates the container, applies force fields, steps the solver forward in time, updates the host with the results synchronously. This is a helper function which performs a synchronous update using the following flow.

// async update GPU data
NvFlexExtPushToDevice(container);
// update solver
NvFlexUpdateSolver(container, dt, iterations);
// async read data back to CPU
NvFlexExtPullFromDevice(container);
// read / write particle data on CPU
NvFlexExtParticleData data = NvFlexExtMapParticleData();
// CPU particle processing
ProcessParticles(data);
// unmap data
NvFlexExtUnmapParticleData();

Parameters

  [in] | container | The container to update
  [in] | dt | The time-step in seconds
  [in] | numSubsteps | The number of substeps to perform
  [in] | enableTimers | Whether to record detailed timers, see NvFlexUpdateSolver()

NV_FLEX_API void NvFlexExtPushToDevice | ( | NvFlexExtContainer * | container | ) |

Updates the device asynchronously, transfers any particle and constraint changes to the flex solver, expected to be called in the following sequence: NvFlexExtPushToDevice, NvFlexUpdateSolver, NvFlexExtPullFromDevice, flexSynchronize

Parameters

  [in] | container | The container to update

NV_FLEX_API void NvFlexExtPullFromDevice | ( | NvFlexExtContainer * | container | ) |

Updates the host asynchronously, transfers particle and constraint data back to he host, expected to be called in the following sequence: NvFlexExtPushToDevice, NvFlexUpdateSolver, NvFlexExtPullFromDevice

Parameters

  [in] | container | The container to update

NV_FLEX_API void NvFlexExtUpdateInstances | ( | NvFlexExtContainer * | container | ) |

Synchronizes the per-instance data with the container's data, should be called after the synchronization with the solver read backs are complete

Parameters

  [in] | container | The instances belonging to this container will be updated

NV_FLEX_API NvFlexExtForceFieldCallback* NvFlexExtCreateForceFieldCallback | ( | NvFlexSolver * | solver | ) |

Create a NvFlexExtForceFieldCallback structure, each callback is associated with the passed in solver once the NvFlexExtSetForceFields() is called.

Parameters

  [in] | solver | A valid solver created with NvFlexCreateSolver()

Returns
  A pointer to a callback structure

NV_FLEX_API void NvFlexExtDestroyForceFieldCallback | ( | NvFlexExtForceFieldCallback * | callback | ) |

Destroy the force field callback

Parameters

  [in] | callback | A valid solver created with NvFlexExtCreateForceFieldCallback()

NV_FLEX_API void NvFlexExtSetForceFields | ( | NvFlexExtForceFieldCallback * | callback,
|  | const NvFlexExtForceField * | forceFields,
|  | int | numForceFields
| ) |  |

Set force fields on the container, these will be applied during the Flex update

Parameters

  [in] | callback | The callback to update
  [in] | forceFields | A pointer to an array of force field data, may be host or GPU memory
  [in] | numForceFields | The number of force fields to send to the device