aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics/solver/interaction_groups.rs
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-02-03 16:33:08 +0100
committerCrozet Sébastien <developer@crozet.re>2021-02-03 18:16:50 +0100
commitcf77d17d9e6c425b1899c03db8e07f265259791b (patch)
tree691e13cae7006b769be55a83d4f53d251e24be82 /src/dynamics/solver/interaction_groups.rs
parent16ba01be16fbf86cf51dab4eea30ae49b7cbea0d (diff)
downloadrapier-cf77d17d9e6c425b1899c03db8e07f265259791b.tar.gz
rapier-cf77d17d9e6c425b1899c03db8e07f265259791b.tar.bz2
rapier-cf77d17d9e6c425b1899c03db8e07f265259791b.zip
Experiment with incremental island computation.
Diffstat (limited to 'src/dynamics/solver/interaction_groups.rs')
-rw-r--r--src/dynamics/solver/interaction_groups.rs31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/dynamics/solver/interaction_groups.rs b/src/dynamics/solver/interaction_groups.rs
index 21cc642..fef7565 100644
--- a/src/dynamics/solver/interaction_groups.rs
+++ b/src/dynamics/solver/interaction_groups.rs
@@ -1,4 +1,4 @@
-use crate::dynamics::{BodyPair, JointGraphEdge, JointIndex, RigidBodySet};
+use crate::dynamics::{BodyPair, IslandSet, JointGraphEdge, JointIndex, RigidBodySet};
use crate::geometry::{ContactManifold, ContactManifoldIndex};
#[cfg(feature = "simd-is-enabled")]
use {
@@ -83,24 +83,23 @@ impl ParallelInteractionGroups {
match (rb1.is_static(), rb2.is_static()) {
(false, false) => {
- let color_mask =
- bcolors[rb1.active_set_offset] | bcolors[rb2.active_set_offset];
+ let color_mask = bcolors[rb1.island_offset] | bcolors[rb2.island_offset];
*color = (!color_mask).trailing_zeros() as usize;
color_len[*color] += 1;
- bcolors[rb1.active_set_offset] |= 1 << *color;
- bcolors[rb2.active_set_offset] |= 1 << *color;
+ bcolors[rb1.island_offset] |= 1 << *color;
+ bcolors[rb2.island_offset] |= 1 << *color;
}
(true, false) => {
- let color_mask = bcolors[rb2.active_set_offset];
+ let color_mask = bcolors[rb2.island_offset];
*color = (!color_mask).trailing_zeros() as usize;
color_len[*color] += 1;
- bcolors[rb2.active_set_offset] |= 1 << *color;
+ bcolors[rb2.island_offset] |= 1 << *color;
}
(false, true) => {
- let color_mask = bcolors[rb1.active_set_offset];
+ let color_mask = bcolors[rb1.island_offset];
*color = (!color_mask).trailing_zeros() as usize;
color_len[*color] += 1;
- bcolors[rb1.active_set_offset] |= 1 << *color;
+ bcolors[rb1.island_offset] |= 1 << *color;
}
(true, true) => unreachable!(),
}
@@ -176,6 +175,7 @@ impl InteractionGroups {
pub fn group_joints(
&mut self,
island_id: usize,
+ islands: &IslandSet,
bodies: &RigidBodySet,
interactions: &[JointGraphEdge],
interaction_indices: &[JointIndex],
@@ -197,7 +197,7 @@ impl InteractionGroups {
// is full, we don't clear the corresponding body mask bit. This may result
// in less grouped constraints.
self.body_masks
- .resize(bodies.active_island(island_id).len(), 0u128);
+ .resize(islands.active_island(island_id).len(), 0u128);
// NOTE: each bit of the occupied mask indicates what bucket already
// contains at least one constraint.
@@ -215,8 +215,8 @@ impl InteractionGroups {
}
let ijoint = interaction.params.type_id();
- let i1 = body1.active_set_offset;
- let i2 = body2.active_set_offset;
+ let i1 = body1.island_offset;
+ let i2 = body2.island_offset;
let conflicts =
self.body_masks[i1] | self.body_masks[i2] | joint_type_conflicts[ijoint];
let conflictfree_targets = !(conflicts & occupied_mask); // The & is because we consider empty buckets as free of conflicts.
@@ -320,6 +320,7 @@ impl InteractionGroups {
pub fn group_manifolds(
&mut self,
island_id: usize,
+ islands: &IslandSet,
bodies: &RigidBodySet,
interactions: &[&mut ContactManifold],
interaction_indices: &[ContactManifoldIndex],
@@ -331,7 +332,7 @@ impl InteractionGroups {
// in less grouped contacts.
// NOTE: body_masks and buckets are already cleared/zeroed at the end of each sort loop.
self.body_masks
- .resize(bodies.active_island(island_id).len(), 0u128);
+ .resize(islands.active_island(island_id).len(), 0u128);
// NOTE: each bit of the occupied mask indicates what bucket already
// contains at least one constraint.
@@ -365,8 +366,8 @@ impl InteractionGroups {
continue;
}
- let i1 = body1.active_set_offset;
- let i2 = body2.active_set_offset;
+ let i1 = body1.island_offset;
+ let i2 = body2.island_offset;
let conflicts = self.body_masks[i1] | self.body_masks[i2];
let conflictfree_targets = !(conflicts & occupied_mask); // The & is because we consider empty buckets as free of conflicts.
let conflictfree_occupied_targets = conflictfree_targets & occupied_mask;