diff options
| author | Crozet Sébastien <developer@crozet.re> | 2020-11-24 14:57:37 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2020-11-24 14:57:37 +0100 |
| commit | dc63c28f56c989ec97cb416d186cf76a1e61c555 (patch) | |
| tree | e6f29b9c8582775e658205feccf8d2d8d8e098ff /src/geometry | |
| parent | af39ec54d35b8c3777add6b6a597e5963067234d (diff) | |
| download | rapier-dc63c28f56c989ec97cb416d186cf76a1e61c555.tar.gz rapier-dc63c28f56c989ec97cb416d186cf76a1e61c555.tar.bz2 rapier-dc63c28f56c989ec97cb416d186cf76a1e61c555.zip | |
Fix crash when removing a collider with no graph ID.
Diffstat (limited to 'src/geometry')
| -rw-r--r-- | src/geometry/narrow_phase.rs | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs index 30c1f8c..cf7b531 100644 --- a/src/geometry/narrow_phase.rs +++ b/src/geometry/narrow_phase.rs @@ -137,25 +137,27 @@ impl NarrowPhase { let mut i = 0; while let Some(collider) = colliders.removed_colliders.read_ith(&cursor, i) { - let graph_idx = self.graph_indices.get(collider.handle).unwrap(); - - let proximity_graph_id = prox_id_remap - .get(&collider.handle) - .copied() - .unwrap_or(graph_idx.proximity_graph_index); - let contact_graph_id = contact_id_remap - .get(&collider.handle) - .copied() - .unwrap_or(graph_idx.contact_graph_index); - - self.remove_collider( - proximity_graph_id, - contact_graph_id, - colliders, - bodies, - &mut prox_id_remap, - &mut contact_id_remap, - ); + // NOTE: if the collider does not have any graph indices currently, there is nothing + // to remove in the narrow-phase for this collider. + if let Some(graph_idx) = self.graph_indices.get(collider.handle) { + let proximity_graph_id = prox_id_remap + .get(&collider.handle) + .copied() + .unwrap_or(graph_idx.proximity_graph_index); + let contact_graph_id = contact_id_remap + .get(&collider.handle) + .copied() + .unwrap_or(graph_idx.contact_graph_index); + + self.remove_collider( + proximity_graph_id, + contact_graph_id, + colliders, + bodies, + &mut prox_id_remap, + &mut contact_id_remap, + ); + } i += 1; } |
