SFML community forums
Help => General => Topic started by: David on June 16, 2011, 02:16:04 pm
-
Hey!
I was playing around with collisions the other day (finally figured it out coming from a scripting background) and noticed that other engines such as Box2D and Chipmunk also support collision
My game is going to be tile-based (bounding box), and I need to know which collision is better: Checking the coordinates or using an engine's collision tests?
-
Box2D and Chipmunk is more for simulating some kind of physics if you ask me. If you only need collision detection and not forces then do it yourself is my opinion. Also those engines do use bounding boxes too, among other things.
-
Box2D and Chipmunk is more for simulating some kind of physics if you ask me. If you only need collision detection and not forces then do it yourself is my opinion. Also those engines do use bounding boxes too, among other things.
This also goes with another question I had in mind: Whether I should use actual physics or not (I'm making a platformer), but that's for another day
-
The code will probably run faster if you implement it yourself (assuming you won't mess up :P). On the other hand, if you implement it yourself, you have to prevent tunneling yourself (if it is an issue), you have to figure out how to respond to the collision etc. I would do it myself if I was you, unless I needed to simulate physics.
-
I think it depends on the complexity. For a simple rectangular collision, it's not worth to use an external library, but as soon as collisions get more complex and are of a common type, I would rather use something existing than reinvent the wheel. Libraries that focus on such functionality also tend to be more optimized and bug-free than own implementations.
-
The code will probably run faster if you implement it yourself (assuming you won't mess up :P). On the other hand, if you implement it yourself, you have to prevent tunneling yourself (if it is an issue), you have to figure out how to respond to the collision etc. I would do it myself if I was you, unless I needed to simulate physics.
Yea, that's what I thought, but I also thought that since it's an engine that supports collision, it should be very optimized
-
If it's axis-aligned rectangles, a simple BBox test will suffice. If it's rotated or any convex polygon, use the Separating Axis Theorem. If there are concave polygons (unlikely), triangulate then use the Separating Axis Theorem.