Search in sources :

Example 91 with Vector3i

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);
}
Also used : Vector3i(org.joml.Vector3i) Point(java.awt.Point)

Example 92 with Vector3i

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;
}
Also used : Vector3i(org.joml.Vector3i) ChunkMonitorEntry(org.terasology.engine.monitoring.chunk.ChunkMonitorEntry) Point(java.awt.Point)

Example 93 with Vector3i

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));
}
Also used : Vector3i(org.joml.Vector3i)

Example 94 with Vector3i

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;
        }
    };
}
Also used : Vector3i(org.joml.Vector3i) Iterator(java.util.Iterator)

Example 95 with Vector3i

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;
}
Also used : Vector3i(org.joml.Vector3i)

Aggregations

Vector3i (org.joml.Vector3i)203 Test (org.junit.jupiter.api.Test)87 Vector3ic (org.joml.Vector3ic)54 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)38 Chunk (org.terasology.engine.world.chunks.Chunk)36 BlockRegion (org.terasology.engine.world.block.BlockRegion)30 Block (org.terasology.engine.world.block.Block)22 ChunkImpl (org.terasology.engine.world.chunks.internal.ChunkImpl)21 Vector3f (org.joml.Vector3f)19 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 Map (java.util.Map)11 BeforeEach (org.junit.jupiter.api.BeforeEach)10 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)10 ChunkViewCoreImpl (org.terasology.engine.world.internal.ChunkViewCoreImpl)8 OnChunkLoaded (org.terasology.engine.world.chunks.event.OnChunkLoaded)7 Lists (com.google.common.collect.Lists)6 Maps (com.google.common.collect.Maps)6 List (java.util.List)6 ExecutionException (java.util.concurrent.ExecutionException)6 Future (java.util.concurrent.Future)6