Sign in to follow this  
Dark Metamorphosis

Collision with lines of a polygon

Recommended Posts

hi guys, as the subject says, I have a probleme with the collision detection against the lines of a polygon (meaning the 3 line segments that relates it vertices). the idea is when the sphere collides with the inside of the polygon, I push according to the polygons normal, and the sphere's radius, but when doing that to the line, I have a probleme, since two polygons may share the same line: _______ / / / if the sphere tries to climb the shape above, it is going to find a probleme when it raches the edge, and the its movement won't be smooth any more, but it will acts as if it collided with something. I hope I am clear enough thanks.

Share this post


Link to post
Share on other sites
I'm not sure if I followed that, but I'll post exactly the same response I did to another post just a second ago, and that is to google for a paper called 'Improved Collision Detection and Response', by a guy named Kasper Fauerby, who also goes by Telemachos. If you can find that paper, it may answer your questions.

Share this post


Link to post
Share on other sites
Yah I see your problem - which direction do you push the sphere when it hits that edge?

The way *I* would do it is to push the sphere back towards where it was last frame until it is no longer touching any polys.

Then I would completely eliminate the speed of thethe sphere in the direction of the polygon's normal. eg.


real fSpeed;

for (i = 0; i < numpolystouchingsphere; i++)
{
fSpeedInDirectionOfNormal = vec3dotproduct(&sphere.velocity, &poly[i].normal);
vec3sub(&sSphere.velocity, &sSphere.velocity, &poly[i].normal, -fSpeedInDirectionOfNormal);
}



That way at least the sphere would transfer some of it's velocity in the up direction when touching the left edge and when it starts touching both edges it will be able to move right *and* up.

Let me know if that helps :)

Share this post


Link to post
Share on other sites
The thing is that I am actually using this collision detection for the ground too, which mean that I can't go with your way FRay, because this would result in a horrible movement.
so the problem here is mainly against the ground polygons, and when the sphere is moving from a polygon to another, it passes through the polygons two (or more) shared edges, and here the way I respond to the collision against edges (push the sphere with the poly's normal) result in an unscaled motion of the sphere.

Share this post


Link to post
Share on other sites
To be honest, I can't see what the problem with dampening the velocity in the polygon normal direction will be. I have used the above method successfully on all types of polygons (ground collision, object-object etc...) and it transfers momentum smoothly. Oh, well, good luck finding another solution :)

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