1
\$\begingroup\$

I've got this problem, and I don't know what may be the cause of it.

I finished reading this article on sphere-triangle collision.

My character (the sphere) stops before it reaches the triangle, and then over like 2 seconds it slowly reaches the "expected" spot where I really want it to stop.

Thing is, I tried switching my whole algorithm from floats to doubles, and they problem stays. So I'm not really sure if that's a number precision problem, although after many debugging I think that there could be a problem with the precision of the next calculation: (t0 and t1)

Real signedDistToTrianglePlane = trianglePlane.signedDistanceTo(colPackage->basePoint);

Real normalDotVelocity = glm::dot(trianglePlane.normal(),colPackage->velocity);

t0 = ((Real)-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
t1 = ((Real)1.0 - signedDistToTrianglePlane) / normalDotVelocity;

Could the dot product function be a trap for precise calculations? (signedDistanceTo() uses glm::dot as well)

Here's my collision detection & response algorithms.

One last thing to note is that on page 47 in the article, the author uses a verySmallDistance number where he only updates some variables if distanceToCollision is bigger than it. I don't understand these lines.

I've been struggling with this issue for a week now. Any help or idea on the subject will be highly appreciated!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.