Exemplo n.º 1
0
  public List<CollisionVolume> getCollidingObject(CollisionModel model) {
    // TODO Make this more general
    final int minX = MathHelper.floor(model.getPosition().getX());
    final int minY = MathHelper.floor(model.getPosition().getY());
    final int minZ = MathHelper.floor(model.getPosition().getZ());
    final int maxX = minX + 1;
    final int maxY = minY + 1;
    final int maxZ = minZ + 1;

    final LinkedList<CollisionVolume> colliding = new LinkedList<CollisionVolume>();

    final BoundingBox mutable = new BoundingBox(0, 0, 0, 0, 0, 0);
    final BoundingBox position = new BoundingBox((BoundingBox) model.getVolume());
    position.offset(minX, minY, minZ);

    for (int dx = minX; dx < maxX; dx++) {
      for (int dy = minY - 1; dy < maxY; dy++) {
        for (int dz = minZ; dz < maxZ; dz++) {
          BlockMaterial material = this.getBlockMaterial(dx, dy, dz);
          mutable.set((BoundingBox) material.getBoundingArea());
          mutable.offset(dx, dy, dz);
          if (mutable.intersects(position)) {
            colliding.add(mutable.clone());
          }
        }
      }
    }

    // TODO: colliding entities
    return colliding;
  }
Exemplo n.º 2
0
 @Override
 public Region getRegion(Point point, boolean load) {
   int x = MathHelper.floor(point.getX());
   int y = MathHelper.floor(point.getY());
   int z = MathHelper.floor(point.getZ());
   return regions.getRegionFromBlock(x, y, z, load);
 }
Exemplo n.º 3
0
 @Override
 public Block getBlock(Point point) {
   int x = MathHelper.floor(point.getX());
   int y = MathHelper.floor(point.getY());
   int z = MathHelper.floor(point.getZ());
   return getBlock(x, y, z);
 }
Exemplo n.º 4
0
 @Override
 public Chunk getChunk(Point point, boolean load) {
   int x = MathHelper.floor(point.getX());
   int y = MathHelper.floor(point.getY());
   int z = MathHelper.floor(point.getZ());
   return getChunk(
       x >> Chunk.CHUNK_SIZE_BITS, y >> Chunk.CHUNK_SIZE_BITS, z >> Chunk.CHUNK_SIZE_BITS, load);
 }
Exemplo n.º 5
0
 @Override
 public Region getRegion() {
   // Check here to avoid the lookup
   if (entityManager != null && entityManager.getRegion() != null) {
     return entityManager.getRegion();
   }
   // Lookup
   World world = getWorld();
   if (world == null) {
     return null;
   } else {
     return world.getRegionFromBlock(
         MathHelper.floor(getPosition().getX()),
         MathHelper.floor(getPosition().getY()),
         MathHelper.floor(getPosition().getZ()));
   }
 }