Skip to content

Fix contact pair removal bugs#693

Merged
Jondolf merged 6 commits into
mainfrom
fix-contact-pair-removal
Apr 12, 2025
Merged

Fix contact pair removal bugs#693
Jondolf merged 6 commits into
mainfrom
fix-contact-pair-removal

Conversation

@Jondolf

@Jondolf Jondolf commented Apr 12, 2025

Copy link
Copy Markdown
Member

Objective

Contact pair removal currently has some issues.

  1. Contact pair removal is done using the EdgeIndex directly, but removing an edge can move the indices around (due to swap_remove), which can sometimes result in incorrect pair removal if many pairs are removed at once.
  2. Changing CollisionLayers doesn't update existing contact pairs.
  3. When a collider is removed or disabled, CollisionEnded is sent even for non-touching contact pairs.

Solution

Fix the things!

For problem 2, I just made the narrow phase always check if the CollisionLayers match for now. Ideally, we'd handle this with fine-grained change detection instead.

CollisionLayers is now also a required component for colliders. This avoids extra branching and is perhaps more semantically accurate; colliders can only belong to collision layers if they have the component for it.


Migration Guide

CollisionLayers is now a required component for colliders.

@Jondolf Jondolf added C-Bug Something isn't working A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality labels Apr 12, 2025
@Jondolf Jondolf added this to the 0.3 milestone Apr 12, 2025
@Jondolf Jondolf added the M-Migration-Guide A breaking change to Avian's public API that needs to be noted in a migration guide label Apr 12, 2025
@Jondolf Jondolf merged commit d0f0383 into main Apr 12, 2025
@Jondolf Jondolf deleted the fix-contact-pair-removal branch April 12, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality C-Bug Something isn't working M-Migration-Guide A breaking change to Avian's public API that needs to be noted in a migration guide

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant