106 mappedPtr = (T*)
NvFlexMap(buffer, flags);
123 assert(index < count);
125 return mappedPtr[index];
131 assert(index < count);
133 return mappedPtr[index];
138 assert(mappedPtr || !buffer);
143 mappedPtr[count++] = t;
146 void assign(
const T* srcPtr,
int newCount)
148 assert(mappedPtr || !buffer);
152 memcpy(mappedPtr, srcPtr, newCount*
sizeof(T));
159 memcpy(dest, mappedPtr,
sizeof(T)*count);
171 return mappedPtr[count-1];
176 if (minCapacity > capacity)
179 const int newCapacity = minCapacity*3/2;
185 memcpy(newPtr, mappedPtr, count*
sizeof(T));
195 mappedPtr = (T*)newPtr;
196 capacity = newCapacity;
203 assert(mappedPtr || !buffer);
213 assert(mappedPtr || !buffer);
215 const int startInit =
count;
216 const int endInit = newCount;
221 for (
int i=startInit; i < endInit; ++i)
400 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);
501 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,
float clusterPlasticThreshold,
float clusterPlasticCreep);
521 NV_FLEX_API
void NvFlexExtCreateSoftMeshSkinning(
const float* vertices,
int numVertices,
const float* bones,
int numBones,
float falloff,
float maxDistance,
float* skinningWeights,
int* skinningIndices);
774 #endif // NV_FLEX_EXT_H
bool mLinearFalloff
Linear or no falloff.
Definition: NvFlexExt.h:736
void destroy()
Definition: NvFlexExt.h:86
NvFlexBufferType type
Definition: NvFlexExt.h:76
int numParticles
Number of particles.
Definition: NvFlexExt.h:315
float * shapeCenters
The position of the center of mass of each shape, an array of vec3s mNumShapes in length...
Definition: NvFlexExt.h:329
NV_FLEX_API void NvFlexExtSetForceFields(NvFlexExtForceFieldCallback *callback, const NvFlexExtForceField *forceFields, int numForceFields)
NV_FLEX_API void NvFlexExtMovingFrameApply(NvFlexExtMovingFrame *frame, float *positions, float *velocities, int numParticles, float linearScale, float angularScale, float dt)
float * shapeRotations
Shape matching group rotations (quaternions)
Definition: NvFlexExt.h:360
NvFlexVector(NvFlexLibrary *l, const T *ptr, int size, NvFlexBufferType type=eNvFlexBufferHost)
Definition: NvFlexExt.h:58
int n
Number of valid tranforms.
Definition: NvFlexExt.h:612
NvFlexLibrary * lib
Definition: NvFlexExt.h:70
float * particles
Local space particle positions, x,y,z,1/mass.
Definition: NvFlexExt.h:314
int * shapeOffsets
Each entry stores the end of the shape's indices in the indices array (exclusive prefix sum of shape ...
Definition: NvFlexExt.h:327
int newParticleIndex
Definition: NvFlexExt.h:449
NV_FLEX_API void NvFlexUnmap(NvFlexBuffer *buffer)
NV_FLEX_API void NvFlexExtDestroyInstance(NvFlexExtContainer *container, const NvFlexExtInstance *instance)
NV_FLEX_API void NvFlexExtMovingFrameUpdate(NvFlexExtMovingFrame *frame, const float *worldTranslation, const float *worldRotation, float dt)
void init(int size)
Definition: NvFlexExt.h:79
NV_FLEX_API NvFlexExtAsset * NvFlexExtCreateRigidFromMesh(const float *vertices, int numVertices, const int *indices, int numTriangleIndices, float radius, float expand)
float * springRestLengths
Spring rest-lengths.
Definition: NvFlexExt.h:321
int size() const
Definition: NvFlexExt.h:162
NV_FLEX_API void NvFlexExtTickContainer(NvFlexExtContainer *container, float dt, int numSubsteps, bool enableTimers=false)
Definition: NvFlexExt.h:569
int numParticles
Number of simulation particles.
Definition: NvFlexExt.h:353
NV_FLEX_API void NvFlexExtUnmapParticleData(NvFlexExtContainer *container)
struct NvFlexExtContainer NvFlexExtContainer
Definition: NvFlexExt.h:370
T & operator[](int index)
Definition: NvFlexExt.h:128
void * userData
User data pointer.
Definition: NvFlexExt.h:364
NV_FLEX_API void NvFlexExtPullFromDevice(NvFlexExtContainer *container)
void resize(int newCount, const T &val)
Definition: NvFlexExt.h:211
int * triangleIndices
Indexed triangle mesh indices for clothing.
Definition: NvFlexExt.h:337
int capacity
Definition: NvFlexExt.h:75
int * particleIndices
Simulation particle indices.
Definition: NvFlexExt.h:352
float mRadius
Radius of the force field.
Definition: NvFlexExt.h:733
int numTriangles
Number of triangles.
Definition: NvFlexExt.h:338
Calling thread will be blocked until buffer is ready for access, default.
Definition: NvFlex.h:69
struct NvFlexSolver NvFlexSolver
Definition: NvFlex.h:57
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)
Definition: NvFlexExt.h:730
int numShapeIndices
Total number of indices for shape constraints.
Definition: NvFlexExt.h:326
NV_FLEX_API void NvFlexExtDestroyTearingCloth(NvFlexExtAsset *asset)
float * rotations
Receives a pointer to the array quaternion rotation data in [x, y z, w] format.
Definition: NvFlexExt.h:610
NV_FLEX_API int NvFlexExtGetActiveList(NvFlexExtContainer *container, int *indices)
int shapeIndex
Index in the container's shape body constraints array.
Definition: NvFlexExt.h:356
Definition: NvFlexExt.h:45
NV_FLEX_API void NvFlexExtDestroyForceFieldCallback(NvFlexExtForceFieldCallback *callback)
NV_FLEX_API void * NvFlexMap(NvFlexBuffer *buffer, int flags)
NvFlexVector(NvFlexLibrary *l, int size=0, NvFlexBufferType type=eNvFlexBufferHost)
Definition: NvFlexExt.h:47
int * springIndices
Spring indices.
Definition: NvFlexExt.h:319
void reserve(int minCapacity)
Definition: NvFlexExt.h:174
~NvFlexVector()
Definition: NvFlexExt.h:65
int maxParticles
Maximum number of particles, allows extra space for tearable assets which duplicate particles...
Definition: NvFlexExt.h:316
void push_back(const T &t)
Definition: NvFlexExt.h:136
NV_FLEX_API void NvFlexExtDestroyContainer(NvFlexExtContainer *container)
float tau[3]
Definition: NvFlexExt.h:240
float omega[3]
Definition: NvFlexExt.h:237
NV_FLEX_API void NvFlexExtCreateSoftMeshSkinning(const float *vertices, int numVertices, const float *bones, int numBones, float falloff, float maxDistance, float *skinningWeights, int *skinningIndices)
bool empty() const
Definition: NvFlexExt.h:164
Definition: NvFlexExt.h:446
NV_FLEX_API NvFlexExtContainer * NvFlexExtCreateContainer(NvFlexLibrary *lib, NvFlexSolver *solver, int maxParticles)
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)
float rotation[4]
Definition: NvFlexExt.h:234
float inflatableVolume
The rest volume for the inflatable constraint.
Definition: NvFlexExt.h:342
A host mappable buffer, pinned memory on CUDA, staging buffer on DX.
Definition: NvFlex.h:78
NV_FLEX_API void NvFlexExtUnmapShapeData(NvFlexExtContainer *container)
struct NvFlexBuffer NvFlexBuffer
Definition: NvFlex.h:62
NV_FLEX_API NvFlexExtShapeData NvFlexExtMapShapeData(NvFlexExtContainer *container)
Apply field value as an impulse.
Definition: NvFlexExt.h:721
float * particles
Receives a pointer to the particle position / mass data.
Definition: NvFlexExt.h:571
float * springCoefficients
Spring coefficients.
Definition: NvFlexExt.h:320
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, float clusterPlasticThreshold, float clusterPlasticCreep)
float * restParticles
Receives a pointer to the particle's rest position (used for self collision culling) ...
Definition: NvFlexExt.h:572
float * positions
Receives a pointer to an array of shape body translations in [x, y, z] format.
Definition: NvFlexExt.h:611
Definition: NvFlexExt.h:231
const T & operator[](int index) const
Definition: NvFlexExt.h:120
void unmap()
Definition: NvFlexExt.h:109
Definition: NvFlexExt.h:350
NV_FLEX_API void NvFlexExtUpdateInstances(NvFlexExtContainer *container)
float mPosition[3]
Center of force field.
Definition: NvFlexExt.h:732
int * indices
Receives a pointer to the array of triangle index data.
Definition: NvFlexExt.h:592
float * normals
Receives a pointer to an array of triangle normal data stored with 16 byte stride, i.e.: [nx, ny, nz].
Definition: NvFlexExt.h:593
NV_FLEX_API void NvFlexExtTearClothMesh(NvFlexExtAsset *asset, float maxStrain, int maxSplits, NvFlexExtTearingParticleClone *particleCopies, int *numParticleCopies, int maxCopies, NvFlexExtTearingMeshEdit *triangleEdits, int *numTriangleEdits, int maxEdits)
float acceleration[3]
Definition: NvFlexExt.h:239
Apply field value as a force.
Definition: NvFlexExt.h:718
float inflatableStiffness
How stiff the inflatable is.
Definition: NvFlexExt.h:344
struct NvFlexLibrary NvFlexLibrary
Definition: NvFlex.h:52
int triIndex
Definition: NvFlexExt.h:448
float * normals
Receives a pointer to the particle normal data with 16 byte stride in format [nx, ny...
Definition: NvFlexExt.h:575
NV_FLEX_API NvFlexExtTriangleData NvFlexExtMapTriangleData(NvFlexExtContainer *container)
int destIndex
Definition: NvFlexExt.h:436
float mStrength
Strength of the force field.
Definition: NvFlexExt.h:734
float position[3]
Definition: NvFlexExt.h:233
void resize(int newCount)
Definition: NvFlexExt.h:201
Definition: NvFlexExt.h:311
NV_FLEX_API void NvFlexExtPushToDevice(NvFlexExtContainer *container)
struct NvFlexExtForceFieldCallback NvFlexExtForceFieldCallback
Definition: NvFlexExt.h:743
int count
Definition: NvFlexExt.h:74
NvFlexExtForceMode
Definition: NvFlexExt.h:715
float * shapeCoefficients
The stiffness coefficient for each shape.
Definition: NvFlexExt.h:328
void map(int flags=eNvFlexMapWait)
Definition: NvFlexExt.h:100
Apply field value as a velocity change.
Definition: NvFlexExt.h:724
NV_FLEX_API NvFlexExtAsset * NvFlexExtCreateTearingClothFromMesh(const float *particles, int numParticles, int maxParticles, const int *indices, int numTriangles, float stretchStiffness, float bendStiffness, float pressure)
Definition: NvFlexExt.h:608
NV_FLEX_API void NvFlexExtMovingFrameInit(NvFlexExtMovingFrame *frame, const float *worldTranslation, const float *worldRotation)
float inflatablePressure
How much over the rest volume the inflatable should attempt to maintain.
Definition: NvFlexExt.h:343
const float * upper
Receive a pointer to the particle upper bounds [x, y, z].
Definition: NvFlexExt.h:578
NV_FLEX_API NvFlexBuffer * NvFlexAllocBuffer(NvFlexLibrary *lib, int elementCount, int elementByteStride, NvFlexBufferType type)
int inflatableIndex
Index in the container's inflatables array.
Definition: NvFlexExt.h:357
NV_FLEX_API void NvFlexExtFreeParticles(NvFlexExtContainer *container, int n, const int *indices)
int * shapeIndices
The indices of the shape matching constraints.
Definition: NvFlexExt.h:325
NV_FLEX_API int NvFlexExtCreateWeldedMeshIndices(const float *vertices, int numVertices, int *uniqueVerts, int *originalToUniqueMap, float threshold)
NV_FLEX_API NvFlexExtParticleData NvFlexExtMapParticleData(NvFlexExtContainer *container)
void assign(const T *srcPtr, int newCount)
Definition: NvFlexExt.h:146
float * shapePlasticThresholds
The plastic threshold coefficient for each shape.
Definition: NvFlexExt.h:333
const NvFlexExtAsset * asset
Source asset used to create this instance.
Definition: NvFlexExt.h:362
T * mappedPtr
Definition: NvFlexExt.h:73
float delta[4][4]
Definition: NvFlexExt.h:242
const float * lower
Receive a pointer to the particle lower bounds [x, y, z].
Definition: NvFlexExt.h:577
int triangleIndex
Index in the container's triangle array.
Definition: NvFlexExt.h:355
Definition: NvFlexExt.h:590
NvFlexExtForceMode mMode
Mode of field application.
Definition: NvFlexExt.h:735
NV_FLEX_API int NvFlexExtAllocParticles(NvFlexExtContainer *container, int n, int *indices)
int * phases
Receives a pointer to the particle phase data.
Definition: NvFlexExt.h:574
NV_FLEX_API void NvFlexFreeBuffer(NvFlexBuffer *buf)
int numShapes
The number of shape matching constraints.
Definition: NvFlexExt.h:330
NV_FLEX_API void NvFlexExtUnmapTriangleData(NvFlexExtContainer *container)
void copyto(T *dest, int count)
Definition: NvFlexExt.h:155
NV_FLEX_API void NvFlexExtDestroyAsset(NvFlexExtAsset *asset)
float * shapePlasticCreeps
The plastic creep coefficient for each shape.
Definition: NvFlexExt.h:334
int srcIndex
Definition: NvFlexExt.h:435
float * shapeTranslations
Shape matching group translations (vec3s)
Definition: NvFlexExt.h:359
float velocity[3]
Definition: NvFlexExt.h:236
Definition: NvFlexExt.h:433
NvFlexBuffer * buffer
Definition: NvFlexExt.h:71
float * velocities
Receives a pointer to the particle velocity data.
Definition: NvFlexExt.h:573
const T & back() const
Definition: NvFlexExt.h:166
NV_FLEX_API NvFlexExtForceFieldCallback * NvFlexExtCreateForceFieldCallback(NvFlexSolver *solver)
bool inflatable
Whether an inflatable constraint should be added.
Definition: NvFlexExt.h:341
int numSprings
Number of springs.
Definition: NvFlexExt.h:322
NV_FLEX_API void NvFlexExtNotifyAssetChanged(NvFlexExtContainer *container, const NvFlexExtAsset *asset)
NvFlexBufferType
Definition: NvFlex.h:76