Welcome, Guest. Please login or register. Did you miss your activation email?

Poll

Which is better?

Checking for the coordinates
4 (66.7%)
Using an engine
2 (33.3%)

Total Members Voted: 5

Voting closed: June 16, 2011, 02:16:04 pm

Author Topic: Collision Optimization  (Read 3997 times)

0 Members and 1 Guest are viewing this topic.

David

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Collision Optimization
« 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?

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Collision Optimization
« Reply #1 on: June 16, 2011, 02:19:24 pm »
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.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

David

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Collision Optimization
« Reply #2 on: June 16, 2011, 02:28:50 pm »
Quote from: "Groogy"
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

Dimple

  • Newbie
  • *
  • Posts: 30
    • View Profile
Collision Optimization
« Reply #3 on: June 17, 2011, 01:54:16 am »
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.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Collision Optimization
« Reply #4 on: June 17, 2011, 02:01:06 am »
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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

David

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Collision Optimization
« Reply #5 on: June 17, 2011, 02:02:58 am »
Quote from: "Dimple"
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

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Collision Optimization
« Reply #6 on: June 17, 2011, 06:26:21 am »
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.
I use the latest build of SFML2