creates distance constraints between particles within some radius
| 274 | |
| 275 | // creates distance constraints between particles within some radius |
| 276 | int 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 | |
| 308 | void CreateSkinning(const Vec3* vertices, int numVertices, const Vec3* clusters, int numClusters, float* outWeights, int* outIndices, float falloff, float maxdist) |
| 309 | { |
no test coverage detected