use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class ChunkMonitorDisplay method mouseToChunkPos.
private Vector3i mouseToChunkPos(Point p) {
Preconditions.checkNotNull(p, "The parameter 'p' must not be null");
int x = (p.x - centerOffsetX - offsetX) / chunkSize;
int z = (p.y - centerOffsetY - offsetY) / chunkSize;
return new Vector3i(x - 1, renderY, z);
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class ChunkMonitorDisplay method recomputeRenderY.
private void recomputeRenderY() {
int min = 0;
int max = 0;
int y = renderY;
for (ChunkMonitorEntry chunk : chunks) {
final Vector3i pos = chunk.getPosition();
if (pos.y < min) {
min = pos.y;
}
if (pos.y > max) {
max = pos.y;
}
}
if (y < min) {
y = min;
}
if (y > max) {
y = max;
}
minRenderY = min;
maxRenderY = max;
renderY = y;
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class ChunkMonitorEntry method addChunk.
public void addChunk(Chunk value) {
Preconditions.checkNotNull(value, "The parameter 'value' must not be null");
Preconditions.checkArgument(pos.equals(value.getPosition(new Vector3i())), "Expected chunk for position {} but got position {} instead", pos, value.getPosition(new Vector3i()));
purge();
chunks.add(new WeakReference<>(value));
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class Diamond3iIterable method iterator.
@Override
public Iterator<Vector3ic> iterator() {
Vector3i pos = new Vector3i();
final int[] level = { this.startDistance };
final Vector3i offset = new Vector3i(-this.startDistance, 0, 0);
return new Iterator<Vector3ic>() {
@Override
public boolean hasNext() {
return level[0] < endDistance;
}
@Override
public Vector3ic next() {
origin.add(offset, pos);
if (offset.z < 0) {
offset.z *= -1;
} else if (offset.y() < 0) {
offset.y *= -1;
offset.z = -(level[0] - TeraMath.fastAbs(offset.x()) - TeraMath.fastAbs(offset.y()));
} else {
offset.y = -offset.y() + 1;
if (offset.y > 0) {
if (++offset.x <= level[0]) {
offset.y = TeraMath.fastAbs(offset.x) - level[0];
offset.z = 0;
} else {
level[0]++;
offset.x = -level[0];
offset.y = 0;
offset.z = 0;
}
} else {
offset.z = -(level[0] - TeraMath.fastAbs(offset.x) - TeraMath.fastAbs(offset.y));
}
}
return pos;
}
};
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class BlockComponent method copyFrom.
@Override
public void copyFrom(BlockComponent other) {
this.position = new Vector3i(other.position);
this.block = other.block;
}
Aggregations