/** * @param min the min point of the region * @param size the size of the region * @return a new region base on the min point and region size, empty if the size is negative */ public static Region3i createFromMinAndSize(BaseVector3i min, BaseVector3i size) { if (size.x() <= 0 || size.y() <= 0 || size.z() <= 0) { return empty(); } return new Region3i(min, size); }
private Region3i calculateRegion() { LocationComponent loc = entity.getComponent(LocationComponent.class); if (loc != null) { Vector3i extents = new Vector3i(relevanceDistance.x / 2, relevanceDistance.y / 2, relevanceDistance.z / 2); return Region3i.createFromCenterExtents(ChunkMath.calcChunkPos(loc.getWorldPosition()), extents); } return Region3i.empty(); }
/** * Create a region by two point * @param min the min point of the region * @param max the max point of the region * @return a new region base on min and max point */ public static Region3i createFromMinMax(BaseVector3i min, BaseVector3i max) { Vector3i size = new Vector3i(max.x() - min.x() + 1, max.y() - min.y() + 1, max.z() - min.z() + 1); if (size.x <= 0 || size.y <= 0 || size.z <= 0) { return empty(); } return new Region3i(min, size); }
@Test public void testNonTouchingIntersect() { Region3i region1 = Region3i.createFromMinMax(new Vector3i(), new Vector3i(32, 32, 32)); Region3i region2 = Region3i.createFromMinMax(new Vector3i(103, 103, 103), new Vector3i(170, 170, 170)); assertEquals(Region3i.empty(), region1.intersect(region2)); }