Skip to content

Commit

Permalink
Fix collisions not being cleared for immediately despawned entities (#…
Browse files Browse the repository at this point in the history
…642)

# Objective

Fixes #533

There is currently a bug where despawning an entity as soon as a collision starts never ends up removing the collision, meaning that `CollisionEnded` is not sent and the despawned entity is not removed from `CollidingEntities`. This is caused by collision states not being updated correctly for despawns.

## Solution

Reset the collision states when an entity is missing such that the collision will be treated as ended.

Note that the way this is handled will change substantially when we implement a contact graph and rework contact management, but regardless, I think it is important to have a fix for it now as it is a serious bug.
  • Loading branch information
Jondolf authored Jan 26, 2025
1 parent b4dd833 commit fa9b898
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/collision/narrow_phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,8 @@ pub fn reset_collision_states(
contacts.during_current_frame = true;
}
} else {
// One of the entities does not exist, so the collision has ended.
contacts.during_previous_frame = true;
contacts.during_current_frame = false;
}
}
Expand Down

0 comments on commit fa9b898

Please sign in to comment.