@@ -37,7 +37,7 @@ impl IslandManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn num_islands(&self) -> usize {
|
pub(crate) fn num_islands(&self) -> usize {
|
||||||
self.active_islands.len() - 1
|
self.active_islands.len().saturating_sub(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update this data-structure after one or multiple rigid-bodies have been removed for `bodies`.
|
/// Update this data-structure after one or multiple rigid-bodies have been removed for `bodies`.
|
||||||
@@ -244,8 +244,8 @@ impl IslandManager {
|
|||||||
self.active_islands.clear();
|
self.active_islands.clear();
|
||||||
self.active_islands.push(0);
|
self.active_islands.push(0);
|
||||||
|
|
||||||
// The max avoid underflow when the stack is empty.
|
// saturating_sub(1) prevents underflow when the stack is empty.
|
||||||
let mut island_marker = self.stack.len().max(1) - 1;
|
let mut island_marker = self.stack.len().saturating_sub(1);
|
||||||
|
|
||||||
// NOTE: islands containing a body with non-standard number of iterations won’t
|
// NOTE: islands containing a body with non-standard number of iterations won’t
|
||||||
// be merged with another island, unless another island with standard
|
// be merged with another island, unless another island with standard
|
||||||
|
|||||||
@@ -58,8 +58,9 @@ impl ParallelInteractionGroups {
|
|||||||
let range = self.groups[i]..self.groups[i + 1];
|
let range = self.groups[i]..self.groups[i + 1];
|
||||||
&self.sorted_interactions[range]
|
&self.sorted_interactions[range]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn num_groups(&self) -> usize {
|
pub fn num_groups(&self) -> usize {
|
||||||
self.groups.len() - 1
|
self.groups.len().saturating_sub(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn group_interactions<Interaction: PairInteraction>(
|
pub fn group_interactions<Interaction: PairInteraction>(
|
||||||
|
|||||||
Reference in New Issue
Block a user