Search in sources :

Example 26 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class BlockRegionTest method union.

@ParameterizedTest
@MethodSource("unionArgs")
public void union(Vector3i vec1, Vector3i vec2) {
    BlockRegion expected = new BlockRegion(new Vector3i(-2, 4, -16), new Vector3i(4, 107, 0));
    assertEquals(expected, new BlockRegion(vec1).union(vec2));
    assertEquals(expected, new BlockRegion(vec2).union(vec1));
}
Also used : Vector3i(org.joml.Vector3i) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 27 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class BlockRegionTest method translate.

// -- translate --------------------------------------------------------------------------------------------------//
@Test
public void translate() {
    BlockRegion region = new BlockRegion(0, 0, 0, 1, 1, 1);
    Vector3i translation = new Vector3i(1, 2, 3);
    assertEquals(new BlockRegion(1, 2, 3, 2, 3, 4), new BlockRegion(region).translate(translation));
    assertEquals(region, new BlockRegion(region).translate(translation).translate(translation.negate(new Vector3i())));
}
Also used : Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 28 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class BlockRegionTest method testBoxOfBlocksRegion.

@Test
public void testBoxOfBlocksRegion() {
    BlockRegion region = new BlockRegion(new Vector3i(0, 0, 0), new Vector3i(1, 1, 1));
    List<Vector3ic> actual = new ArrayList<>();
    for (Vector3ic vector3ic : region) {
        actual.add(new Vector3i(vector3ic));
    }
    Assertions.assertEquals(8, actual.size());
    Assertions.assertEquals(new HashSet<>(expectedPositions(region)), new HashSet<>(actual));
}
Also used : Vector3ic(org.joml.Vector3ic) Vector3i(org.joml.Vector3i) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 29 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class BlockRegionTest method createEncompassing.

@ParameterizedTest
@MethodSource("createEncompassingArgs")
public void createEncompassing(Vector3i expectedSize, Collection<Vector3i> positions) {
    Vector3i min = positions.stream().reduce(new Vector3i(Integer.MAX_VALUE), Vector3i::min);
    Vector3i max = positions.stream().reduce(new Vector3i(Integer.MIN_VALUE), Vector3i::max);
    BlockRegion region = positions.stream().reduce(new BlockRegion(BlockRegion.INVALID), BlockRegion::union, BlockRegion::union);
    assertEquals(min, region.getMin(new Vector3i()), "min of " + region);
    assertEquals(max, region.getMax(new Vector3i()), "max of " + region);
    assertEquals(expectedSize, region.getSize(new Vector3i()), "size of " + region);
}
Also used : Vector3i(org.joml.Vector3i) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 30 with Vector3i

use of org.joml.Vector3i in project Terasology by MovingBlocks.

the class BlockRegionTest method testSimpleIntersect.

@Test
public void testSimpleIntersect() {
    BlockRegion region1 = new BlockRegion(new Vector3i(), new Vector3i(32, 32, 32));
    BlockRegion region2 = new BlockRegion(new Vector3i(1, 1, 1), new Vector3i(17, 17, 17));
    assertEquals(region2, new BlockRegion(region1).intersect(region2).get());
}
Also used : Vector3i(org.joml.Vector3i) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

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