33 #define NV_FLEX_API __declspec(dllexport)
39 #define NV_FLEX_VERSION 110
1147 NV_FLEX_API
void NvFlexSetDebug(
NvFlexSolver* solver,
bool enable);
1148 NV_FLEX_API
void NvFlexGetShapeBVH(
NvFlexSolver* solver,
void* bvh);
NV_FLEX_API int NvFlexGetActiveCount(NvFlexSolver *solver)
float solveShapes
Time spent solving rigid body constraints.
Definition: NvFlex.h:198
NV_FLEX_API NvFlexSolverCallback NvFlexRegisterSolverCallback(NvFlexSolver *solver, NvFlexSolverCallback function, NvFlexSolverCallbackStage stage)
float radius
Definition: NvFlex.h:760
Warning messages.
Definition: NvFlex.h:219
float solveSprings
Time spent solving distance constraints.
Definition: NvFlex.h:199
NvFlexMapFlags
Definition: NvFlex.h:67
NV_FLEX_API void NvFlexGetRestParticles(NvFlexSolver *solver, NvFlexBuffer *p, int n)
void(* NvFlexErrorCallback)(NvFlexErrorSeverity type, const char *msg, const char *file, int line)
Definition: NvFlex.h:301
Information messages.
Definition: NvFlex.h:218
float smoothing
Control the strength of Laplacian smoothing in particles for rendering, if zero then smoothed positio...
Definition: NvFlex.h:134
NV_FLEX_API void NvFlexSetParams(NvFlexSolver *solver, const NvFlexParams *params)
Called at the end of solver update after the final substep has completed.
Definition: NvFlex.h:233
NV_FLEX_API void NvFlexSetRigids(NvFlexSolver *solver, NvFlexBuffer *offsets, NvFlexBuffer *indices, NvFlexBuffer *restPositions, NvFlexBuffer *restNormals, NvFlexBuffer *stiffness, NvFlexBuffer *rotations, NvFlexBuffer *translations, int numRigids, int numIndices)
NV_FLEX_API void NvFlexGetSmoothParticles(NvFlexSolver *solver, NvFlexBuffer *p, int n)
NV_FLEX_API void NvFlexUpdateTriangleMesh(NvFlexLibrary *lib, NvFlexTriangleMeshId mesh, NvFlexBuffer *vertices, NvFlexBuffer *indices, int numVertices, int numTriangles, const float *lower, const float *upper)
NV_FLEX_API void NvFlexUnmap(NvFlexBuffer *buffer)
If set this particle will interact with particles of the same group.
Definition: NvFlex.h:170
float createCellIndices
Time spent creating grid indices.
Definition: NvFlex.h:187
float shapeCollisionMargin
Increases the radius used during contact finding against kinematic shapes.
Definition: NvFlex.h:154
float scale
Uniform scale of SDF, this corresponds to the world space width of the shape.
Definition: NvFlex.h:804
NV_FLEX_API void NvFlexGetActive(NvFlexSolver *solver, NvFlexBuffer *indices)
int diffuseBallistic
The number of neighbors below which a diffuse particle is considered ballistic.
Definition: NvFlex.h:143
NvFlexRelaxationMode
Definition: NvFlex.h:86
float drag
Drag force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in th...
Definition: NvFlex.h:122
NvFlexErrorSeverity
Definition: NvFlex.h:215
float maxSpeed
The magnitude of particle velocity will be clamped to this value at the end of each step...
Definition: NvFlex.h:113
float planes[8][4]
Collision planes in the form ax + by + cz + d = 0.
Definition: NvFlex.h:156
float cohesion
Control how strongly particles hold each other together, default: 0.025, range [0.0, +inf].
Definition: NvFlex.h:127
float staticFriction
Coefficient of static friction used when colliding against shapes.
Definition: NvFlex.h:107
float collideParticles
Time spent finding particle neighbors.
Definition: NvFlex.h:191
NvFlexCapsuleGeometry capsule
Definition: NvFlex.h:815
float predict
Time spent in prediction.
Definition: NvFlex.h:186
float updateDiffuse
Time spent updating diffuse particles.
Definition: NvFlex.h:204
NvFlexSphereGeometry sphere
Definition: NvFlex.h:814
float collisionDistance
Distance particles maintain against shapes, note that for robust collision against triangle meshes th...
Definition: NvFlex.h:152
NvFlexTriangleMeshGeometry triMesh
Definition: NvFlex.h:818
float solveContacts
Time spent solving contact constraints.
Definition: NvFlex.h:200
NvFlexComputeType computeType
Set to eNvFlexD3D11 if DirectX 11 should be used, eNvFlexD3D12 for DirectX 12, this must match the li...
Definition: NvFlex.h:284
NV_FLEX_API void NvFlexDestroyDistanceField(NvFlexLibrary *lib, NvFlexDistanceFieldId sdf)
Use DirectX 11 compute for Flex, the application must link against the D3D libraries.
Definition: NvFlex.h:242
NV_FLEX_API void NvFlexDestroySolver(NvFlexSolver *solver)
Lower 3 bits holds the type of the collision shape.
Definition: NvFlex.h:834
const int * originalToSortedMap
Device pointer that maps the sorted callback data to the original position given by SetParticles() ...
Definition: NvFlex.h:271
float halfHeight
Definition: NvFlex.h:769
Calling thread will be blocked until buffer is ready for access, default.
Definition: NvFlex.h:69
NV_FLEX_API void NvFlexSetDiffuseParticles(NvFlexSolver *solver, NvFlexBuffer *p, NvFlexBuffer *v, int n)
struct NvFlexSolver NvFlexSolver
Definition: NvFlex.h:57
Called at the end of each substep after the velocity has been updated by the constraints.
Definition: NvFlex.h:232
float * particles
Device pointer to the active particle basic data in the form x,y,z,1/m.
Definition: NvFlex.h:263
NV_FLEX_API void NvFlexSetInflatables(NvFlexSolver *solver, NvFlexBuffer *startTris, NvFlexBuffer *numTris, NvFlexBuffer *restVolumes, NvFlexBuffer *overPressures, NvFlexBuffer *constraintScales, int numInflatables)
Called at the beginning of each constraint iteration.
Definition: NvFlex.h:229
NV_FLEX_API void NvFlexGetTriangleMeshBounds(NvFlexLibrary *lib, const NvFlexTriangleMeshId mesh, float *lower, float *upper)
NV_FLEX_API NvFlexConvexMeshId NvFlexCreateConvexMesh(NvFlexLibrary *lib)
NV_FLEX_API void * NvFlexMap(NvFlexBuffer *buffer, int flags)
float time
Definition: NvFlex.h:993
float updateNormals
Time spent updating vertex normals.
Definition: NvFlex.h:206
unsigned int NvFlexTriangleMeshId
Definition: NvFlex.h:633
The relaxation factor is a fixed multiplier on each constraint's delta divided by the particle's cons...
Definition: NvFlex.h:89
NV_FLEX_API NvFlexBuffer * NvFlexRegisterD3DBuffer(NvFlexLibrary *lib, void *buffer, int elementCount, int elementByteStride)
Buffer contents will be discarded, this allows for efficent buffer reuse.
Definition: NvFlex.h:71
Indicates that the shape is a trigger volume, this means it will not perform any collision response...
Definition: NvFlex.h:836
A sphere shape, see FlexSphereGeometry.
Definition: NvFlex.h:824
A signed distance field shape, see FlexSDFGeometry.
Definition: NvFlex.h:829
int deviceIndex
The GPU device index that should be used, if there is already a CUDA context on the calling thread th...
Definition: NvFlex.h:279
bool fluid
If true then particles with phase 0 are considered fluid particles and interact using the position ba...
Definition: NvFlex.h:126
float viscosity
Smoothes particle velocities using XSPH viscosity.
Definition: NvFlex.h:129
NvFlexTriangleMeshId mesh
A triangle mesh pointer created by NvFlexCreateTriangleMesh()
Definition: NvFlex.h:795
NV_FLEX_API void NvFlexGetVelocities(NvFlexSolver *solver, NvFlexBuffer *v, int n)
NV_FLEX_API int NvFlexMakePhase(int group, int flags)
Definition: NvFlex.h:178
float adhesion
Controls how strongly particles stick to surfaces they hit, default 0.0, range [0.0, +inf].
Definition: NvFlex.h:110
NV_FLEX_API void NvFlexUnregisterOGLBuffer(NvFlexBuffer *buf)
float halfExtents[3]
Definition: NvFlex.h:777
NV_FLEX_API void NvFlexGetPhases(NvFlexSolver *solver, NvFlexBuffer *phases, int n)
NV_FLEX_API NvFlexDistanceFieldId NvFlexCreateDistanceField(NvFlexLibrary *lib)
int * phases
Device pointer to the active particle phase data.
Definition: NvFlex.h:265
NV_FLEX_API void NvFlexFlush(NvFlexLibrary *lib)
NV_FLEX_API void NvFlexGetBounds(NvFlexSolver *solver, NvFlexBuffer *lower, NvFlexBuffer *upper)
Host mappable buffer, pinned memory on CUDA, staging buffer on DX.
Definition: NvFlex.h:79
int numActive
The number of active particles returned, the callback data only return pointers to active particle da...
Definition: NvFlex.h:267
NV_FLEX_API NvFlexLibrary * NvFlexGetSolverLibrary(NvFlexSolver *solver)
struct NvFlexBuffer NvFlexBuffer
Definition: NvFlex.h:62
float sortCellIndices
Time spent sorting grid indices.
Definition: NvFlex.h:188
float radius
The maximum interaction radius for particles.
Definition: NvFlex.h:101
NV_FLEX_API void NvFlexGetContacts(NvFlexSolver *solver, NvFlexBuffer *planes, NvFlexBuffer *velocities, NvFlexBuffer *indices, NvFlexBuffer *counts)
NvFlexBoxGeometry box
Definition: NvFlex.h:816
float * velocities
Device pointer to the active particle velocity data in the form x,y,z,w (last component is not used) ...
Definition: NvFlex.h:264
float anisotropyMin
Clamp the anisotropy scale to this fraction of the radius.
Definition: NvFlex.h:132
float applyDeltas
Time spent adding position deltas to particles.
Definition: NvFlex.h:202
NvFlexDistanceFieldId field
A signed distance field pointer created by NvFlexCreateDistanceField()
Definition: NvFlex.h:805
float calculateDensity
Time spent calculating fluid density.
Definition: NvFlex.h:195
void * userData
Definition: NvFlex.h:292
A capsule shape, see FlexCapsuleGeometry.
Definition: NvFlex.h:825
NV_FLEX_API NvFlexTriangleMeshId NvFlexCreateTriangleMesh(NvFlexLibrary *lib)
NV_FLEX_API void NvFlexSetRestParticles(NvFlexSolver *solver, NvFlexBuffer *p, int n)
NV_FLEX_API void NvFlexShutdown(NvFlexLibrary *lib)
NvFlexSolver * solver
Pointer to the solver that the callback is registered to.
Definition: NvFlex.h:260
If set this particle will generate fluid density constraints for its overlapping neighbors.
Definition: NvFlex.h:172
NvFlexPhase
Definition: NvFlex.h:166
NV_FLEX_API void NvFlexUnregisterD3DBuffer(NvFlexBuffer *buf)
float sleepThreshold
Particles with a velocity magnitude < this threshold will be considered fixed.
Definition: NvFlex.h:111
NV_FLEX_API void NvFlexGetDensities(NvFlexSolver *solver, NvFlexBuffer *densities, int n)
NV_FLEX_API int NvFlexGetVersion()
float anisotropyMax
Clamp the anisotropy scale to this fraction of the radius.
Definition: NvFlex.h:133
float collideTriangles
Time spent colliding triangle shapes.
Definition: NvFlex.h:193
NV_FLEX_API int NvFlexGetDetailTimers(NvFlexSolver *solver, NvFlexDetailTimer **timers)
NV_FLEX_API void NvFlexSetVelocities(NvFlexSolver *solver, NvFlexBuffer *v, int n)
NV_FLEX_API void NvFlexGetConvexMeshBounds(NvFlexLibrary *lib, NvFlexConvexMeshId mesh, float *lower, float *upper)
Indicates the shape is dynamic and should have lower priority over static collision shapes...
Definition: NvFlex.h:835
Calling thread will check if buffer is ready for access, if not ready then the method will return NUL...
Definition: NvFlex.h:70
NV_FLEX_API void NvFlexGetNormals(NvFlexSolver *solver, NvFlexBuffer *normals, int n)
float shockPropagation
Artificially decrease the mass of particles based on height from a fixed reference point...
Definition: NvFlex.h:116
NV_FLEX_API const char * NvFlexGetDeviceName(NvFlexLibrary *lib)
NV_FLEX_API void NvFlexDestroyConvexMesh(NvFlexLibrary *lib, NvFlexConvexMeshId convex)
float collideFields
Time spent colliding signed distance field shapes.
Definition: NvFlex.h:194
float calculateAnisotropy
Time spent calculating particle anisotropy for fluid.
Definition: NvFlex.h:203
void * renderContext
Direct3D context to use for simulation, if none is specified a new context will be created...
Definition: NvFlex.h:282
struct NvFlexLibrary NvFlexLibrary
Definition: NvFlex.h:52
NV_FLEX_API void NvFlexAcquireContext(NvFlexLibrary *lib)
NV_FLEX_API NvFlexLibrary * NvFlexInit(int version=NV_FLEX_VERSION, NvFlexErrorCallback errorFunc=0, NvFlexInitDesc *desc=0)
float freeSurfaceDrag
Drag force applied to boundary fluid particles.
Definition: NvFlex.h:136
NV_FLEX_API float NvFlexGetDeviceLatency(NvFlexSolver *solver)
NvFlexSDFGeometry sdf
Definition: NvFlex.h:819
float maxAcceleration
The magnitude of particle acceleration will be clamped to this value at the end of each step (limits ...
Definition: NvFlex.h:114
float wind[3]
Constant acceleration applied to particles that belong to dynamic triangles, drag needs to be > 0 for...
Definition: NvFlex.h:121
NV_FLEX_API void NvFlexUpdateDistanceField(NvFlexLibrary *lib, NvFlexDistanceFieldId sdf, int dimx, int dimy, int dimz, NvFlexBuffer *field)
float surfaceTension
Controls how strongly particles attempt to minimize surface area, default: 0.0, range: [0...
Definition: NvFlex.h:128
float dt
The per-update time-step, this is the value passed to NvFlexUpdateSolver()
Definition: NvFlex.h:269
float diffuseSortAxis[3]
Diffuse particles will be sorted by depth along this axis if non-zero.
Definition: NvFlex.h:144
float fluidRestDistance
The distance fluid particles are spaced at the rest density, must be in the range (0...
Definition: NvFlex.h:103
float reorder
Time spent reordering particles.
Definition: NvFlex.h:190
unsigned int NvFlexDistanceFieldId
Definition: NvFlex.h:638
A triangle mesh shape, see FlexTriangleMeshGeometry.
Definition: NvFlex.h:828
If set this particle will ignore collisions with particles closer than the radius in the rest pose...
Definition: NvFlex.h:171
NV_FLEX_API void NvFlexGetAnisotropy(NvFlexSolver *solver, NvFlexBuffer *q1, NvFlexBuffer *q2, NvFlexBuffer *q3)
NV_FLEX_API void NvFlexGetTimers(NvFlexSolver *solver, NvFlexTimers *timers)
NvFlexConvexMeshId mesh
Definition: NvFlex.h:786
NvFlexConvexMeshGeometry convexMesh
Definition: NvFlex.h:817
NvFlexSolverCallbackStage
Definition: NvFlex.h:227
float dissipation
Damps particle velocity based on how many particle contacts it has.
Definition: NvFlex.h:117
NvFlexCollisionShapeType
Definition: NvFlex.h:822
Used only in debug version of dll.
Definition: NvFlex.h:220
Use CUDA compute for Flex, the application must link against the CUDA libraries.
Definition: NvFlex.h:241
NvFlexRelaxationMode relaxationMode
How the relaxation is applied inside the solver.
Definition: NvFlex.h:159
float lift
Lift force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in th...
Definition: NvFlex.h:123
NV_FLEX_API void NvFlexGetDeviceAndContext(NvFlexLibrary *lib, void **device, void **context)
void * renderDevice
Direct3D device to use for simulation, if none is specified a new device and context will be created...
Definition: NvFlex.h:281
A box shape, see FlexBoxGeometry.
Definition: NvFlex.h:826
float damping
Viscous drag force, applies a force proportional, and opposite to the particle velocity.
Definition: NvFlex.h:118
NV_FLEX_API void NvFlexSetDynamicTriangles(NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *normals, int numTris)
NvFlexCollisionShapeFlags
Definition: NvFlex.h:832
int numPlanes
Num collision planes.
Definition: NvFlex.h:157
NV_FLEX_API void NvFlexUpdateConvexMesh(NvFlexLibrary *lib, NvFlexConvexMeshId convex, NvFlexBuffer *planes, int numPlanes, float *lower, float *upper)
NV_FLEX_API NvFlexBuffer * NvFlexAllocBuffer(NvFlexLibrary *lib, int elementCount, int elementByteStride, NvFlexBufferType type)
float collideShapes
Time spent colliding convex shapes.
Definition: NvFlex.h:192
float particleFriction
Coefficient of friction used when colliding particles.
Definition: NvFlex.h:108
NV_FLEX_API void NvFlexUpdateSolver(NvFlexSolver *solver, float dt, int substeps, bool enableTimers)
NV_FLEX_API void NvFlexSetNormals(NvFlexSolver *solver, NvFlexBuffer *normals, int n)
NV_FLEX_API void NvFlexGetRigidTransforms(NvFlexSolver *solver, NvFlexBuffer *rotations, NvFlexBuffer *translations)
float createGrid
Time spent creating grid.
Definition: NvFlex.h:189
Low 24 bits represent the particle group for controlling collisions.
Definition: NvFlex.h:168
NV_FLEX_API void NvFlexGetParticles(NvFlexSolver *solver, NvFlexBuffer *p, int n)
float buoyancy
Gravity is scaled by this value for fluid particles.
Definition: NvFlex.h:137
All log types.
Definition: NvFlex.h:221
NV_FLEX_API void NvFlexSetShapes(NvFlexSolver *solver, NvFlexBuffer *geometry, NvFlexBuffer *shapePositions, NvFlexBuffer *shapeRotations, NvFlexBuffer *shapePrevPositions, NvFlexBuffer *shapePrevRotations, NvFlexBuffer *shapeFlags, int numShapes)
NV_FLEX_API void NvFlexSetParticles(NvFlexSolver *solver, NvFlexBuffer *p, int n)
Use DirectX 12 compute for Flex, the application must link against the D3D libraries.
Definition: NvFlex.h:243
float scale[3]
The scale of the object from local space to world space.
Definition: NvFlex.h:794
float solveDensities
Time spent solving density constraints.
Definition: NvFlex.h:196
float plasticThreshold
Particles belonging to rigid shapes that move with a position delta magnitude > threshold will be per...
Definition: NvFlex.h:148
NV_FLEX_API void NvFlexDestroyTriangleMesh(NvFlexLibrary *lib, NvFlexTriangleMeshId mesh)
float gravity[3]
Constant acceleration applied to all particles.
Definition: NvFlex.h:100
Called at the end of each constraint iteration.
Definition: NvFlex.h:230
Error messages.
Definition: NvFlex.h:217
NV_FLEX_API void NvFlexFreeBuffer(NvFlexBuffer *buf)
float solveInflatables
Time spent solving pressure constraints.
Definition: NvFlex.h:201
Called at the beginning of each substep after the prediction step has been completed.
Definition: NvFlex.h:231
NV_FLEX_API void NvFlexSetPhases(NvFlexSolver *solver, NvFlexBuffer *phases, int n)
The relaxation factor is a fixed multiplier on each constraint's position delta.
Definition: NvFlex.h:88
float total
Sum of all timers above.
Definition: NvFlex.h:209
void * userData
Pointer to the user data provided to NvFlexRegisterSolverCallback()
Definition: NvFlex.h:261
float radius
Definition: NvFlex.h:768
NV_FLEX_API void NvFlexGetDynamicTriangles(NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *normals, int numTris)
NV_FLEX_API int NvFlexMakeShapeFlags(NvFlexCollisionShapeType type, bool dynamic)
Definition: NvFlex.h:844
NV_FLEX_API NvFlexBuffer * NvFlexRegisterOGLBuffer(NvFlexLibrary *lib, int buf, int elementCount, int elementByteStride)
float relaxationFactor
Control the convergence rate of the parallel solver, default: 1, values greater than 1 may lead to in...
Definition: NvFlex.h:160
NV_FLEX_API void NvFlexSetSprings(NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *restLengths, NvFlexBuffer *stiffness, int numSprings)
float finalize
Time spent finalizing state.
Definition: NvFlex.h:207
const int * sortedToOriginalMap
Device pointer that maps the original particle index to the index in the callback data structure...
Definition: NvFlex.h:272
NvFlexComputeType
Definition: NvFlex.h:239
NV_FLEX_API void NvFlexSetActive(NvFlexSolver *solver, NvFlexBuffer *indices, int n)
float dynamicFriction
Coefficient of friction used when colliding against shapes.
Definition: NvFlex.h:106
float plasticCreep
Controls the rate at which particles in the rest pose are deformed for particles passing the deformat...
Definition: NvFlex.h:149
float scale[3]
Definition: NvFlex.h:785
float diffuseBuoyancy
Scales force opposing gravity that diffuse particles receive.
Definition: NvFlex.h:141
float updateBounds
Time spent updating particle bounds.
Definition: NvFlex.h:208
char * name
Definition: NvFlex.h:992
float solidRestDistance
The distance non-fluid particles attempt to maintain from each other, must be in the range (0...
Definition: NvFlex.h:102
float solidPressure
Add pressure from solid surfaces to particles.
Definition: NvFlex.h:135
float solveVelocities
Time spent solving velocity constraints.
Definition: NvFlex.h:197
Number of stages.
Definition: NvFlex.h:234
float restitution
Coefficient of restitution used when colliding against shapes, particle collisions are always inelast...
Definition: NvFlex.h:109
int numIterations
Number of solver iterations to perform per-substep.
Definition: NvFlex.h:98
NV_FLEX_API void NvFlexRestoreContext(NvFlexLibrary *lib)
NV_FLEX_API void NvFlexGetParams(NvFlexSolver *solver, NvFlexParams *params)
NV_FLEX_API NvFlexSolver * NvFlexCreateSolver(NvFlexLibrary *lib, int maxParticles, int maxDiffuseParticles, int maxNeighborsPerParticle=96)
float anisotropyScale
Control how much anisotropy is present in resulting ellipsoids for rendering, if zero then anisotropy...
Definition: NvFlex.h:131
float vorticityConfinement
Increases vorticity by applying rotational forces to particles.
Definition: NvFlex.h:130
NV_FLEX_API int NvFlexGetDiffuseParticles(NvFlexSolver *solver, NvFlexBuffer *p, NvFlexBuffer *v, NvFlexBuffer *indices)
float diffuseLifetime
Time in seconds that a diffuse particle will live for after being spawned, particles will be spawned ...
Definition: NvFlex.h:145
float diffuseDrag
Scales force diffuse particles receive in direction of neighbor fluid particles.
Definition: NvFlex.h:142
float particleCollisionMargin
Increases the radius used during neighbor finding, this is useful if particles are expected to move s...
Definition: NvFlex.h:153
float diffuseThreshold
Particles with kinetic energy + divergence above this threshold will spawn new diffuse particles...
Definition: NvFlex.h:140
Device memory buffer, mapping this on CUDA will return a device memory pointer, and will return a buf...
Definition: NvFlex.h:80
NV_FLEX_API void NvFlexGetSprings(NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *restLengths, NvFlexBuffer *stiffness, int numSprings)
A convex mesh shape, see FlexConvexMeshGeometry.
Definition: NvFlex.h:827
float updateTriangles
Time spent updating dynamic triangles.
Definition: NvFlex.h:205
NvFlexBufferType
Definition: NvFlex.h:77
bool enableExtensions
Enable or disable NVIDIA/AMD extensions in DirectX, can lead to improved performance.
Definition: NvFlex.h:280
unsigned int NvFlexConvexMeshId
Definition: NvFlex.h:645