Consider simplifying scene query filter?
- Dominant language
- Rust
- Stars
- 5.7k
- Forks
- 387
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 6
Description
Currently, according to document https://rapier.rs/docs/user_guides/javascript/scene_queries#query-filters , the `groups` param obey the universal collider-collider collision grouping rule:
1. the "group bits" should have **membership bits** indicate "what group it belongs to"
2. the "group bits" should have filter bits indicate "what group it can collide with"
However, in my opinion, in the subject of dynamic scene query, **the scene query filter group bits should only express what colliders should be tested for intersection**.
Since the common case is the caller want to intersect/cast a **WILD** shape with colliders having some characteristics in scene. The intersection/casting should only care about what colliders you want to test instead of which group your input WILD shape belongs, right?
For example, the idea usage is:
```js
const tag = {
player: 1 << 0,
building: 1 << 1,
};
world.intersectShape(
shapePos, // intersect
rapier.Ball(1.0), // the ball with colliders in world,
0, // including all colliders
tag.player | tag.building, // limit those colliders to players and buildings
undefined,
undefined,
(collider) => {},
);
```
However, I have to add a temp "tag" to simulate the "membership" of the WILD shape:
```diff
const tag = {
player: 1 << 0,
building: 1 << 1,
++ scene_query_input: 1 << 2, // add a tag, used for intersection test
};
world.intersectShape(
shapePos, // intersect
rapier.Ball(1.0), // the ball with colliders in world,
0, // including all colliders
-- tag.player | tag.building, // limit those colliders to players and buildings
++ (tag.scene_query_input << 16) | (tag.player | tag.building),
undefined,
undefined,
(collider) => {},
);
```
Contributor guide
Assessment
This issue has not been assessed yet.