How To Handle Object/Item Collision

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
AerisAndMe
ES Software Engineer
ES Software Engineer
Posts: 381
Joined: Tue Apr 07, 2009 9:29 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: PC, SNES, PS3
Programming Language of Choice: C/++
Location: Madison AL
Contact:

Re: How To Handle Object/Item Collision

Post by AerisAndMe »

Welllll..... there's no magix way to know what objects are going to be colliding with what other objects. But a quad/oct - tree can improve your chances of guessing :)

Of course checking every object with every other object WOULD work, it would just be slower than rendering a tortoise in HD.

Implementing a quadtree (if you're in 2D) or an octree (if you're in 3D), both of which act the same way in their respective dimensions, would eliminate a whole bunch of unnecessary checks. Somewhere around here, I thought avansc posted about quadtrees.... Hrmm... Anyway, the basic idea is that you're breaking up space in which a collision between two points is possible by continually decomposing that space into quadrants (or um... octants? in 3D). i.e. an object in the top left corner of the screen doesn't have to be checked for collision with an object in the bottom right corner since they aren't in the same quadrant.

Google.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: How To Handle Object/Item Collision

Post by dandymcgee »

AerisAndMe wrote:Welllll..... there's no magix way to know what objects are going to be colliding with what other objects. But a quad/oct - tree can improve your chances of guessing :)

Of course checking every object with every other object WOULD work, it would just be slower than rendering a tortoise in HD.

Implementing a quadtree (if you're in 2D) or an octree (if you're in 3D), both of which act the same way in their respective dimensions, would eliminate a whole bunch of unnecessary checks. Somewhere around here, I thought avansc posted about quadtrees.... Hrmm... Anyway, the basic idea is that you're breaking up space in which a collision between two points is possible by continually decomposing that space into quadrants (or um... octants? in 3D). i.e. an object in the top left corner of the screen doesn't have to be checked for collision with an object in the bottom right corner since they aren't in the same quadrant.

Google.
I read a whole ton about quadtrees, but unfortunately just like the Separating Axis Theorem, I didn't even know where to start integrating theory and project. :|
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: How To Handle Object/Item Collision

Post by Falco Girgis »

dandymcgee wrote:
AerisAndMe wrote:Welllll..... there's no magix way to know what objects are going to be colliding with what other objects. But a quad/oct - tree can improve your chances of guessing :)

Of course checking every object with every other object WOULD work, it would just be slower than rendering a tortoise in HD.

Implementing a quadtree (if you're in 2D) or an octree (if you're in 3D), both of which act the same way in their respective dimensions, would eliminate a whole bunch of unnecessary checks. Somewhere around here, I thought avansc posted about quadtrees.... Hrmm... Anyway, the basic idea is that you're breaking up space in which a collision between two points is possible by continually decomposing that space into quadrants (or um... octants? in 3D). i.e. an object in the top left corner of the screen doesn't have to be checked for collision with an object in the bottom right corner since they aren't in the same quadrant.

Google.
I read a whole ton about quadtrees, but unfortunately just like the Separating Axis Theorem, I didn't even know where to start integrating theory and project. :|
It comes with a lot of experience with abstract mathematics--or in the words of Kendall, "A shitload of linear algebra."
Lucas
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 16
Joined: Sun May 24, 2009 11:28 am
Favorite Gaming Platforms: PC, SNES, Dreamcast
Programming Language of Choice: C++
Location: UK

Re: How To Handle Object/Item Collision

Post by Lucas »

AerisAndMe wrote:Somewhere around here, I thought avansc posted about quadtrees.... Hrmm...
Since it has been mentioned if anybody is too lazy to search for it, it's here http://elysianshadows.com/phpBB3/viewto ... 765#p39765
(I assume that's the post you were talking about)

It definatly(sp?) helped me understand quadtrees a bit better, it is in a PowerPoint presentation so if you don't have PowerPoint you'll need to download the PowerPoint viewer from Microsoft's website.
I don't see any invisible walls...
Post Reply