Jump to content
  • Advertisement
Sign in to follow this  

Capsule separating axis

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


Sorry for my level of English, I hope you can understand this mail :)

I have problems with test collsion between capsules and triangles using separatiion axis test.

For the directions, I use:
- The triangle normal against the two vertex of the capsule segment (the cylinder axis of the capsule)
- The triangle edges against the capsule segment

For each test, I add the capsule sphere radius to the two projected capsule vertices for find the correct distance.

void CapsuleCollisionGeometry::getIntervalMinMax(const vector3 *dirAxis, float& min, float& max) const
min = max = dirAxis->dotProduct(m_segmentPoints[0]);

float d = dirAxis->dotProduct(m_segmentPoints[1]);

if(d < min)
min = d;

if(d > max)
max = d;

min -= m_sphereRad;
max += m_sphereRad;

But some of the collsions are missed. I supose that I need additional axis to test. I read several solutions, but I don't know what is the correct:

"8 directions of lines perpendicular to capsule main axis, passing through each of the box vertices (to test vertices to capsule cylinder, actually catches the faces agains capsule cylinder as a side effect"
"Get the closer triangle vertex and use the vector from this point to the center of the capsule or the closer point of the capsule segment"

Somebody can help me?

Thanks in advance.

Juan Alfonso

Share this post

Link to post
Share on other sites
First I would try to compute the closest points between the segment and the triangle. I use GJK for this which is pretty simple, but you can use another approach as well. If the segment and the capsule don't intersect I check if the seperating axis (difference between closest points) and the triangle normal are parallel. If they are within some threshold I clip the segment against the side planes of the triangle to create two contact points. Otherwise the closest points define the contact. If the segment intersects the triangle you can actually use SAT and you have to test the triangle normal and the cross products between the segment and the triangle edges (four axes). Again I would try to clip in the case of a face contact.

If you want to run a pure SAT you have to consider that the segment might not be intersecting. In this case the closest point can be vertex - vertex, edge - vertex, edge - edge. So you need to test all these case as well. E.g. all difference vectors of segment vertices to triangle vertices (six axes). This is where the GJK comes into play and the two stage approach as mentioned above.


Share this post

Link to post
Share on other sites
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!