public int collideWith(Collidable other) { TempVars tempVars = TempVars.get(); try { CollisionResults tempResults = tempVars.collisionResults; tempResults.clear(); return collideWith(other, tempResults); } finally { tempVars.release(); } } }
@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 BoundingVolume) { BoundingVolume bv = (BoundingVolume) other; return bv.collideWith(this, results); } else if (other instanceof AbstractTriangle) { AbstractTriangle tri = (AbstractTriangle) other; float d = intersects(tri.get1(), tri.get2(), tri.get3()); if (Float.isInfinite(d) || Float.isNaN(d)) { return 0; } Vector3f point = new Vector3f(direction).multLocal(d).addLocal(origin); results.addCollision(new CollisionResult(point, d)); return 1; } else { throw new UnsupportedCollisionException(); } }
CollisionResults boundResults = vars.collisionResults; boundResults.clear(); worldBound.collideWith(r, boundResults); if (boundResults.size() > 0) { float tMin = boundResults.getClosestCollision().getDistance();
public int collideWith(Collidable other) { TempVars tempVars = TempVars.get(); try { CollisionResults tempResults = tempVars.collisionResults; tempResults.clear(); return collideWith(other, tempResults); } finally { tempVars.release(); } } }
@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 BoundingVolume) { BoundingVolume bv = (BoundingVolume) other; return bv.collideWith(this, results); } else if (other instanceof AbstractTriangle) { AbstractTriangle tri = (AbstractTriangle) other; float d = intersects(tri.get1(), tri.get2(), tri.get3()); if (Float.isInfinite(d) || Float.isNaN(d)) { return 0; } Vector3f point = new Vector3f(direction).multLocal(d).addLocal(origin); results.addCollision(new CollisionResult(point, d)); return 1; } else { throw new UnsupportedCollisionException(); } }
public int collideWith(Collidable other, CollisionResults results) { if (other instanceof BoundingVolume) { BoundingVolume bv = (BoundingVolume) other; return bv.collideWith(this, results); } else if (other instanceof AbstractTriangle) { AbstractTriangle tri = (AbstractTriangle) other; float d = intersects(tri.get1(), tri.get2(), tri.get3()); if (Float.isInfinite(d) || Float.isNaN(d)) { return 0; } Vector3f point = new Vector3f(direction).multLocal(d).addLocal(origin); results.addCollision(new CollisionResult(point, d)); return 1; } else { throw new UnsupportedCollisionException(); } }
worldBound.collideWith(r, boundResults); if (boundResults.size() > 0) { float tMin = boundResults.getClosestCollision().getDistance();
CollisionResults boundResults = vars.collisionResults; boundResults.clear(); worldBound.collideWith(r, boundResults); if (boundResults.size() > 0) { float tMin = boundResults.getClosestCollision().getDistance();
public void dropGold() { if (gold > 0) { // See if there is any gold at our feet to merge to // FIXME: What would be the best way... final int goldToSet = gold; for (ObjectControl objectControl : worldState.getThingLoader().getObjects()) { if (objectControl instanceof GoldObjectControl && objectControl.getState() == ObjectControl.ObjectState.NORMAL) { // See distance if (getSpatial().getWorldBound().collideWith(objectControl.getSpatial().getWorldBound()) > 0) { GoldObjectControl goldObjectControl = (GoldObjectControl) objectControl; worldState.getGameState().getApplication().enqueue(() -> { goldObjectControl.setGold(goldObjectControl.getGold() + goldToSet); }); gold = 0; return; } } } // No merging, just add loose gold Vector3f pos = spatial.getLocalTranslation(); worldState.getGameState().getApplication().enqueue(() -> { worldState.getThingLoader().addLooseGold(new Vector2f(pos.x, pos.z), ownerId, goldToSet); }); gold = 0; } }