Quote:Original post by simotix
Granted that I am correct about my elapsed time idea, I have one other problem I want to tackle with this algorithm before I was my hands of it. It deals with having a radius of other than one for the sphere.
In my test case I did a radius of 0.5, a base point of (2.5, 1.0, 0) and a velocity of (0, -0.5, 0), this should cause it to just touch at (2.5, 0, 0), the issue is that I do not report collision or no collision, I just seem to not fall into a case.
I get that my Normal dot Velocitty is -0.5, that is almost obvious. I then have the following to work off of radius
I did this because of the way the documentation explains the collision "If the distance is greater than 1 then we know that a collision cannot ever happen and we can return early from the function." I figured by one they mean that because of their radius being one.
Yes, but the time of collision would be 2.0. Is that getting rejected? The comment "distance > 1" probably means, the distance along the path of travel. If you have a distance of 2.0, then it will get rejected, and picked up at another frame.
Quote:
if (fabs(signedDistToTrianglePlane) >= fRadius)
That code is to check if the sphere is already embedded in the plane. If it is, it's a special case. The time the sphere hits the plane will be zero, and you can use the current sphere position for further checks.
if the sphere is not already embedded with the plane, you can run that code
Quote:
t0=(-fRadius-signedDistToTrianglePlane)/normalDotVelocity;t1=( fRadius-signedDistToTrianglePlane)/normalDotVelocity;
Quote:
However, I am not sure what else should be changed due to the radius? I know that their should be collision, but I am not sure how to have this be based off of the radius unfortunately
taking the collision paper as it is, these are the lines that should be replaced with a radius.
if (fabs(signedDistToTrianglePlane) >= 1.0f) {
replace with
if (fabs(signedDistToTrianglePlane) >= radius) {
else {// N dot D is not 0. Calculate intersection interval:t0=(-1.0-signedDistToTrianglePlane)/normalDotVelocity;t1=( 1.0-signedDistToTrianglePlane)/normalDotVelocity;
replace with
else {// N dot D is not 0. Calculate intersection interval:t0=(-radius-signedDistToTrianglePlane)/normalDotVelocity;t1=( radius-signedDistToTrianglePlane)/normalDotVelocity;
// P1b = 2.0*(velocity.dot(base-p1));c = (p1-base).squaredLength() - 1.0;if (getLowestRoot(a,b,c, t, &newT)) {t = newT;
replace with
// P1b = 2.0*(velocity.dot(base-p1));c = (p1-base).squaredLength() - (radius * radius);if (getLowestRoot(a,b,c, t, &newT)) {t = newT;
and for P2, and P3.
then the edges
// Calculate parameters for equationc = edgeSquaredLength*(1-baseToVertex.squaredLength())+edgeDotBaseToVertex*edgeDotBaseToVertex;
replace with
// Calculate parameters for equationc = edgeSquaredLength*((radius*radius)-baseToVertex.squaredLength())+edgeDotBaseToVertex*edgeDotBaseToVertex;
The algorithm also assumes that the time lapse is in the range [0, 1]. This is where the time comparisons for 't', 't0', 't1', and 'f' with 1's come from.