Sign in to follow this  

Collision of polygons in 2D vector-based simulation

This topic is 4592 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. I've just been thinking about collision handling in this vector-based game engine I'm trying to develop. All the objects are polygons with float-value vertices along with (x, y) coordinates for their "centres." I'm trying to see if I can develop "line-perfect" collision. What I do is before I actually move the objects in the game I use their velocities to calculate what the coordinates of their vertices will be. I create lines between these vertices for each object, as well as lines between the vertices and their correspondents in the original polygon (so, when you draw the lines, the objects look kind of 3D if they're moving fast enough). To test for collision, I check if any of these lines from two objects intersect at all. I made lines between the vertices of the "shadow" shape and the real shape in case a polygon is moving so fast it would be translated completely past another polygon when it's actually updated. Here's an image to help visualizing this: [url]http://img197.echo.cx/img197/2035/collisiondiagram4tg.jpg[/url] What I want to do is if two objects will collide the update method would be altered for them so that they'd be just touching in the next frame, instead of overlapping. To keep the unit time on track I'd figure out what percentage of the unit time it would take the objects to move close enough to touch then figure out where they'd move in the remaining time based on whatever physics I use, which is what gets drawn to the screen.

Share this post


Link to post
Share on other sites
Not sure what you are asking exactly. Some collision response?

This below is an algorithm for swept collision detection (using velocities), which should be faster than ray-casting every points.

http://members.gamedev.net/oliii/PolyColly3.zip

And since you have the contact for the lines an the polygon, it's simply a matter of moving the objects to the time of contact, so they just touch, or take the earliest one. As for the response, anything goes. Rigid bodies, velocity reflection, ...

http://uk.geocities.com/olivier_rebellion/Polycolly.zip

that's an earlier version of the code. It's gor examples and docs for collision response, contact calculation, and so forth.

This one also has a code + doc about ray-polygon intersections.

Share this post


Link to post
Share on other sites
I downloaded your tutorials oliii. They seem good though it might take me a while to wrap my head around the math. Thank you anyway.

I guess my real question is how do I determine the time (starting from time = 0) at which two moving polygons, either convex or concave, contact each other before overlapping.

Share this post


Link to post
Share on other sites

This topic is 4592 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.

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