soft tetrahedrons

feature/softbody-runtime-control
Benjamin Kraft 4 months ago
parent c67d33c25e
commit 8b239ddf33
  1. 12
      src/soft_body.cpp

@ -183,26 +183,26 @@ void SoftBody::splitConstraints() {
Graph graph; Graph graph;
auto setNeighbors = [&pointToConstraints, &graph](const Constraint * constraint, const vector<uint32_t> &vIDs){ auto findAdjacent = [&pointToConstraints, &graph](const Constraint * constraint, const vector<uint32_t> &vIDs){
unordered_set<const Constraint *> neighbors; unordered_set<const Constraint *> neighbors;
for (uint32_t vID : vIDs) for (uint32_t vID : vIDs)
neighbors.insert(pointToConstraints[vID].begin(), pointToConstraints[vID].end()); neighbors.insert(pointToConstraints[vID].begin(), pointToConstraints[vID].end());
neighbors.erase(constraint); neighbors.erase(constraint);
#pragma omp critical #pragma omp critical
graph[constraint].insert(graph[constraint].end(), neighbors.begin(), neighbors.end()); graph[constraint].assign(neighbors.begin(), neighbors.end());
}; };
#pragma omp parallel for default(none) shared(setNeighbors, lengthConstraints) #pragma omp parallel for default(none) shared(findAdjacent, lengthConstraints)
for (const DistanceConstraint &distanceConstraint : lengthConstraints){ for (const DistanceConstraint &distanceConstraint : lengthConstraints){
setNeighbors(&distanceConstraint, { findAdjacent(&distanceConstraint, {
distanceConstraint.a, distanceConstraint.a,
distanceConstraint.b distanceConstraint.b
}); });
} }
#pragma omp parallel for default(none) shared(setNeighbors, volumeConstraints) #pragma omp parallel for default(none) shared(findAdjacent, volumeConstraints)
for (const VolumeConstraint &volumeConstraint : volumeConstraints){ for (const VolumeConstraint &volumeConstraint : volumeConstraints){
setNeighbors(&volumeConstraint, { findAdjacent(&volumeConstraint, {
volumeConstraint.a, volumeConstraint.a,
volumeConstraint.b, volumeConstraint.b,
volumeConstraint.c, volumeConstraint.c,

Loading…
Cancel
Save