• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Pixel perfect collision and concave shapes in 2D

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

No replies to this topic

### #1l4mbda  Members

Posted 26 September 2012 - 08:43 AM

Hi everyone,
I hope you can help me.

I'm working on a concept of pixel perfect collision in a 2D enviroment combinied with some physic simulations.

My problem comes by handling a collision correctly. For example, my object wants to move in an area it mustn't, I recalculate the velocity and bring it as close as it is alowed to the "edge". Now, for my purposes, the object must react to any kind of shapes. and even if it's only one backgruound pixel. So, I check both, the background and also the objects bitfield for overlap. And while this all works pretty nice on "straight line egdes", I often encoure problems whene I hit a concave shape.

I know what the problem is: No matter how round a shape is, at the end it's all about suqare pixels. That's the first thing I can't simulate. Then, when I hit pixel and recalculate the velocity, in the next frame my object often hits a Pixel next to the first collisons pixel. In the real world, the object would just "roll over" this pixel by its mass, but in my concept, it just calculates the velocity new and sends it in the moste cases back to the first collision, which concludes amlmost everytime in a situation, where my object gets stuck in a round shape.

I tried alot of things, but nothing got me any closer to a smooth collision handling in concave curves.

Has anyone any suggestions?