the main collision class with the problem that I am having.

//this class is made in groovy to take advantage of overloading constructors public class Collision { public static boolean collide(AABB first, AABB other, Float u0, Float u1){ //AABB class contains 3 vectors //location - the x, y, z location //extents - the extents of the bounding box //sweep - the distance traveled that frame Vector va = new Vector(first.sweep); Vector vb = new Vector(other.sweep); Vector v = vb - va; Vector v0 = new Vector(0.0f, 0.0f, 0.0f); Vector v1 = new Vector(1.0f, 1.0f, 1.0f); if(overlap(first, other)){ u0 = 0.0f; u1 = 0.0f; return true; } for(int i = 0; i < 3; i++){ if(max(i, first) < min(i, other) && v[i] < 0) v0[i] = (float)((max(i, first) - min(i, other) / v[i])); else if(max(i, other) < min(i, first) && v[i] > 0) v0[i] = (float)((min(i, first) - max(i, other)) / v[i]); if(max(i, other) > min(i, first) && v[i] < 0) v1[i] = (float)((min(i, first) - max(i, other)) / v[i]); else if(max(i, first) < min(i, other) && v[i] > 0) v1[i] = (float)((max(i, first) - min(i, other)) / v[i]); } u0 = Math.max(v0.x, Math.max(v0.y, v0.z)); u1 = Math.min(v1.x, Math.min(v1.y, v1.z)); return u0 <= u1; } private static boolean overlap(AABB first, AABB other) { Vector T = other.location - first.location; return Math.abs(T.x) <= (first.location.x + other.location.x) && Math.abs(T.y) <= (first.location.y + other.location.y) && Math.abs(T.z) <= (first.location.z + other.location.z); } private static float max(int i, AABB bla){ bla.location[i] + bla.bounds[i]; } private static float min(int i, AABB bla){ bla.location[i]; } }

the class that handels the vectors

it is a wraper class for vector3f letting me overload operators

class Vector extends Vector3f { public Vector(float f, float g, float h) { super(f, g, h); } public Vector(Vector3f a){ super(a); } public Vector plus(Vector other){ return new Vector((float) (x + other.x), (float) (y + other.y), (float) (z + other.z)); } public Vector minus(Vector other){ return new Vector((float) (x - other.x), (float) (y - other.y), (float) (z - other.z)); } public Float getAt(Integer i){ if(i > 2 || i < 0) throw new IndexOutOfBoundsException("Vector index out of bounds"); switch(i){ case 0: return x; case 1: return y; case 2: return z; } } public void putAt(Integer i, Float a){ if(i > 2 || i < 0) throw new IndexOutOfBoundsException("Vector index out of bounds"); switch(i){ case 0: x = a; return; case 1: y = a; return; case 2: z = a; return; } } public static Vector downcast(Vector3f down){ return new Vector(down.x, down.y, down.z); } }