Giter Site home page Giter Site logo

Add collision exceptions. about rapier HOT 8 CLOSED

dimforge avatar dimforge commented on June 15, 2024
Add collision exceptions.

from rapier.

Comments (8)

sebcrozet avatar sebcrozet commented on June 15, 2024 2

Thank you for your feedbacks @kakoeimon and @dpmkl. So I think we are talking here about letting the user setup some arbitrary filter rule for collision pairs. I think this is something we will want to add, yes.
We will also need #2 which is more efficient but not as versatile.

from rapier.

sebcrozet avatar sebcrozet commented on June 15, 2024

What do you mean exactly by "collision exceptions"? How is this different from #2 from the end-user point of view?

from rapier.

dpmkl avatar dpmkl commented on June 15, 2024

I would reckon he means something like the collision filter callback in Box2D. https://github.com/erincatto/box2d/blob/master/src/dynamics/b2_world_callbacks.cpp#L28
This could come in handy for 2D Platformer mechanics, where you are able to jump up through platforms but don't fall down through them.

from rapier.

kakoeimon avatar kakoeimon commented on June 15, 2024

The difference is that you may want an object not to collide with a particular object and not the whole group.
For example a bullet will collide with all the objects but not with the player who shooted it.

from rapier.

jpetkau avatar jpetkau commented on June 15, 2024

[Edit: oh, I guess this is a dup of #2 if my interpretation is correct.]

Some examples:

  • Chain or cloth: allow each link to interpenetrate its neighbors, but collide normally with everything else
  • 2D physics: often you want to ignore self-collision (e.g. in a side-view game with a walking character, the character's legs should be able to cross each other).
  • (Sort of the same): 2D game with pseudo-depth in Z: objects should be able to pass in front of/behind other layers, but still hit their own layer.
  • Bullet / grenade that ignores shooter / thrower but can hit everything else. [From @kakoeimon's reply]

The most general form of this would be an arbitrary predicate saying whether a pair of objects can collide or not. But simple filter bitmasks are faster and useful enough for many cases. Examples:

  • In Box2d each object has a 32-bit "category" and a 32-bit "mask", and collisions require obj1.cat& obj2.mask && obj2.cat & obj1.mask: http://www.iforce2d.net/b2dtut/collision-filtering
  • In NVidia's flex there's a 32-bit "phase", with a 24-bit "group" and a 1-bit "flag" indicating whether a particle should collide with other particles with the same group.

from rapier.

kakoeimon avatar kakoeimon commented on June 15, 2024

It is not a dup of #2
Think about it as a bullet/granade that can do a frendly fire but cannot damage the shooter/thrower.
This is not just for 2D, neither masks and layers are.
Those two #2 and this are essential in game making. Especialy if there are no plans to expose to the user checks just before the collision detection.
If there are plans to expose to the users a way to make checks before the actual collision detection then there is no need to implement this, neither #2 and the user can implement his own checkings.

from rapier.

jpetkau avatar jpetkau commented on June 15, 2024

I'm not sure how what you're describing differs from "an arbitrary predicate saying whether a pair of objects can collide or not"?

It is not a dup of #2 ...
Think about it as a bullet/granade that can do a friendly fire but cannot damage the shooter/thrower.
This is not just for 2D, neither masks and layers are.

I wasn't saying it's only for 2D (e.g. the cloth example only makes sense in 3D). I was just giving some examples of when it's useful, and two of them happened to be for 2D.

from rapier.

kakoeimon avatar kakoeimon commented on June 15, 2024

Yes without the "But" It does not differ.

from rapier.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.