Long story short, I'm still a shitty coder I guess. I need to rewrite a function that is dependant on a class being pased as an argument. It solves t for sphere to plane collision. Some of the first attempt code is commented out.
float CColSphere::CollideAABB(const CColAABB &s, float tcount){ Vector3 S = Internal; Vector3 D = Direction * Velocity * tcount; Vector3 P = s.Internal + s.ClosestToPoint(S - s.Internal); Vector3 C = S - P; Vector3 N = Normalize3( C ); //Vector3 R = S + ( N * -Radius ); float d = ( C * N ) - Radius; float u = ( d - ( C * N ) + Radius ); float f = ( D * N ); //float f = N * ( Direction * Velocity * tcount ); //float u = ( R - C ) * N; float t = u / f; if(t <= 0.0f) { Vector3 b = s.ClosestToPoint(Internal - s.Internal); Vector3 c = (Internal - (b + s.Internal)); // if(c.x) Direction.x = -Direction.x; if(c.z) Direction.z = -Direction.z; if(c.x && c.z) Direction = c; if( s.Contains( Internal - s.Internal ) ) Direction = Internal - s.Internal; Direction = Normalize3(Direction); return 1.0f; } if(t < 1.0f && t > 0.0f) return t; else return 0.0f;}