Skip to content

Commit 86f3c48

Browse files
authored
Fix removing colliders from contact graph EntityDataIndex (#688)
# Objective When a collider is removed from the contact graph, the `EntityDataIndex` used for mapping entities to graph nodes is not updated. This can cause bugs and even crashes when an entity with the same index is removed and later added back to the graph. ## Solution Remove colliders from the `EntityDataIndex` in `ContactGraph::remove_collider_with`.
1 parent 58a3662 commit 86f3c48

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/collision/contact_types/contact_graph.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,9 @@ impl ContactGraph {
377377
where
378378
F: FnMut(ContactPair),
379379
{
380-
let Some(&index) = self.entity_graph_index.get(entity) else {
380+
// Remove the entity from the entity graph index,
381+
// and get the index of the node in the graph.
382+
let Some(index) = self.entity_graph_index.remove(entity, NodeIndex::END) else {
381383
return;
382384
};
383385

0 commit comments

Comments
 (0)