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

Add Collision Layers and Masks. #2

Closed
kakoeimon opened this issue Aug 27, 2020 · 3 comments · Fixed by #43
Closed

Add Collision Layers and Masks. #2

kakoeimon opened this issue Aug 27, 2020 · 3 comments · Fixed by #43
Labels
C-Enhancement New feature or request

Comments

@kakoeimon
Copy link

Right now all the colliders collide with each other, there is no way to tell which colliders can collide.
One way to do this are collision layers and masks.

A collision layer is where the given collider leaves and the mask is which layers can the collider collide.
Layer and mask are just a 32 bit integer and this makes the comparisson very fast.
Godot Game engine uses this technic
An example of setting individual bits can been seen here :
https://github.com/godotengine/godot/blob/00949f0c5fcc6a4f8382a4a97d5591fd9ec380f8/scene/2d/area_2d.cpp#L483

And the comparison here:
https://github.com/godotengine/godot/blob/8e8699e36b81f04fb7acb403bb567648f576867f/servers/physics_2d/collision_object_2d_sw.h#L193

@sebcrozet
Copy link
Member

Thank you for detailing your needs here. This is similar to what exists in ncollide as collision groups. This should be integrated to Rapier.

@sebcrozet sebcrozet added the C-Enhancement New feature or request label Aug 28, 2020
@stephanemagnenat
Copy link

Box2D does it the same way as Godot it seems.

@Gregoor
Copy link

Gregoor commented Oct 2, 2020

I have never implemented anything like this in a physics engine and overall my experience working with real physics engines (that weren't my own hacky beasts) is pretty non-existant. But I'd take a shot at looking at what ncollide is doing and porting it over, if that might be valuable @sebcrozet?

midstreeeam added a commit to midstreeeam/rapier that referenced this issue Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants