@Override public boolean intersectsSphere(BoundingSphere sphere, TempVars vars) { Vector3f closestPoint = getClosestPoint(vars, sphere.getCenter()); // check if the point intersects with the sphere bound if (sphere.intersects(closestPoint)) { return true; } return false; }
@Override public int collideWith(Collidable other) { if (other instanceof Ray) { Ray ray = (Ray) other; return collideWithRay(ray); } else if (other instanceof Triangle){ return super.collideWith(other); } else if (other instanceof BoundingVolume) { return intersects((BoundingVolume)other) ? 1 : 0; } else { throw new UnsupportedCollisionException(); } }
public int collideWith(Collidable other, CollisionResults results) { if (other instanceof Ray) { Ray ray = (Ray) other; return collideWithRay(ray, results); } else if (other instanceof Triangle){ Triangle t = (Triangle) other; return collideWithTri(t, results); } else if (other instanceof BoundingVolume) { if (intersects((BoundingVolume)other)) { CollisionResult result = new CollisionResult(); results.addCollision(result); return 1; } return 0; } else if (other instanceof Spatial) { return ((Spatial)other).collideWith(this, results); } else { throw new UnsupportedCollisionException(); } }
@Override public int collideWith(Collidable other) { if (other instanceof Ray) { Ray ray = (Ray) other; return collideWithRay(ray); } else if (other instanceof Triangle){ return super.collideWith(other); } else if (other instanceof BoundingVolume) { return intersects((BoundingVolume)other) ? 1 : 0; } else { throw new UnsupportedCollisionException(); } }
public int collideWith(Collidable other, CollisionResults results) { if (other instanceof Ray) { Ray ray = (Ray) other; return collideWithRay(ray, results); } else if (other instanceof Triangle){ Triangle t = (Triangle) other; return collideWithTri(t, results); } else if (other instanceof BoundingVolume) { if (intersects((BoundingVolume)other)) { CollisionResult result = new CollisionResult(); results.addCollision(result); return 1; } return 0; } else if (other instanceof Spatial) { return ((Spatial)other).collideWith(this, results); } else { throw new UnsupportedCollisionException(); } }