![]() |
FLEX
0.8
|
Go to the source code of this file.
Data Structures | |
struct | FlexExtAsset |
struct | FlexExtInstance |
struct | FlexExtForceField |
Enumerations | |
enum | FlexForceExtMode { eFlexExtModeForce = 0, eFlexExtModeImpulse = 1, eFlexExtModeVelocityChange = 2 } |
Functions | |
FLEX_API int | flexExtCreateWeldedMeshIndices (const float *vertices, int numVertices, int *uniqueVerts, int *originalToUniqueMap, float threshold) |
FLEX_API FlexExtAsset * | flexExtCreateClothFromMesh (const float *particles, int numVertices, const int *indices, int numTriangles, float stretchStiffness, float bendStiffness, float tetherStiffness, float tetherGive, float pressure) |
FLEX_API FlexExtAsset * | flexExtCreateRigidFromMesh (const float *vertices, int numVertices, const int *indices, int numTriangleIndices, float radius) |
FLEX_API void | flexExtDestroyAsset (FlexExtAsset *asset) |
FLEX_API FlexExtContainer * | flexExtCreateContainer (FlexSolver *solver, int maxParticles) |
FLEX_API void | flexExtDestroyContainer (FlexExtContainer *container) |
FLEX_API int | flexExtAllocParticles (FlexExtContainer *container, int n, int *indices) |
FLEX_API void | flexExtFreeParticles (FlexExtContainer *container, int n, const int *indices) |
FLEX_API int | flexExtGetActiveList (FlexExtContainer *container, int *indices) |
FLEX_API FlexExtInstance * | flexExtCreateInstance (FlexExtContainer *container, const FlexExtAsset *asset, const float *transform, float vx, float vy, float vz, int phase, float invMassScale) |
FLEX_API void | flexExtDestroyInstance (FlexExtContainer *container, const FlexExtInstance *instance) |
FLEX_API void | flexExtGetParticleData (FlexExtContainer *container, float **particles, float **velocities, int **phases, float **normals) |
FLEX_API void | flexExtGetTriangleData (FlexExtContainer *container, int **indices, float **normals) |
FLEX_API void | flexExtGetRigidData (FlexExtContainer *container, float **rotations, float **positions) |
FLEX_API void | flexExtTickContainer (FlexExtContainer *container, float dt, int numSubsteps, FlexTimers *timers=NULL) |
FLEX_API void | flexExtPushToDevice (FlexExtContainer *container) |
FLEX_API void | flexExtPullFromDevice (FlexExtContainer *container) |
FLEX_API void | flexExtSetForceFields (FlexExtContainer *container, const FlexExtForceField *forceFields, int numForceFields, FlexMemory source) |
FLEX_API void | flexExtApplyForceFields (FlexExtContainer *container, float dt) |
struct FlexExtAsset |
Represents a group of particles and constraints, each asset can be instanced into a simulation using flexExtCreateInstance
struct FlexExtInstance |
Represents an instance of a FlexAsset in a container
Data Fields | ||
---|---|---|
int * | mParticleIndices | Simulation particle indices. |
int | mNumParticles | Number of simulation particles. |
int | mTriangleIndex | Index in the container's triangle array. |
int | mRigidIndex | Index in the container's rigid body constraints array. |
int | mInflatableIndex | Index in the container's inflatables array. |
const FlexExtAsset * | mAsset | Source asset used to create this instance. |
void * | mUserData | User data pointer. |
struct FlexExtForceField |
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. |
FlexForceExtMode | mMode | Mode of field application. |
bool | mLinearFalloff | Linear or no falloff. |
enum FlexForceExtMode |
FLEX_API int flexExtCreateWeldedMeshIndices | ( | const float * | vertices, |
int | numVertices, | ||
int * | uniqueVerts, | ||
int * | originalToUniqueMap, | ||
float | threshold | ||
) |
Create an index buffer of unique vertices in the mesh
[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 |
FLEX_API FlexExtAsset* flexExtCreateClothFromMesh | ( | const float * | particles, |
int | numVertices, | ||
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.
[in] | particles | Positions and masses of the particles in the format [x, y, z, 1/m] |
[in] | numVertices | The number of particles |
[in] | indices | The triangle indices, these should be 'welded' using flexExtCreateWeldedMeshIndices() 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 tether's 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 |
FLEX_API FlexExtAsset* flexExtCreateRigidFromMesh | ( | const float * | vertices, |
int | numVertices, | ||
const int * | indices, | ||
int | numTriangleIndices, | ||
float | radius | ||
) |
Create a rigid 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.
[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 |
FLEX_API void flexExtDestroyAsset | ( | FlexExtAsset * | asset | ) |
Frees all memory associated with an asset created by one of the creation methods param[in] asset The asset to destroy.
FLEX_API FlexExtContainer* flexExtCreateContainer | ( | FlexSolver * | solver, |
int | maxParticles | ||
) |
Creates a wrapper object around a Flex solver that can hold assets / instances
[in] | solver | The solver to wrap |
[in] | maxParticles | The maximum number of particles to manage |
FLEX_API void flexExtDestroyContainer | ( | FlexExtContainer * | container | ) |
Frees all memory associated with a container
[in] | container | The container to destroy |
FLEX_API int flexExtAllocParticles | ( | FlexExtContainer * | container, |
int | n, | ||
int * | indices | ||
) |
Allocates particles in the container.
[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 |
FLEX_API void flexExtFreeParticles | ( | FlexExtContainer * | container, |
int | n, | ||
const int * | indices | ||
) |
Free allocated particles
[in] | container | The container to free from |
[in] | n | The number of particles to free |
[in] | indices | The indices of the particles to free |
FLEX_API int flexExtGetActiveList | ( | FlexExtContainer * | container, |
int * | indices | ||
) |
Retrives the indices of all active particles
[in] | container | The container to free from |
[out] | indices | Returns the number of active particles |
FLEX_API FlexExtInstance* flexExtCreateInstance | ( | FlexExtContainer * | container, |
const FlexExtAsset * | 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.
[in] | container | The container to spawn into |
[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 |
FLEX_API void flexExtDestroyInstance | ( | FlexExtContainer * | container, |
const FlexExtInstance * | instance | ||
) |
Destoy an instance of an asset
[in] | container | The container the instance belongs to |
[in] | instance | The instance to destroy |
FLEX_API void flexExtGetParticleData | ( | FlexExtContainer * | container, |
float ** | particles, | ||
float ** | velocities, | ||
int ** | phases, | ||
float ** | normals | ||
) |
Returns pointers to the internal data stored by the container. These are host-memory pointers, and will remain valid until the container is destroyed. They can be used to read and write particle data, but only after suitable synchronization. See flexExtTickContainer() for details.
container | The container whose data should be accessed |
particles | Receives a pointer to the particle position / mass data |
velocities | Receives a pointer to the particle velocity data |
phases | Receives a pointer to the particle phase data |
normals | Receives a pointer to the particle normal data with 16 byte stride in format [nx, ny, nz, nw] |
FLEX_API void flexExtGetTriangleData | ( | FlexExtContainer * | container, |
int ** | indices, | ||
float ** | normals | ||
) |
Access triangle constraint data, see flexExtGetParticleData() for notes on ownership.
container | The container to retrive from |
indices | Receives a pointer to the array of triangle index data |
normals | Receives a pointer to an array of triangle normal data stored with 16 byte stride, i.e.: [nx, ny, nz] |
FLEX_API void flexExtGetRigidData | ( | FlexExtContainer * | container, |
float ** | rotations, | ||
float ** | positions | ||
) |
Access rigid body constraint data, see flexExtGetParticleData() for notes on ownership.
container | The container to retrive from |
rotations | Receives a pointer to the array 3x3 rotation matrix data |
positions | Receives a pointer to an array of rigid body translations in [x, y, z] format |
FLEX_API void flexExtTickContainer | ( | FlexExtContainer * | container, |
float | dt, | ||
int | numSubsteps, | ||
FlexTimers * | timers = NULL |
||
) |
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.
[in] | container | The container to update |
[in] | dt | The time-step in seconds |
[in] | numSubsteps | The number of substeps to perform |
[in] | timers | Pointer to a Flex profiling structure, see flexUpdateSolver() |
FLEX_API void flexExtPushToDevice | ( | FlexExtContainer * | container | ) |
Updates the device asynchronously, transfers any particle and constraint changes to the flex solver, expected to be called in the following sequence: flexExtPushToDevice, [flexExtApplyForceFields,] flexUpdateSolver, flexExtPullFromDevice, flexSynchronize
[in] | container | The container to update |
FLEX_API void flexExtPullFromDevice | ( | FlexExtContainer * | container | ) |
Updates the host asynchronously, transfers particle and constraint data back to he host, expected to be called in the following sequence: flexExtPushToDevice, [flexExtApplyForceFields,] flexUpdateSolver, flexExtPullFromDevice, flexSynchronize
[in] | container | The container to update |
FLEX_API void flexExtSetForceFields | ( | FlexExtContainer * | container, |
const FlexExtForceField * | forceFields, | ||
int | numForceFields, | ||
FlexMemory | source | ||
) |
FLEX_API void flexExtApplyForceFields | ( | FlexExtContainer * | container, |
float | dt | ||
) |