Original Post
This is Dimitri's ( hope i spelled your name ok) sphere Ray intersection test. i have played around with it, and tried to do a sphere sphere collision test with it. it works to an extent,but the problem is that the collission isnt detected when the bounding spheres touch but when their centers touch, which gives the impression that one charachter is overlapping the other, and no matter what i do, i cant seem to get that to change. anyone got any ideas ? also could you explain out this algorithm to me, as maby picked it up wrong and this is why i cant fix it.
public bool SphereSphereIntersection(Vector3 point, Vector3 vel, double rad, double intersectTime1, double intersectTime2)
{
bool ret = false;
double det , b, k;
k = Vector3.Dot(vel,vel);
b = -Vector3.Dot(point,vel)/k;
det = ( b*b ) -( Vector3.Dot(point,point) - (rad))/k ;
if(det <0)
{
ret = false;
}
det = Math.Sqrt((double)det);
intersectTime1 = b-det;
intersectTime2 = b+det;
if(intersectTime2 < 0)
{
ret = false;
}
if(intersectTime1 < 0)
{
intersectTime1 = 0;
ret = true;
}
return ret;
}