# Collision with lines of a polygon

This topic is 5145 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 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.normal);    vec3sub(&sSphere.velocity, &sSphere.velocity, &poly.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 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 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 :)

1. 1
2. 2
Rutin
22
3. 3
4. 4
frob
18
5. 5

• 33
• 13
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
632566
• Total Posts
3007107

×