FLEX  1.2.0
NvFlex.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2013-2017 NVIDIA Corporation. All rights reserved.
27 
28 #ifndef NV_FLEX_H
29 #define NV_FLEX_H
30 
32 #if _WIN32
33 #define NV_FLEX_API __declspec(dllexport)
34 #else
35 #define NV_FLEX_API
36 #endif
37 
38 // least 2 significant digits define minor version, eg: 10 -> version 0.10
39 #define NV_FLEX_VERSION 120
40 
42 
47 extern "C" {
48 
53 
57 typedef struct NvFlexSolver NvFlexSolver;
58 
62 typedef struct NvFlexBuffer NvFlexBuffer;
63 
68 {
71 };
72 
77 {
80 };
81 
86 {
89 };
90 
91 
96 {
98 
99  float gravity[3];
100  float radius;
103 
104  // common params
108  float restitution;
109  float adhesion;
111 
112  float maxSpeed;
114 
116  float dissipation;
117  float damping;
118 
119  // cloth params
120  float wind[3];
121  float drag;
122  float lift;
123 
124  // fluid params
125  float cohesion;
127  float viscosity;
132  float smoothing;
135  float buoyancy;
136 
137  // diffuse params
140  float diffuseDrag;
143 
144  // collision params
148 
149  float planes[8][4];
150  int numPlanes;
151 
154 };
155 
156 
161 {
162  eNvFlexPhaseGroupMask = 0x000fffff,
163  eNvFlexPhaseFlagsMask = 0x00f00000,
165 
168  eNvFlexPhaseFluid = 1 << 22,
169  eNvFlexPhaseUnused = 1 << 23,
170 
179 };
180 
181 
190 NV_FLEX_API inline int NvFlexMakePhaseWithChannels(int group, int particleFlags, int shapeChannels) { return (group & eNvFlexPhaseGroupMask) | (particleFlags & eNvFlexPhaseFlagsMask) | (shapeChannels & eNvFlexPhaseShapeChannelMask); }
191 
195 NV_FLEX_API inline int NvFlexMakePhase(int group, int particleFlags) { return NvFlexMakePhaseWithChannels(group, particleFlags, eNvFlexPhaseShapeChannelMask); }
196 
197 
202 {
203  float predict;
206  float createGrid;
207  float reorder;
215  float solveShapes;
216  float solveSprings;
219  float applyDeltas;
224  float finalize;
225  float updateBounds;
226  float total;
227 };
228 
233 {
239 };
240 
241 
245 {
252 };
253 
254 
268 {
270  void* userData;
271 
272  float* particles;
273  float* velocities;
274  int* phases;
275 
276  int numActive;
277 
278  float dt;
279 
280  const int* originalToSortedMap;
281  const int* sortedToOriginalMap;
282 };
283 
287 {
289  void* userData;
290 
292  void (*function)(NvFlexSolverCallbackParams params);
293 };
294 
298 typedef void (*NvFlexErrorCallback)(NvFlexErrorSeverity type, const char* msg, const char* file, int line);
299 
300 
301 
302 
306 {
310 };
311 
312 
316 {
319  void* renderDevice;
323 
325 };
326 
336 NV_FLEX_API NvFlexLibrary* NvFlexInit(int version = NV_FLEX_VERSION, NvFlexErrorCallback errorFunc = 0, NvFlexInitDesc* desc = 0);
337 
344 NV_FLEX_API void NvFlexShutdown(NvFlexLibrary* lib);
345 
349 NV_FLEX_API int NvFlexGetVersion();
350 
355 {
359 };
360 
365 {
367 
371 };
372 
377 NV_FLEX_API void NvFlexSetSolverDescDefaults(NvFlexSolverDesc* desc);
378 
385 NV_FLEX_API NvFlexSolver* NvFlexCreateSolver(NvFlexLibrary* lib, const NvFlexSolverDesc* desc);
391 NV_FLEX_API void NvFlexDestroySolver(NvFlexSolver* solver);
392 
400 
407 NV_FLEX_API void NvFlexGetSolverDesc(NvFlexSolver* solver, NvFlexSolverDesc* desc);
408 
418 
478 NV_FLEX_API void NvFlexUpdateSolver(NvFlexSolver* solver, float dt, int substeps, bool enableTimers);
479 
486 NV_FLEX_API void NvFlexSetParams(NvFlexSolver* solver, const NvFlexParams* params);
487 
495 NV_FLEX_API void NvFlexGetParams(NvFlexSolver* solver, NvFlexParams* params);
496 
501 {
502  int srcOffset; //<! Offset in elements from the start of the source buffer to begin reading from
503  int dstOffset; //<! Offset in elements from the start of the destination buffer to being writing to
504  int elementCount; //<! Number of elements to copy
505 };
506 
514 NV_FLEX_API void NvFlexSetActive(NvFlexSolver* solver, NvFlexBuffer* indices, const NvFlexCopyDesc* desc);
515 
523 NV_FLEX_API void NvFlexGetActive(NvFlexSolver* solver, NvFlexBuffer* indices, const NvFlexCopyDesc* desc);
524 
531 NV_FLEX_API void NvFlexSetActiveCount(NvFlexSolver* solver, int n);
532 
539 NV_FLEX_API int NvFlexGetActiveCount(NvFlexSolver* solver);
540 
549 NV_FLEX_API void NvFlexSetParticles(NvFlexSolver* solver, NvFlexBuffer* p, const NvFlexCopyDesc* desc);
550 
558 NV_FLEX_API void NvFlexGetParticles(NvFlexSolver* solver, NvFlexBuffer* p, const NvFlexCopyDesc* desc);
559 
569 NV_FLEX_API void NvFlexSetRestParticles(NvFlexSolver* solver, NvFlexBuffer* p, const NvFlexCopyDesc* desc);
570 
579 NV_FLEX_API void NvFlexGetRestParticles(NvFlexSolver* solver, NvFlexBuffer* p, const NvFlexCopyDesc* desc);
580 
581 
589 NV_FLEX_API void NvFlexGetSmoothParticles(NvFlexSolver* solver, NvFlexBuffer* p, const NvFlexCopyDesc* desc);
590 
599 NV_FLEX_API void NvFlexSetVelocities(NvFlexSolver* solver, NvFlexBuffer* v, const NvFlexCopyDesc* desc);
607 NV_FLEX_API void NvFlexGetVelocities(NvFlexSolver* solver, NvFlexBuffer* v, const NvFlexCopyDesc* desc);
608 
625 NV_FLEX_API void NvFlexSetPhases(NvFlexSolver* solver, NvFlexBuffer* phases, const NvFlexCopyDesc* desc);
633 NV_FLEX_API void NvFlexGetPhases(NvFlexSolver* solver, NvFlexBuffer* phases, const NvFlexCopyDesc* desc);
634 
642 NV_FLEX_API void NvFlexSetNormals(NvFlexSolver* solver, NvFlexBuffer* normals, const NvFlexCopyDesc* desc);
643 
651 NV_FLEX_API void NvFlexGetNormals(NvFlexSolver* solver, NvFlexBuffer* normals, const NvFlexCopyDesc* desc);
652 
653 
666 NV_FLEX_API void NvFlexSetSprings(NvFlexSolver* solver, NvFlexBuffer* indices, NvFlexBuffer* restLengths, NvFlexBuffer* stiffness, int numSprings);
676 NV_FLEX_API void NvFlexGetSprings(NvFlexSolver* solver, NvFlexBuffer* indices, NvFlexBuffer* restLengths, NvFlexBuffer* stiffness, int numSprings);
677 
696 NV_FLEX_API void NvFlexSetRigids(NvFlexSolver* solver, NvFlexBuffer* offsets, NvFlexBuffer* indices, NvFlexBuffer* restPositions, NvFlexBuffer* restNormals, NvFlexBuffer* stiffness, NvFlexBuffer* thresholds, NvFlexBuffer* creeps, NvFlexBuffer* rotations, NvFlexBuffer* translations, int numRigids, int numIndices);
697 
713 NV_FLEX_API void NvFlexGetRigids(NvFlexSolver* solver, NvFlexBuffer* offsets, NvFlexBuffer* indices, NvFlexBuffer* restPositions, NvFlexBuffer* restNormals, NvFlexBuffer* stiffness, NvFlexBuffer* thresholds, NvFlexBuffer* creeps, NvFlexBuffer* rotations, NvFlexBuffer* translations);
714 
718 typedef unsigned int NvFlexTriangleMeshId;
719 
723 typedef unsigned int NvFlexDistanceFieldId;
724 
730 typedef unsigned int NvFlexConvexMeshId;
731 
738 NV_FLEX_API NvFlexTriangleMeshId NvFlexCreateTriangleMesh(NvFlexLibrary* lib);
739 
746 NV_FLEX_API void NvFlexDestroyTriangleMesh(NvFlexLibrary* lib, NvFlexTriangleMeshId mesh);
747 
761 NV_FLEX_API void NvFlexUpdateTriangleMesh(NvFlexLibrary* lib, NvFlexTriangleMeshId mesh, NvFlexBuffer* vertices, NvFlexBuffer* indices, int numVertices, int numTriangles, const float* lower, const float* upper);
762 
771 NV_FLEX_API void NvFlexGetTriangleMeshBounds(NvFlexLibrary* lib, const NvFlexTriangleMeshId mesh, float* lower, float* upper);
772 
779 NV_FLEX_API NvFlexDistanceFieldId NvFlexCreateDistanceField(NvFlexLibrary* lib);
780 
787 NV_FLEX_API void NvFlexDestroyDistanceField(NvFlexLibrary* lib, NvFlexDistanceFieldId sdf);
788 
800 NV_FLEX_API void NvFlexUpdateDistanceField(NvFlexLibrary* lib, NvFlexDistanceFieldId sdf, int dimx, int dimy, int dimz, NvFlexBuffer* field);
801 
808 NV_FLEX_API NvFlexConvexMeshId NvFlexCreateConvexMesh(NvFlexLibrary* lib);
809 
816 NV_FLEX_API void NvFlexDestroyConvexMesh(NvFlexLibrary* lib, NvFlexConvexMeshId convex);
817 
828 NV_FLEX_API void NvFlexUpdateConvexMesh(NvFlexLibrary* lib, NvFlexConvexMeshId convex, NvFlexBuffer* planes, int numPlanes, const float* lower, const float* upper);
829 
838 NV_FLEX_API void NvFlexGetConvexMeshBounds(NvFlexLibrary* lib, NvFlexConvexMeshId mesh, float* lower, float* upper);
839 
844 {
845  float radius;
846 };
847 
852 {
853  float radius;
854  float halfHeight;
855 };
856 
861 {
862  float halfExtents[3];
863 };
864 
869 {
870  float scale[3];
871  NvFlexConvexMeshId mesh;
872 };
873 
878 {
879  float scale[3];
880  NvFlexTriangleMeshId mesh;
881 };
882 
888 {
889  float scale;
890  NvFlexDistanceFieldId field;
891 };
892 
898 {
905 };
906 
908 {
915 };
916 
918 {
922 
924 };
925 
933 NV_FLEX_API inline int NvFlexMakeShapeFlagsWithChannels(NvFlexCollisionShapeType type, bool dynamic, int shapeChannels) { return type | (dynamic?eNvFlexShapeFlagDynamic:0) | shapeChannels; }
934 
938 NV_FLEX_API inline int NvFlexMakeShapeFlags(NvFlexCollisionShapeType type, bool dynamic) { return NvFlexMakeShapeFlagsWithChannels(type, dynamic, eNvFlexPhaseShapeChannelMask); }
939 
940 
954 NV_FLEX_API void NvFlexSetShapes(NvFlexSolver* solver, NvFlexBuffer* geometry, NvFlexBuffer* shapePositions, NvFlexBuffer* shapeRotations, NvFlexBuffer* shapePrevPositions, NvFlexBuffer* shapePrevRotations, NvFlexBuffer* shapeFlags, int numShapes);
955 
966 NV_FLEX_API void NvFlexSetDynamicTriangles(NvFlexSolver* solver, NvFlexBuffer* indices, NvFlexBuffer* normals, int numTris);
975 NV_FLEX_API void NvFlexGetDynamicTriangles(NvFlexSolver* solver, NvFlexBuffer* indices, NvFlexBuffer* normals, int numTris);
976 
991 NV_FLEX_API void NvFlexSetInflatables(NvFlexSolver* solver, NvFlexBuffer* startTris, NvFlexBuffer* numTris, NvFlexBuffer* restVolumes, NvFlexBuffer* overPressures, NvFlexBuffer* constraintScales, int numInflatables);
992 
1000 NV_FLEX_API void NvFlexGetDensities(NvFlexSolver* solver, NvFlexBuffer* densities, const NvFlexCopyDesc* desc);
1001 
1016 NV_FLEX_API void NvFlexGetAnisotropy(NvFlexSolver* solver, NvFlexBuffer* q1, NvFlexBuffer* q2, NvFlexBuffer* q3, const NvFlexCopyDesc* desc);
1026 NV_FLEX_API void NvFlexGetDiffuseParticles(NvFlexSolver* solver, NvFlexBuffer* p, NvFlexBuffer* v, NvFlexBuffer* count);
1027 
1038 NV_FLEX_API void NvFlexSetDiffuseParticles(NvFlexSolver* solver, NvFlexBuffer* p, NvFlexBuffer* v, int n);
1039 
1049 NV_FLEX_API void NvFlexGetContacts(NvFlexSolver* solver, NvFlexBuffer* planes, NvFlexBuffer* velocities, NvFlexBuffer* indices, NvFlexBuffer* counts);
1050 
1094 NV_FLEX_API void NvFlexGetNeighbors(NvFlexSolver* solver, NvFlexBuffer* neighbors, NvFlexBuffer* counts, NvFlexBuffer* remap);
1095 
1104 NV_FLEX_API void NvFlexGetBounds(NvFlexSolver* solver, NvFlexBuffer* lower, NvFlexBuffer* upper);
1105 
1117 NV_FLEX_API float NvFlexGetDeviceLatency(NvFlexSolver* solver, unsigned long long* begin, unsigned long long* end, unsigned long long* frequency);
1118 
1129 NV_FLEX_API void NvFlexGetTimers(NvFlexSolver* solver, NvFlexTimers* timers);
1130 
1135 {
1136  char* name;
1137  float time;
1138 };
1139 
1152 NV_FLEX_API int NvFlexGetDetailTimers(NvFlexSolver* solver, NvFlexDetailTimer** timers);
1153 
1163 NV_FLEX_API NvFlexBuffer* NvFlexAllocBuffer(NvFlexLibrary* lib, int elementCount, int elementByteStride, NvFlexBufferType type);
1164 
1170 NV_FLEX_API void NvFlexFreeBuffer(NvFlexBuffer* buf);
1171 
1181 NV_FLEX_API void* NvFlexMap(NvFlexBuffer* buffer, int flags);
1182 
1188 NV_FLEX_API void NvFlexUnmap(NvFlexBuffer* buffer);
1189 
1219 NV_FLEX_API NvFlexBuffer* NvFlexRegisterOGLBuffer(NvFlexLibrary* lib, int buf, int elementCount, int elementByteStride);
1220 
1226 NV_FLEX_API void NvFlexUnregisterOGLBuffer(NvFlexBuffer* buf);
1227 
1237 NV_FLEX_API NvFlexBuffer* NvFlexRegisterD3DBuffer(NvFlexLibrary* lib, void* buffer, int elementCount, int elementByteStride);
1238 
1244 NV_FLEX_API void NvFlexUnregisterD3DBuffer(NvFlexBuffer* buf);
1245 
1251 NV_FLEX_API void NvFlexAcquireContext(NvFlexLibrary* lib);
1252 
1257 NV_FLEX_API void NvFlexRestoreContext(NvFlexLibrary* lib);
1258 
1264 NV_FLEX_API const char* NvFlexGetDeviceName(NvFlexLibrary* lib);
1265 
1275 NV_FLEX_API void NvFlexGetDeviceAndContext(NvFlexLibrary* lib, void** device, void** context);
1276 
1277 
1283 NV_FLEX_API void NvFlexFlush(NvFlexLibrary* lib);
1284 
1285 NV_FLEX_API void NvFlexWait(NvFlexLibrary* lib);
1286 
1288 
1293 NV_FLEX_API void NvFlexSetDebug(NvFlexSolver* solver, bool enable);
1294 NV_FLEX_API void NvFlexGetShapeBVH(NvFlexSolver* solver, void* bvh);
1295 NV_FLEX_API void NvFlexCopySolver(NvFlexSolver* dst, NvFlexSolver* src);
1296 NV_FLEX_API void NvFlexCopyDeviceToHost(NvFlexSolver* solver, NvFlexBuffer* pDevice, void* pHost, int size, int stride);
1297 NV_FLEX_API void NvFlexComputeWaitForGraphics(NvFlexLibrary* lib);
1298 
1300 
1301 } // extern "C"
1302 
1303 #endif // NV_FLEX_H
NV_FLEX_API int NvFlexGetActiveCount(NvFlexSolver *solver)
Reserved.
Definition: NvFlex.h:169
float solveShapes
Time spent solving rigid body constraints.
Definition: NvFlex.h:215
NV_FLEX_API NvFlexSolverCallback NvFlexRegisterSolverCallback(NvFlexSolver *solver, NvFlexSolverCallback function, NvFlexSolverCallbackStage stage)
NV_FLEX_API void NvFlexGetPhases(NvFlexSolver *solver, NvFlexBuffer *phases, const NvFlexCopyDesc *desc)
float radius
Definition: NvFlex.h:845
Warning messages.
Definition: NvFlex.h:236
float solveSprings
Time spent solving distance constraints.
Definition: NvFlex.h:216
NvFlexMapFlags
Definition: NvFlex.h:67
int maxDiffuseParticles
Maximum number of diffuse particles in the solver.
Definition: NvFlex.h:369
void(* NvFlexErrorCallback)(NvFlexErrorSeverity type, const char *msg, const char *file, int line)
Definition: NvFlex.h:298
Information messages.
Definition: NvFlex.h:235
float smoothing
Control the strength of Laplacian smoothing in particles for rendering, if zero then smoothed positio...
Definition: NvFlex.h:132
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:250
Particle will collide with shapes with channel 3 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:174
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:166
float createCellIndices
Time spent creating grid indices.
Definition: NvFlex.h:204
Particle will collide with shapes with channel 4 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:175
float shapeCollisionMargin
Increases the radius used during contact finding against kinematic shapes.
Definition: NvFlex.h:147
float scale
Uniform scale of SDF, this corresponds to the world space width of the shape.
Definition: NvFlex.h:889
int diffuseBallistic
The number of neighbors below which a diffuse particle is considered ballistic.
Definition: NvFlex.h:141
NV_FLEX_API void NvFlexSetRigids(NvFlexSolver *solver, NvFlexBuffer *offsets, NvFlexBuffer *indices, NvFlexBuffer *restPositions, NvFlexBuffer *restNormals, NvFlexBuffer *stiffness, NvFlexBuffer *thresholds, NvFlexBuffer *creeps, NvFlexBuffer *rotations, NvFlexBuffer *translations, int numRigids, int numIndices)
NvFlexRelaxationMode
Definition: NvFlex.h:85
float drag
Drag force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in th...
Definition: NvFlex.h:121
NvFlexErrorSeverity
Definition: NvFlex.h:232
NV_FLEX_API void NvFlexSetPhases(NvFlexSolver *solver, NvFlexBuffer *phases, const NvFlexCopyDesc *desc)
float maxSpeed
The magnitude of particle velocity will be clamped to this value at the end of each step...
Definition: NvFlex.h:112
All features enabled.
Definition: NvFlex.h:356
float planes[8][4]
Collision planes in the form ax + by + cz + d = 0.
Definition: NvFlex.h:149
float cohesion
Control how strongly particles hold each other together, default: 0.025, range [0.0, +inf].
Definition: NvFlex.h:125
float staticFriction
Coefficient of static friction used when colliding against shapes.
Definition: NvFlex.h:106
float collideParticles
Time spent finding particle neighbors.
Definition: NvFlex.h:208
NV_FLEX_API void NvFlexGetNormals(NvFlexSolver *solver, NvFlexBuffer *normals, const NvFlexCopyDesc *desc)
NvFlexCapsuleGeometry capsule
Definition: NvFlex.h:900
float predict
Time spent in prediction.
Definition: NvFlex.h:203
NV_FLEX_API void NvFlexGetDiffuseParticles(NvFlexSolver *solver, NvFlexBuffer *p, NvFlexBuffer *v, NvFlexBuffer *count)
Definition: NvFlex.h:868
int maxNeighborsPerParticle
Maximum number of neighbors per-particle, for solids this can be around 32, for fluids up to 128 may ...
Definition: NvFlex.h:370
float updateDiffuse
Time spent updating diffuse particles.
Definition: NvFlex.h:221
NvFlexSphereGeometry sphere
Definition: NvFlex.h:899
float collisionDistance
Distance particles maintain against shapes, note that for robust collision against triangle meshes th...
Definition: NvFlex.h:145
NvFlexTriangleMeshGeometry triMesh
Definition: NvFlex.h:903
float solveContacts
Time spent solving contact constraints.
Definition: NvFlex.h:217
NV_FLEX_API void NvFlexSetActiveCount(NvFlexSolver *solver, int n)
Bits [20, 23] hold flags about how the particle behave.
Definition: NvFlex.h:163
Definition: NvFlex.h:923
NvFlexComputeType computeType
Set to eNvFlexD3D11 if DirectX 11 should be used, eNvFlexD3D12 for DirectX 12, this must match the li...
Definition: NvFlex.h:324
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:308
NV_FLEX_API void NvFlexGetNeighbors(NvFlexSolver *solver, NvFlexBuffer *neighbors, NvFlexBuffer *counts, NvFlexBuffer *remap)
NV_FLEX_API void NvFlexDestroySolver(NvFlexSolver *solver)
Lower 3 bits holds the type of the collision shape given by the NvFlexCollisionShapeType enum...
Definition: NvFlex.h:919
const int * originalToSortedMap
Device pointer that maps the sorted callback data to the original position given by SetParticles() ...
Definition: NvFlex.h:280
float halfHeight
Definition: NvFlex.h:854
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:249
float * particles
Device pointer to the active particle basic data in the form x,y,z,1/m.
Definition: NvFlex.h:272
NV_FLEX_API void NvFlexGetActive(NvFlexSolver *solver, NvFlexBuffer *indices, const NvFlexCopyDesc *desc)
NV_FLEX_API void NvFlexSetInflatables(NvFlexSolver *solver, NvFlexBuffer *startTris, NvFlexBuffer *numTris, NvFlexBuffer *restVolumes, NvFlexBuffer *overPressures, NvFlexBuffer *constraintScales, int numInflatables)
NV_FLEX_API void NvFlexWait(NvFlexLibrary *lib)
NV_FLEX_API void NvFlexSetParticles(NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
Definition: NvFlex.h:843
Definition: NvFlex.h:364
int dstOffset
Definition: NvFlex.h:503
Called at the beginning of each constraint iteration.
Definition: NvFlex.h:246
NV_FLEX_API void NvFlexGetTriangleMeshBounds(NvFlexLibrary *lib, const NvFlexTriangleMeshId mesh, float *lower, float *upper)
NV_FLEX_API int NvFlexMakeShapeFlagsWithChannels(NvFlexCollisionShapeType type, bool dynamic, int shapeChannels)
Definition: NvFlex.h:933
Definition: NvFlex.h:267
NV_FLEX_API NvFlexConvexMeshId NvFlexCreateConvexMesh(NvFlexLibrary *lib)
NV_FLEX_API void * NvFlexMap(NvFlexBuffer *buffer, int flags)
float time
Definition: NvFlex.h:1137
Definition: NvFlex.h:897
float updateNormals
Time spent updating vertex normals.
Definition: NvFlex.h:223
unsigned int NvFlexTriangleMeshId
Definition: NvFlex.h:718
The relaxation factor is a fixed multiplier on each constraint's delta divided by the particle's cons...
Definition: NvFlex.h:88
NV_FLEX_API NvFlexBuffer * NvFlexRegisterD3DBuffer(NvFlexLibrary *lib, void *buffer, int elementCount, int elementByteStride)
Indicates that the shape is a trigger volume, this means it will not perform any collision response...
Definition: NvFlex.h:921
Simple single phase fluid-only particles (no solids)
Definition: NvFlex.h:358
A sphere shape, see FlexSphereGeometry.
Definition: NvFlex.h:909
A signed distance field shape, see FlexSDFGeometry.
Definition: NvFlex.h:914
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:317
float viscosity
Smoothes particle velocities using XSPH viscosity.
Definition: NvFlex.h:127
NvFlexTriangleMeshId mesh
A triangle mesh pointer created by NvFlexCreateTriangleMesh()
Definition: NvFlex.h:880
float adhesion
Controls how strongly particles stick to surfaces they hit, default 0.0, range [0.0, +inf].
Definition: NvFlex.h:109
NV_FLEX_API void NvFlexUnregisterOGLBuffer(NvFlexBuffer *buf)
float halfExtents[3]
Definition: NvFlex.h:862
Definition: NvFlex.h:860
NV_FLEX_API NvFlexDistanceFieldId NvFlexCreateDistanceField(NvFlexLibrary *lib)
int * phases
Device pointer to the active particle phase data.
Definition: NvFlex.h:274
NV_FLEX_API void NvFlexFlush(NvFlexLibrary *lib)
NV_FLEX_API void NvFlexGetBounds(NvFlexSolver *solver, NvFlexBuffer *lower, NvFlexBuffer *upper)
A host mappable buffer, pinned memory on CUDA, staging buffer on DX.
Definition: NvFlex.h:78
int numActive
The number of active particles returned, the callback data only return pointers to active particle da...
Definition: NvFlex.h:276
NV_FLEX_API NvFlexLibrary * NvFlexGetSolverLibrary(NvFlexSolver *solver)
Particle will collide with shapes with channel 7 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:178
struct NvFlexBuffer NvFlexBuffer
Definition: NvFlex.h:62
float sortCellIndices
Time spent sorting grid indices.
Definition: NvFlex.h:205
int srcOffset
Definition: NvFlex.h:502
int maxParticles
Maximum number of regular particles in the solver.
Definition: NvFlex.h:368
NV_FLEX_API void NvFlexGetRestParticles(NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
void * computeContext
Direct3D context to use for simulation, if none is specified a new context will be created...
Definition: NvFlex.h:321
float radius
The maximum interaction radius for particles.
Definition: NvFlex.h:100
NV_FLEX_API void NvFlexGetContacts(NvFlexSolver *solver, NvFlexBuffer *planes, NvFlexBuffer *velocities, NvFlexBuffer *indices, NvFlexBuffer *counts)
NvFlexBoxGeometry box
Definition: NvFlex.h:901
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:273
Particle will collide with shapes with channel 1 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:172
NV_FLEX_API float NvFlexGetDeviceLatency(NvFlexSolver *solver, unsigned long long *begin, unsigned long long *end, unsigned long long *frequency)
float anisotropyMin
Clamp the anisotropy scale to this fraction of the radius.
Definition: NvFlex.h:130
float applyDeltas
Time spent adding position deltas to particles.
Definition: NvFlex.h:219
NvFlexDistanceFieldId field
A signed distance field pointer created by NvFlexCreateDistanceField()
Definition: NvFlex.h:890
float calculateDensity
Time spent calculating fluid density.
Definition: NvFlex.h:212
void * userData
Definition: NvFlex.h:289
A capsule shape, see FlexCapsuleGeometry.
Definition: NvFlex.h:910
NV_FLEX_API NvFlexTriangleMeshId NvFlexCreateTriangleMesh(NvFlexLibrary *lib)
NvFlexFeatureMode featureMode
Control which features are enabled.
Definition: NvFlex.h:366
NV_FLEX_API void NvFlexShutdown(NvFlexLibrary *lib)
NvFlexSolver * solver
Pointer to the solver that the callback is registered to.
Definition: NvFlex.h:269
If set this particle will generate fluid density constraints for its overlapping neighbors.
Definition: NvFlex.h:168
NvFlexFeatureMode
Definition: NvFlex.h:354
NvFlexPhase
Definition: NvFlex.h:160
NV_FLEX_API void NvFlexUnregisterD3DBuffer(NvFlexBuffer *buf)
bool useComputeQueue
If true, run Flex on a D3D12 compute queue, or vendor specific D3D11 compute queue. This allows compute and graphics to run in parallel on some GPUs.
Definition: NvFlex.h:322
float sleepThreshold
Particles with a velocity magnitude < this threshold will be considered fixed.
Definition: NvFlex.h:110
NV_FLEX_API int NvFlexGetVersion()
float anisotropyMax
Clamp the anisotropy scale to this fraction of the radius.
Definition: NvFlex.h:131
float collideTriangles
Time spent colliding triangle shapes.
Definition: NvFlex.h:210
NV_FLEX_API int NvFlexGetDetailTimers(NvFlexSolver *solver, NvFlexDetailTimer **timers)
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:920
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 int NvFlexMakePhaseWithChannels(int group, int particleFlags, int shapeChannels)
Definition: NvFlex.h:190
NV_FLEX_API int NvFlexMakePhase(int group, int particleFlags)
Definition: NvFlex.h:195
NV_FLEX_API void NvFlexSetActive(NvFlexSolver *solver, NvFlexBuffer *indices, const NvFlexCopyDesc *desc)
float shockPropagation
Artificially decrease the mass of particles based on height from a fixed reference point...
Definition: NvFlex.h:115
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:211
float calculateAnisotropy
Time spent calculating particle anisotropy for fluid.
Definition: NvFlex.h:220
Particle will collide with shapes with channel 6 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:177
NV_FLEX_API void NvFlexGetParticles(NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
void * renderContext
Direct3D context that the app is using for rendering. In DirectX 12 this should be a ID3D12CommandQue...
Definition: NvFlex.h:320
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:134
NV_FLEX_API void NvFlexSetNormals(NvFlexSolver *solver, NvFlexBuffer *normals, const NvFlexCopyDesc *desc)
NvFlexSDFGeometry sdf
Definition: NvFlex.h:904
float maxAcceleration
The magnitude of particle acceleration will be clamped to this value at the end of each step (limits ...
Definition: NvFlex.h:113
float wind[3]
Constant acceleration applied to particles that belong to dynamic triangles, drag needs to be > 0 for...
Definition: NvFlex.h:120
Particle will collide with shapes with channel 5 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:176
NV_FLEX_API NvFlexSolver * NvFlexCreateSolver(NvFlexLibrary *lib, const NvFlexSolverDesc *desc)
NV_FLEX_API void NvFlexUpdateDistanceField(NvFlexLibrary *lib, NvFlexDistanceFieldId sdf, int dimx, int dimy, int dimz, NvFlexBuffer *field)
Definition: NvFlex.h:201
float surfaceTension
Controls how strongly particles attempt to minimize surface area, default: 0.0, range: [0...
Definition: NvFlex.h:126
Particle will collide with shapes with channel 0 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:171
float dt
The per-update time-step, this is the value passed to NvFlexUpdateSolver()
Definition: NvFlex.h:278
float fluidRestDistance
The distance fluid particles are spaced at the rest density, must be in the range (0...
Definition: NvFlex.h:102
float reorder
Time spent reordering particles.
Definition: NvFlex.h:207
unsigned int NvFlexDistanceFieldId
Definition: NvFlex.h:723
A triangle mesh shape, see FlexTriangleMeshGeometry.
Definition: NvFlex.h:913
If set this particle will ignore collisions with particles closer than the radius in the rest pose...
Definition: NvFlex.h:167
NV_FLEX_API void NvFlexGetTimers(NvFlexSolver *solver, NvFlexTimers *timers)
NvFlexConvexMeshId mesh
Definition: NvFlex.h:871
NV_FLEX_API void NvFlexGetRigids(NvFlexSolver *solver, NvFlexBuffer *offsets, NvFlexBuffer *indices, NvFlexBuffer *restPositions, NvFlexBuffer *restNormals, NvFlexBuffer *stiffness, NvFlexBuffer *thresholds, NvFlexBuffer *creeps, NvFlexBuffer *rotations, NvFlexBuffer *translations)
NvFlexConvexMeshGeometry convexMesh
Definition: NvFlex.h:902
NvFlexSolverCallbackStage
Definition: NvFlex.h:244
float dissipation
Damps particle velocity based on how many particle contacts it has.
Definition: NvFlex.h:116
NvFlexCollisionShapeType
Definition: NvFlex.h:907
Used only in debug version of dll.
Definition: NvFlex.h:237
Use CUDA compute for Flex, the application must link against the CUDA libraries.
Definition: NvFlex.h:307
NV_FLEX_API void NvFlexUpdateConvexMesh(NvFlexLibrary *lib, NvFlexConvexMeshId convex, NvFlexBuffer *planes, int numPlanes, const float *lower, const float *upper)
NvFlexRelaxationMode relaxationMode
How the relaxation is applied inside the solver.
Definition: NvFlex.h:152
float lift
Lift force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in th...
Definition: NvFlex.h:122
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:319
A box shape, see FlexBoxGeometry.
Definition: NvFlex.h:911
float damping
Viscous drag force, applies a force proportional, and opposite to the particle velocity.
Definition: NvFlex.h:117
NV_FLEX_API void NvFlexSetDynamicTriangles(NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *normals, int numTris)
NvFlexCollisionShapeFlags
Definition: NvFlex.h:917
int numPlanes
Num collision planes.
Definition: NvFlex.h:150
NV_FLEX_API NvFlexBuffer * NvFlexAllocBuffer(NvFlexLibrary *lib, int elementCount, int elementByteStride, NvFlexBufferType type)
Definition: NvFlex.h:95
float collideShapes
Time spent colliding convex shapes.
Definition: NvFlex.h:209
float particleFriction
Coefficient of friction used when colliding particles.
Definition: NvFlex.h:107
NV_FLEX_API void NvFlexUpdateSolver(NvFlexSolver *solver, float dt, int substeps, bool enableTimers)
float createGrid
Time spent creating grid.
Definition: NvFlex.h:206
Bits [ 0, 19] represent the particle group for controlling collisions.
Definition: NvFlex.h:162
float buoyancy
Gravity is scaled by this value for fluid particles.
Definition: NvFlex.h:135
All log types.
Definition: NvFlex.h:238
NV_FLEX_API void NvFlexSetShapes(NvFlexSolver *solver, NvFlexBuffer *geometry, NvFlexBuffer *shapePositions, NvFlexBuffer *shapeRotations, NvFlexBuffer *shapePrevPositions, NvFlexBuffer *shapePrevRotations, NvFlexBuffer *shapeFlags, int numShapes)
Use DirectX 12 compute for Flex, the application must link against the D3D libraries.
Definition: NvFlex.h:309
float scale[3]
The scale of the object from local space to world space.
Definition: NvFlex.h:879
float solveDensities
Time spent solving density constraints.
Definition: NvFlex.h:213
NV_FLEX_API void NvFlexGetSmoothParticles(NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
NV_FLEX_API void NvFlexGetAnisotropy(NvFlexSolver *solver, NvFlexBuffer *q1, NvFlexBuffer *q2, NvFlexBuffer *q3, const NvFlexCopyDesc *desc)
NV_FLEX_API void NvFlexDestroyTriangleMesh(NvFlexLibrary *lib, NvFlexTriangleMeshId mesh)
float gravity[3]
Constant acceleration applied to all particles.
Definition: NvFlex.h:99
Called at the end of each constraint iteration.
Definition: NvFlex.h:247
Error messages.
Definition: NvFlex.h:234
NV_FLEX_API void NvFlexFreeBuffer(NvFlexBuffer *buf)
Bits [24, 31] hold flags representing what shape collision channels particles will collide with...
Definition: NvFlex.h:164
float solveInflatables
Time spent solving pressure constraints.
Definition: NvFlex.h:218
Called at the beginning of each substep after the prediction step has been completed.
Definition: NvFlex.h:248
Simple per-particle collision (no per-particle SDF normals, no fluids)
Definition: NvFlex.h:357
Definition: NvFlex.h:315
The relaxation factor is a fixed multiplier on each constraint's position delta.
Definition: NvFlex.h:87
NV_FLEX_API void NvFlexGetVelocities(NvFlexSolver *solver, NvFlexBuffer *v, const NvFlexCopyDesc *desc)
Definition: NvFlex.h:851
float total
Sum of all timers above.
Definition: NvFlex.h:226
void * userData
Pointer to the user data provided to NvFlexRegisterSolverCallback()
Definition: NvFlex.h:270
NV_FLEX_API void NvFlexGetDensities(NvFlexSolver *solver, NvFlexBuffer *densities, const NvFlexCopyDesc *desc)
float radius
Definition: NvFlex.h:853
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:938
NV_FLEX_API NvFlexBuffer * NvFlexRegisterOGLBuffer(NvFlexLibrary *lib, int buf, int elementCount, int elementByteStride)
Definition: NvFlex.h:1134
Particle will collide with shapes with channel 2 set (see NvFlexMakeShapeFlags()) ...
Definition: NvFlex.h:173
float relaxationFactor
Control the convergence rate of the parallel solver, default: 1, values greater than 1 may lead to in...
Definition: NvFlex.h:153
NV_FLEX_API void NvFlexSetSprings(NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *restLengths, NvFlexBuffer *stiffness, int numSprings)
float finalize
Time spent finalizing state.
Definition: NvFlex.h:224
const int * sortedToOriginalMap
Device pointer that maps the original particle index to the index in the callback data structure...
Definition: NvFlex.h:281
NvFlexComputeType
Definition: NvFlex.h:305
float dynamicFriction
Coefficient of friction used when colliding against shapes.
Definition: NvFlex.h:105
Definition: NvFlex.h:887
float scale[3]
Definition: NvFlex.h:870
Definition: NvFlex.h:286
float diffuseBuoyancy
Scales force opposing gravity that diffuse particles receive.
Definition: NvFlex.h:139
float updateBounds
Time spent updating particle bounds.
Definition: NvFlex.h:225
char * name
Definition: NvFlex.h:1136
float solidRestDistance
The distance non-fluid particles attempt to maintain from each other, must be in the range (0...
Definition: NvFlex.h:101
NV_FLEX_API void NvFlexSetSolverDescDefaults(NvFlexSolverDesc *desc)
float solidPressure
Add pressure from solid surfaces to particles.
Definition: NvFlex.h:133
float solveVelocities
Time spent solving velocity constraints.
Definition: NvFlex.h:214
Number of stages.
Definition: NvFlex.h:251
float restitution
Coefficient of restitution used when colliding against shapes, particle collisions are always inelast...
Definition: NvFlex.h:108
Definition: NvFlex.h:877
int numIterations
Number of solver iterations to perform per-substep.
Definition: NvFlex.h:97
NV_FLEX_API void NvFlexRestoreContext(NvFlexLibrary *lib)
NV_FLEX_API void NvFlexGetParams(NvFlexSolver *solver, NvFlexParams *params)
float anisotropyScale
Control how much anisotropy is present in resulting ellipsoids for rendering, if zero then anisotropy...
Definition: NvFlex.h:129
float vorticityConfinement
Increases vorticity by applying rotational forces to particles.
Definition: NvFlex.h:128
float diffuseLifetime
Time in seconds that a diffuse particle will live for after being spawned, particles will be spawned ...
Definition: NvFlex.h:142
float diffuseDrag
Scales force diffuse particles receive in direction of neighbor fluid particles.
Definition: NvFlex.h:140
NV_FLEX_API void NvFlexGetSolverDesc(NvFlexSolver *solver, NvFlexSolverDesc *desc)
float particleCollisionMargin
Increases the radius used during neighbor finding, this is useful if particles are expected to move s...
Definition: NvFlex.h:146
float diffuseThreshold
Particles with kinetic energy + divergence above this threshold will spawn new diffuse particles...
Definition: NvFlex.h:138
int elementCount
Definition: NvFlex.h:504
A device memory buffer, mapping this on CUDA will return a device memory pointer, and will return a b...
Definition: NvFlex.h:79
NV_FLEX_API void NvFlexGetSprings(NvFlexSolver *solver, NvFlexBuffer *indices, NvFlexBuffer *restLengths, NvFlexBuffer *stiffness, int numSprings)
NV_FLEX_API void NvFlexSetRestParticles(NvFlexSolver *solver, NvFlexBuffer *p, const NvFlexCopyDesc *desc)
NV_FLEX_API void NvFlexSetVelocities(NvFlexSolver *solver, NvFlexBuffer *v, const NvFlexCopyDesc *desc)
A convex mesh shape, see FlexConvexMeshGeometry.
Definition: NvFlex.h:912
float updateTriangles
Time spent updating dynamic triangles.
Definition: NvFlex.h:222
Definition: NvFlex.h:500
NvFlexBufferType
Definition: NvFlex.h:76
bool enableExtensions
Enable or disable NVIDIA/AMD extensions in DirectX, can lead to improved performance.
Definition: NvFlex.h:318
unsigned int NvFlexConvexMeshId
Definition: NvFlex.h:730