use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class BlockRegionTest method setMinMaxInvalid.
@Test
void setMinMaxInvalid() {
BlockRegion region = new BlockRegion(new Vector3i());
assertThrows(IllegalArgumentException.class, () -> region.minX(2));
assertThrows(IllegalArgumentException.class, () -> region.minY(2));
assertThrows(IllegalArgumentException.class, () -> region.minZ(2));
assertThrows(IllegalArgumentException.class, () -> region.maxX(-1));
assertThrows(IllegalArgumentException.class, () -> region.maxY(-1));
assertThrows(IllegalArgumentException.class, () -> region.maxZ(-1));
}
use of org.joml.Vector3i in project Terasology by MovingBlocks.
the class BlockRegionTest method getMinMax.
@Test
void getMinMax() {
final Vector3i min = new Vector3i(1, 2, 3);
final Vector3i max = new Vector3i(7, 8, 9);
final BlockRegion region = new BlockRegion(min, max);
assertEquals(min, region.getMin(new Vector3i()));
assertEquals(max, region.getMax(new Vector3i()));
assertEquals(min.x, region.minX());
assertEquals(region.minX(), region.minX());
assertEquals(min.y, region.minY());
assertEquals(region.minY(), region.minY());
assertEquals(min.z, region.minZ());
assertEquals(region.minZ(), region.minZ());
assertEquals(max.x, region.maxX());
assertEquals(region.maxX(), region.maxX());
assertEquals(max.y, region.maxY());
assertEquals(region.maxY(), region.maxY());
assertEquals(max.z, region.maxZ());
assertEquals(region.maxZ(), region.maxZ());
}
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));
}
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())));
}
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));
}
Aggregations