Jump to content
  • Advertisement
Sign in to follow this  
Cocytus

Collision detection

This topic is 4439 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering if there was a better way to do collision testing other than the simple way of checking each entity against all other entities out there as this results in a Big O of n^2. If this is the only way then thats fine. i'm just wondering if there is a faster one. thank you. -Cocytus

Share this post


Link to post
Share on other sites
Advertisement
Given how little we know about the type of game you're working on, I can only give generalities.

Each object needs to be checked against each object that it can possibly collide with. The trick to making collision detection more efficient is to figure out which objects it can possibly collide with. This is where things like quad-trees come in. On the simplest level if you break down the world into a set of regions, each object can only collide with objects in the same region as itself. Depending how you implement it, this can drastically reduce the number of checks you have to do.

If you provide us with a more specific context we will be able to help more.

Share this post


Link to post
Share on other sites
I thank you for the quick reply.

That was the type of answer i was looking for.

Thank you again.


-Cocytus

Share this post


Link to post
Share on other sites
In addition to the above suggestion, a quick and easy optimization is to only test each unique pair of objects; this can be done by only testing each object against those objects that appear after it in the list.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!