34 #define FLEX_API __declspec(dllexport)
40 #define FLEX_VERSION 26
259 FLEX_API FlexSolver*
flexCreateSolver(
int maxParticles,
int maxDiffuseParticles,
unsigned char maxNeighborsPerParticle = 96);
396 FLEX_API
void flexSetSprings(FlexSolver* s,
const int* indices,
const float* restLengths,
const float* stiffness,
int numSprings,
FlexMemory source);
407 FLEX_API
void flexGetSprings(FlexSolver* s,
int* indices,
float* restLengths,
float* stiffness,
int numSprings,
FlexMemory target);
423 FLEX_API
void flexSetRigids(FlexSolver* s,
const int* offsets,
const int* indices,
const float* restPositions,
const float* restNormals,
const float* stiffness,
const float* rotations,
int numRigids,
FlexMemory source);
474 FLEX_API
void flexSetConvexes (FlexSolver* s,
const float* aabbMin,
const float* aabbMax,
const int* planeOffsets,
const int* planeCounts,
const float* planes,
const float* positions,
const float* rotations,
const float* prevPositions,
const float* prevRotations,
const int* flags,
int numConvexes,
int numPlanes,
FlexMemory source);
486 FLEX_API
void flexSetTriangles(FlexSolver* s,
const int* indices,
const float* vertices,
int numTris,
int numVertices,
float cellSize,
FlexMemory source);
532 FLEX_API
void flexSetInflatables(FlexSolver* s,
const int* startTris,
const int* numTris,
float* restVolumes,
float* overPressures,
float* constraintScales,
int numInflatables,
FlexMemory source);
598 FLEX_API
void flexGetBounds(FlexSolver* s,
float* lower,
float* upper);
657 FLEX_API
void flexSetDebug(FlexSolver* s,
bool enable);
658 FLEX_API
void flexGetConvexGrid(FlexSolver* s,
int* grid,
float* lower,
float* upper,
int* axis);
659 FLEX_API
void flexGetStaticTriangleGrid(FlexSolver* s,
int* counts,
float* lower,
float* cellEdge);
660 FLEX_API
void flexStartRecord(FlexSolver* s,
const char* file);
661 FLEX_API
void flexStopRecord(FlexSolver* s);
float mSleepThreshold
Particles with a velocity magnitude < this threshold will be considered fixed.
Definition: flex.h:75
float mUpdateNormals
Time spent updating vertex normals.
Definition: flex.h:179
FlexPhase
Definition: flex.h:125
void(* FlexErrorCallback)(const char *msg, const char *file, int line)
Definition: flex.h:230
unsigned int mDepth
Field z dimension in voxels.
Definition: flex.h:149
float mCohesion
Control how strongly particles hold each other together, default: 0.025, range [0.0, +inf].
Definition: flex.h:89
FLEX_API void flexGetNormals(FlexSolver *s, float *normals, int n, FlexMemory target)
float mBuoyancy
Gravity is scaled by this value for fluid particles.
Definition: flex.h:97
FLEX_API void flexGetSmoothParticles(FlexSolver *s, float *p, int n, FlexMemory target)
float mStaticFriction
Coefficient of static friction used when colliding against shapes.
Definition: flex.h:71
float mSolveVelocities
Time spent solving velocity constraints.
Definition: flex.h:171
float mSolidRestDistance
The distance non-fluid particles attempt to maintain from each other, must be in the range (0...
Definition: flex.h:66
FLEX_API void flexGetSprings(FlexSolver *s, int *indices, float *restLengths, float *stiffness, int numSprings, FlexMemory target)
FLEX_API int flexGetVersion()
float mRelaxationFactor
Control the convergence rate of the parallel solver, default: 1, values greater than 1 may lead to in...
Definition: flex.h:119
int mDiffuseBallistic
The number of neighbors below which a diffuse particle is considered ballistic.
Definition: flex.h:103
float mMaxVelocity
Particle velocity will be clamped to this value at the end of each step.
Definition: flex.h:76
float mAdhesion
Controls how strongly particles stick to surfaces they hit, default 0.0, range [0.0, +inf].
Definition: flex.h:74
FLEX_API FlexError flexInit(int version=FLEX_VERSION, FlexErrorCallback errorFunc=NULL)
int mNumIterations
Number of solver iterations to perform per-substep.
Definition: flex.h:62
float mCollideFields
Time spent colliding signed distance field shapes.
Definition: flex.h:168
float mCreateGrid
Time spent creating grid.
Definition: flex.h:163
FLEX_API void flexSetActive(FlexSolver *s, const int *indices, int n, FlexMemory source)
FLEX_API void flexGetParticles(FlexSolver *s, float *p, int n, FlexMemory target)
float mGravity[3]
Constant acceleration applied to all particles.
Definition: flex.h:64
FlexRelaxationMode mRelaxationMode
How the relaxation is applied inside the solver.
Definition: flex.h:118
FLEX_API void flexGetBounds(FlexSolver *s, float *lower, float *upper)
float mCalculateDensity
Time spent calculating fluid density.
Definition: flex.h:169
float mCreateCellIndices
Time spent creating grid indices.
Definition: flex.h:161
FLEX_API void flexWaitFence()
float mPlasticThreshold
Particles belonging to rigid shapes that move with a position delta magnitude > threshold will be per...
Definition: flex.h:107
FLEX_API void flexSetNormals(FlexSolver *s, const float *normals, int n, FlexMemory source)
The GPU associated with the calling thread does not meet requirements. An SM3.0 GPU or above is requi...
Definition: flex.h:199
float mDamping
Viscous drag force, applies a force proportional, and opposite to the particle velocity.
Definition: flex.h:79
The relaxation factor is a fixed multiplier on each constraint's delta divided by the particle's cons...
Definition: flex.h:57
float mPlanes[8][4]
Collision planes in the form ax + by + cz + d = 0.
Definition: flex.h:115
float mCollideParticles
Time spent finding particle neighbors.
Definition: flex.h:165
float mDrag
Drag force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in th...
Definition: flex.h:84
float mAnisotropyScale
Control how much anisotropy is present in resulting ellipsoids for rendering, if zero then anisotropy...
Definition: flex.h:93
FLEX_API void flexSetFields(FlexSolver *s, const FlexSDF *shapes, int numShapes)
float mUpper[3]
Shape AABB upper bounds in world space.
Definition: flex.h:144
float mSolveDensities
Time spent solving density constraints.
Definition: flex.h:170
Device (GPU) memory asynchronous, when used with a flexGet/flexSet method the memory transfer will be...
Definition: flex.h:224
float mDiffuseSortAxis[3]
Diffuse particles will be sorted by depth along this axis if non-zero.
Definition: flex.h:104
float mDiffuseBuoyancy
Scales force opposing gravity that diffuse particles receive.
Definition: flex.h:101
float mSurfaceTension
Controls how strongly particles attempt to minimize surface area, default: 0.0, range: [0...
Definition: flex.h:90
float mLift
Lift force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in th...
Definition: flex.h:85
float mInvEdgeLength[3]
1/(mUpper-mLower)
Definition: flex.h:145
float mSolidPressure
Add pressure from solid surfaces to particles.
Definition: flex.h:95
float mLower[3]
Shape AABB lower bounds in world space.
Definition: flex.h:143
float mShockPropagation
Artificially decrease the mass of particles based on height from a fixed reference point...
Definition: flex.h:77
The header version does not match the library binary.
Definition: flex.h:195
unsigned int mHeight
Field y dimension in voxels.
Definition: flex.h:148
float mSolveShapes
Time spent solving rigid body constraints.
Definition: flex.h:172
float mPlasticCreep
Controls the rate at which particles in the rest pose are deformed for particles passing the deformat...
Definition: flex.h:108
float mFinalize
Time spent finalizing state.
Definition: flex.h:180
float mDiffuseThreshold
Particles with kinetic energy + divergence above this threshold will spawn new diffuse particles...
Definition: flex.h:100
FlexRelaxationMode
Definition: flex.h:54
Device (GPU) memory.
Definition: flex.h:212
float mReorder
Time spent reordering particles.
Definition: flex.h:164
float mCollisionDistance
Distance particles maintain against shapes.
Definition: flex.h:111
FLEX_API void flexGetContacts(FlexSolver *s, float *planes, int *indices, unsigned char *counts, FlexMemory target)
FlexMemory
Definition: flex.h:206
float mViscosity
Smoothes particle velocities using XSPH viscosity.
Definition: flex.h:91
FLEX_API void flexSetSprings(FlexSolver *s, const int *indices, const float *restLengths, const float *stiffness, int numSprings, FlexMemory source)
FLEX_API void flexGetDynamicTriangles(FlexSolver *s, int *indices, float *normals, int numTris, FlexMemory target)
FLEX_API void flexSetPhases(FlexSolver *s, const int *phases, int n, FlexMemory source)
FLEX_API void flexSetDynamicTriangles(FlexSolver *s, const int *indices, const float *normals, int numTris, FlexMemory source)
Flag specifying whether this particle will generate fluid density constraints for its overlapping nei...
Definition: flex.h:130
float mTotal
Sum of all timers above.
Definition: flex.h:182
Host (CPU) memory asynchronous, when used with a flexGet/flexSet method the memory transfer will be a...
Definition: flex.h:218
float mFluidRestDistance
The distance fluid particles are spaced at the rest density, must be in the range (0...
Definition: flex.h:67
FLEX_API void flexSetDiffuseParticles(FlexSolver *s, const float *p, const float *v, int n, FlexMemory source)
FLEX_API void flexGetRigidTransforms(FlexSolver *s, float *rotations, float *translations, FlexMemory target)
FLEX_API int flexGetActiveCount(FlexSolver *s)
bool mFluid
If true then particles with phase 0 are considered fluid particles and interact using the position ba...
Definition: flex.h:88
float mCollideTriangles
Time spent colliding triangle shapes.
Definition: flex.h:167
float mCollideConvexes
Time spent colliding convex shapes.
Definition: flex.h:166
float mRestitution
Coefficient of restitution used when colliding against shapes, particle collisions are always inelast...
Definition: flex.h:73
float mSolveContacts
Time spent solving contact constraints.
Definition: flex.h:174
Host (CPU) memory.
Definition: flex.h:209
float mUpdateBounds
Time spent updating particle bounds.
Definition: flex.h:181
FLEX_API void flexSetParams(FlexSolver *s, const FlexParams *params)
FLEX_API void flexSetInflatables(FlexSolver *s, const int *startTris, const int *numTris, float *restVolumes, float *overPressures, float *constraintScales, int numInflatables, FlexMemory source)
FlexError
Definition: flex.h:189
float mCalculateAnisotropy
Time spent calculating particle anisotropy for fluid.
Definition: flex.h:176
float mUpdateDiffuse
Time spent updating diffuse particles.
Definition: flex.h:177
FLEX_API int flexGetDiffuseParticles(FlexSolver *s, float *p, float *v, int *indices, FlexMemory target)
unsigned int mWidth
Field x dimension in voxels.
Definition: flex.h:147
float mPredict
Time spent in prediction.
Definition: flex.h:160
FLEX_API void flexSetFence()
float mShapeCollisionMargin
Increases the radius used during contact finding against kinematic shapes.
Definition: flex.h:113
FLEX_API void flexSetRigids(FlexSolver *s, const int *offsets, const int *indices, const float *restPositions, const float *restNormals, const float *stiffness, const float *rotations, int numRigids, FlexMemory source)
float mVorticityConfinement
Increases vorticity by applying rotational forces to particles.
Definition: flex.h:92
float mFreeSurfaceDrag
Drag force applied to boundary fluid particles.
Definition: flex.h:96
float mWind[3]
Constant acceleration applied to particles that belong to dynamic triangles, drag needs to be > 0 for...
Definition: flex.h:83
FLEX_API int flexMakePhase(int group, int flags)
Definition: flex.h:136
FLEX_API void flexSetParticles(FlexSolver *s, const float *p, int n, FlexMemory source)
float mSmoothing
Control the strength of Laplacian smoothing in particles for rendering, if zero then smoothed positio...
Definition: flex.h:94
FLEX_API void * flexAlloc(int size)
FLEX_API void flexGetActive(FlexSolver *s, int *indices, FlexMemory target)
FLEX_API void flexGetVelocities(FlexSolver *s, float *v, int n, FlexMemory target)
FLEX_API void flexUpdateSolver(FlexSolver *s, float dt, int substeps, FlexTimers *timers)
const float * mField
SDF voxel data, must be mWidth*mHeight*mDepth in length.
Definition: flex.h:151
The relaxation factor is a fixed multiplier on each constraint's position delta.
Definition: flex.h:56
FLEX_API void flexSetTriangles(FlexSolver *s, const int *indices, const float *vertices, int numTris, int numVertices, float cellSize, FlexMemory source)
FLEX_API FlexSolver * flexCreateSolver(int maxParticles, int maxDiffuseParticles, unsigned char maxNeighborsPerParticle=96)
The API call returned with no errors.
Definition: flex.h:192
FLEX_API void flexFree(void *ptr)
float mDiffuseDrag
Scales force diffuse particles receive in direction of neighbor fluid particles.
Definition: flex.h:102
Flag specifying whether this particle will interact with particles of the same group.
Definition: flex.h:129
float mSolveInflatables
Time spent solving pressure constraints.
Definition: flex.h:175
float mDissipation
Damps particle velocity based on how many particle contacts it has.
Definition: flex.h:78
int mNumPlanes
Num collision planes.
Definition: flex.h:116
FLEX_API void flexSetVelocities(FlexSolver *s, const float *v, int n, FlexMemory source)
float mUpdateTriangles
Time spent updating dynamic triangles.
Definition: flex.h:178
float mRadius
The maximum interaction radius for particles.
Definition: flex.h:65
FLEX_API void flexGetPhases(FlexSolver *s, int *phases, int n, FlexMemory target)
float mSortCellIndices
Time spent sorting grid indices.
Definition: flex.h:162
FLEX_API void flexGetAnisotropy(FlexSolver *s, float *q1, float *q2, float *q3, FlexMemory target)
FLEX_API void flexShutdown()
Low 24 bits represent the particle group for controlling collisions.
Definition: flex.h:127
FLEX_API void flexDestroySolver(FlexSolver *s)
float mSolveSprings
Time spent solving distance constraints.
Definition: flex.h:173
float mEnableCCD
If true then a second collision detection pass will be executed against triangle meshes to prevent tu...
Definition: flex.h:80
FLEX_API void flexGetDensities(FlexSolver *s, float *densities, FlexMemory target)
float mDynamicFriction
Coefficient of friction used when colliding against shapes.
Definition: flex.h:70
float mParticleFriction
Coefficient of friction used when colliding particles.
Definition: flex.h:72
float mParticleCollisionMargin
Increases the radius used during neighbor finding, this is useful if particles are expected to move s...
Definition: flex.h:112
FLEX_API void flexSetConvexes(FlexSolver *s, const float *aabbMin, const float *aabbMax, const int *planeOffsets, const int *planeCounts, const float *planes, const float *positions, const float *rotations, const float *prevPositions, const float *prevRotations, const int *flags, int numConvexes, int numPlanes, FlexMemory source)