For collision detection, is Chipmunk or Box2d the best tool?

For a Cocos2d-based project, I would like to use physical tools for conflict detection. What are the pros and cons of using Chipmunk or Box2d?

+6
source share
2 answers

What kind of collisions are we talking about?

If you need all this:

  • rect intersects the rectangle -> CGRectIntersectsRect (..)
  • point in rect → CGRectContainsPoint (..)
  • the radius intersects (i.e. the distance of two points) → ccpDistance (..)

Then you do not need a physical engine at all, and you also do not need to write your own collision detection algorithms.

Chipmunk and Box2D manage collisions equally well. I am of the opinion that if someone asks “what is better”, it will not matter to you. Instead, ask yourself if you are more comfortable working with C (Chipmunk) or C ++ (Box2D).

Likewise, do you prefer working with an object-oriented API (Box2D) or a functional, shortened API (Chipmunk)?

Base your decision on what makes it easier for you to work, rather than some arbitrary, undefined and very subjective idea of ​​whether one physical engine can be better than another, because the technical differences are insignificant, and you can only evaluate their impact on your gaming design, if you both well know your own game design and internal algorithms of physical engines.

+4
source

According to this answer, Chipmunk does not support continuous collision detection, but Box2D does. This is important to prevent "tunneling" (objects passing a little through each other when driving at high speeds)

This is explained by Steffen Itterheim's text about his Box2D vs Chipmunk FAQ : if you have very fast moving physics objects like Bullets, consider using Box2D, as it can make crowded collisions, as well as continuous collision integration to prevent fast moving objects from deep penetration or even tunneling through other objects.

Collision detection with cumps docs talk about separate() callback. The two forms have just stopped touching for the first time this step. but it was not clear to me if this had any significance for their ability to detect collisions with speed.

There is also a very negative opinion about using Box2D for a breakthrough game. My current game uses Box2D, and I would like to use Chipmunk with it ... Mostly because Box2D has two serious problems that are exacerbated in my game: firstly, it has a REALLY old error, where objects “caught” in the corners, my game is a breakthrough game, so when the ball “rolls” along the wall, sometimes it breaks and is thrown off the wall, many people ask why my game physics looks “random”.

Conclusion: I am also embarrassed.

+9
source

Source: https://habr.com/ru/post/898761/


All Articles