MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/FleX / CreateLinks

Function CreateLinks

extensions/flexExtSoft.cpp:276–306  ·  view source on GitHub ↗

creates distance constraints between particles within some radius

Source from the content-addressed store, hash-verified

274
275// creates distance constraints between particles within some radius
276int CreateLinks(const Vec3* particles, int numParticles, std::vector<int>& outSpringIndices, std::vector<float>& outSpringLengths, std::vector<float>& outSpringStiffness, float radius, float stiffness = 1.0f)
277{
278 int count = 0;
279
280 std::vector<int> neighbors;
281 SweepAndPrune sap(particles, numParticles);
282
283 for (int i = 0; i < numParticles; ++i)
284 {
285 neighbors.resize(0);
286
287 sap.QuerySphere(Vec3(particles[i]), radius, neighbors);
288
289 for (int j = 0; j < int(neighbors.size()); ++j)
290 {
291 const int nj = neighbors[j];
292
293 if (nj != i)
294 {
295 outSpringIndices.push_back(i);
296 outSpringIndices.push_back(nj);
297 outSpringLengths.push_back(Length(Vec3(particles[i]) - Vec3(particles[nj])));
298 outSpringStiffness.push_back(stiffness);
299
300 ++count;
301 }
302 }
303 }
304
305 return count;
306}
307
308void CreateSkinning(const Vec3* vertices, int numVertices, const Vec3* clusters, int numClusters, float* outWeights, int* outIndices, float falloff, float maxdist)
309{

Callers 1

Calls 4

resizeMethod · 0.80
QuerySphereMethod · 0.80
sizeMethod · 0.80
push_backMethod · 0.80

Tested by

no test coverage detected