Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RayCaster.ignore_self doesn't ignore colliders in children #473

Open
johannesvollmer opened this issue Jul 28, 2024 · 1 comment
Open

RayCaster.ignore_self doesn't ignore colliders in children #473

johannesvollmer opened this issue Jul 28, 2024 · 1 comment
Labels
A-Spatial-Query Relates to spatial queries, such as ray casting, shape casting, and intersection tests C-Enhancement New feature or request

Comments

@johannesvollmer
Copy link

johannesvollmer commented Jul 28, 2024

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()
}
@janhohenheim
Copy link
Contributor

Note that the proposed API should probably be called ignore_descendants to mirror how iter_descendants works in Bevy.

@Jondolf Jondolf added C-Enhancement New feature or request A-Spatial-Query Relates to spatial queries, such as ray casting, shape casting, and intersection tests labels Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Spatial-Query Relates to spatial queries, such as ray casting, shape casting, and intersection tests C-Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants