Sign in to follow this  

Collision detection

This topic is 4227 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
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
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

This topic is 4227 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this