-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
Comments
Thank you for detailing your needs here. This is similar to what exists in ncollide as collision groups. This should be integrated to Rapier. |
Box2D does it the same way as Godot it seems. |
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? |
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
The text was updated successfully, but these errors were encountered: