Jump to content

  • Log In with Google      Sign In   
  • Create Account

Collision detection against curves or other complex shapes and bitmaps.

  • You cannot reply to this topic
3 replies to this topic

#1 SomeNoob   Members   -  Reputation: 102


Posted 30 August 2014 - 10:50 PM

Ok so I am new in game development and for simple games bounding box collision is fine. However, let's say you have a shape or bitmap like this:


Now this is just an example but if you had more elaborate curves or even a whole shape which was more complex than a simple polygon or rectangle-like shape, how would you do precise collision detection? And I am strictly speaking in 2D here. I just want to know the concept behind how you would do this. Thanks!


#2 Waterlimon   Crossbones+   -  Reputation: 2565


Posted 31 August 2014 - 04:07 AM

You would either represent it as a collection of simple collision primitives (circles, boxes etc.) that are scaled and rotated to approximate it well, or you would approximate it as an arbitrary polygon (which the physics engine could triangulate or just do physics based on the polygon edges or whatever works the best)


Check some 2D physics engine and see what features it has.


#3 tonemgub   Members   -  Reputation: 1139


Posted 01 September 2014 - 12:53 AM

Here's a great article about per-pixel collision detection: http://lazyfoo.net/SDL_tutorials/lesson18/

And a quad-tree implementation for speeding it up: http://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-374

Edited by tonemgub, 01 September 2014 - 12:59 AM.

#4 wodinoneeye   Members   -  Reputation: 820


Posted 30 September 2014 - 03:00 PM

There is a thing called 'lazy evaluation'  where for the bulk of the collision interactions you use a fairly crude evaluation method (like AABB axis aligned bounding boxes) to validly eliminate most (hopefully vast majority) of the candidates for the collision test,  leaving the remainder to be subjected to the much more processing -intense (but accurate) methods.      


Eample is a human figure object maintaining a AABB box that encompases every extremity and then being used to filter out obvious misses of projectiles,  but then if passed proceding to a more accurate piece by piece (figure mesh) testing can then be done to be fully accurate (or as accurate as needed for the games mechanics).  Thus eliminating alot of unncecessary and game performance sapping processing.

--------------------------------------------Ratings are Opinion, not Fact