Jump to content
  • Advertisement
Sign in to follow this  
l4mbda

Pixel perfect collision and concave shapes in 2D

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

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!