bevy_xpbd
bevy_xpbd copied to clipboard
`RayCaster.ignore_self` doesn't ignore colliders in children
trafficstars
In general, all colliders in children of a rigidbody do contribute to the rigidbody in the parent entity.
Therefore, it would seem sensible to me that RayCaster.ignore_self would have a consistent behaviour, also ignoring all children colliders, not just the entity itself. Or at least offer an analogous alternative, maybe RayCaster.ignore_children. What do you think? I might be able to contribute this.
Current workaround is to manually filter the hits:
let hits = hits.iter().filter(|&hit| is_child_of(hit.entity, rigidbody_parent_entity, &parents));
fn is_child_of(child: Entity, maybe_parent: Entity, parents: Query<&Parent>) -> bool {
parents.iter_ancestors(child).find(|&parent| parent == maybe_parent).is_some()
}
Note that the proposed API should probably be called ignore_descendants to mirror how iter_descendants works in Bevy.