Sign in to follow this  
l4mbda

Pixel perfect collision and concave shapes in 2D

Recommended Posts

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?

Thanks in advance.

Share this post


Link to post
Share on other sites

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