@Override public int collideWith(Collidable other) { if (other instanceof Ray) { Ray ray = (Ray) other; return collideWithRay(ray); } else if (other instanceof Triangle) { Triangle t = (Triangle) other; if (intersects(t.get1(), t.get2(), t.get3())) { return 1; } return 0; } else if (other instanceof BoundingVolume) { return intersects((BoundingVolume) other) ? 1 : 0; } else { throw new UnsupportedCollisionException("With: " + other.getClass().getSimpleName()); } }
@Override 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; if (intersects(t.get1(), t.get2(), t.get3())) { CollisionResult r = new CollisionResult(); results.addCollision(r); return 1; } return 0; } else if (other instanceof BoundingVolume) { if (intersects((BoundingVolume) other)) { CollisionResult r = new CollisionResult(); results.addCollision(r); return 1; } return 0; } else if (other instanceof Spatial) { return ((Spatial)other).collideWith(this, results); } else { throw new UnsupportedCollisionException("With: " + other.getClass().getSimpleName()); } }
@Override public int collideWith(Collidable other) { if (other instanceof Ray) { Ray ray = (Ray) other; return collideWithRay(ray); } else if (other instanceof Triangle) { Triangle t = (Triangle) other; if (intersects(t.get1(), t.get2(), t.get3())) { return 1; } return 0; } else if (other instanceof BoundingVolume) { return intersects((BoundingVolume) other) ? 1 : 0; } else { throw new UnsupportedCollisionException("With: " + other.getClass().getSimpleName()); } }
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; if (intersects(t.get1(), t.get2(), t.get3())) { CollisionResult r = new CollisionResult(); results.addCollision(r); return 1; } return 0; } else { throw new UnsupportedCollisionException("With: " + other.getClass().getSimpleName()); } }
@Override 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; if (intersects(t.get1(), t.get2(), t.get3())) { CollisionResult r = new CollisionResult(); results.addCollision(r); return 1; } return 0; } else if (other instanceof BoundingVolume) { if (intersects((BoundingVolume) other)) { CollisionResult r = new CollisionResult(); results.addCollision(r); return 1; } return 0; } else if (other instanceof Spatial) { return ((Spatial)other).collideWith(this, results); } else { throw new UnsupportedCollisionException("With: " + other.getClass().getSimpleName()); } }