private int collideWithRay(Ray ray) { TempVars vars = TempVars.get(); try { Vector3f diff = vars.vect1.set(ray.origin).subtractLocal(center); Vector3f direction = vars.vect2.set(ray.direction); //float[] t = {0f, Float.POSITIVE_INFINITY}; float[] t = vars.fWdU; // use one of the tempvars arrays t[0] = 0; t[1] = Float.POSITIVE_INFINITY; float saveT0 = t[0], saveT1 = t[1]; boolean notEntirelyClipped = clip(+direction.x, -diff.x - xExtent, t) && clip(-direction.x, +diff.x - xExtent, t) && clip(+direction.y, -diff.y - yExtent, t) && clip(-direction.y, +diff.y - yExtent, t) && clip(+direction.z, -diff.z - zExtent, t) && clip(-direction.z, +diff.z - zExtent, t); if (notEntirelyClipped && (t[0] != saveT0 || t[1] != saveT1)) { if (t[1] > t[0]) return 2; else return 1; } return 0; } finally { vars.release(); } }
private int collideWithRay(Ray ray) { TempVars vars = TempVars.get(); try { Vector3f diff = vars.vect1.set(ray.origin).subtractLocal(center); Vector3f direction = vars.vect2.set(ray.direction); //float[] t = {0f, Float.POSITIVE_INFINITY}; float[] t = vars.fWdU; // use one of the tempvars arrays t[0] = 0; t[1] = Float.POSITIVE_INFINITY; float saveT0 = t[0], saveT1 = t[1]; boolean notEntirelyClipped = clip(+direction.x, -diff.x - xExtent, t) && clip(-direction.x, +diff.x - xExtent, t) && clip(+direction.y, -diff.y - yExtent, t) && clip(-direction.y, +diff.y - yExtent, t) && clip(+direction.z, -diff.z - zExtent, t) && clip(-direction.z, +diff.z - zExtent, t); if (notEntirelyClipped && (t[0] != saveT0 || t[1] != saveT1)) { if (t[1] > t[0]) return 2; else return 1; } return 0; } finally { vars.release(); } }
boolean notEntirelyClipped = clip(+direction.x, -diff.x - xExtent, t) && clip(-direction.x, +diff.x - xExtent, t) && clip(+direction.y, -diff.y - yExtent, t) && clip(-direction.y, +diff.y - yExtent, t) && clip(+direction.z, -diff.z - zExtent, t) && clip(-direction.z, +diff.z - zExtent, t); vars.release();