Reuse VolmLib's hunk, interpolation and face types and drop the dead util wrappers

Iris carried copies of VolmLib's storage hunks, interpolation statics and HunkFace, plus wrappers nothing used. The storage hunks and IrisInterpolation now extend VolmLib's, Hunk uses VolmLib's HunkFace, and the Iris rangeScale stays so interpolation output does not change. The newly shipped VolmLib classes leave the Bukkit jar's left-out list.

Upstream: 355d7f413 355161408 114cc68a0
This commit is contained in:
piexel committed 2026-11-10 01:16:52 +01:00
1 parent fd936f4dd8
commit 8748d85e37
22 files changed
+105 -755

No files matched your search

@@ -0,0 +1,66 @@
package art.arcane.iris.util.project.hunk.storage;
import art.arcane.iris.util.project.hunk.Hunk;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
public class VolmLibStorageHunkTest {
private static final int WIDTH = 3;
private static final int HEIGHT = 4;
private static final int DEPTH = 5;
@Test
public void everyStorageHunkReadsBackWhatWasWritten() {
assertRoundTrip(new ArrayHunk<Integer>(WIDTH, HEIGHT, DEPTH));
assertRoundTrip(new AtomicHunk<Integer>(WIDTH, HEIGHT, DEPTH));
assertRoundTrip(new SynchronizedArrayHunk<Integer>(WIDTH, HEIGHT, DEPTH));
assertRoundTrip(new AtomicIntegerHunk(WIDTH, HEIGHT, DEPTH));
}
@Test
public void atomicHunksReportAtomic() {
assertTrue(new AtomicHunk<Integer>(WIDTH, HEIGHT, DEPTH).isAtomic());
assertTrue(new AtomicDoubleHunk(WIDTH, HEIGHT, DEPTH).isAtomic());
assertTrue(new AtomicIntegerHunk(WIDTH, HEIGHT, DEPTH).isAtomic());
assertTrue(new AtomicLongHunk(WIDTH, HEIGHT, DEPTH).isAtomic());
}
@Test
public void filledHunkHoldsTheValueEverywhere() {
ArrayHunk<Integer> hunk = new ArrayHunk<>(WIDTH, HEIGHT, DEPTH);
hunk.fill(7);
assertEquals(Integer.valueOf(7), hunk.getRaw(0, 0, 0));
assertEquals(Integer.valueOf(7), hunk.getRaw(WIDTH - 1, HEIGHT - 1, DEPTH - 1));
}
@Test
public void emptyHunkIsRejected() {
assertThrows(RuntimeException.class, () -> new ArrayHunk<Integer>(0, HEIGHT, DEPTH));
}
private static void assertRoundTrip(Hunk<Integer> hunk) {
assertEquals(WIDTH, hunk.getWidth());
assertEquals(HEIGHT, hunk.getHeight());
assertEquals(DEPTH, hunk.getDepth());
for (int x = 0; x < WIDTH; x++) {
for (int y = 0; y < HEIGHT; y++) {
for (int z = 0; z < DEPTH; z++) {
hunk.setRaw(x, y, z, x * 100 + y * 10 + z);
}
}
}
for (int x = 0; x < WIDTH; x++) {
for (int y = 0; y < HEIGHT; y++) {
for (int z = 0; z < DEPTH; z++) {
assertEquals(Integer.valueOf(x * 100 + y * 10 + z), hunk.getRaw(x, y, z));
}
}
}
}
}
@@ -0,0 +1,28 @@
package art.arcane.iris.util.project.interpolation;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class IrisInterpolationRangeScaleTest {
private static final double TOLERANCE = 1e-12;
@Test
public void degenerateSourceRangeKeepsIrisArithmetic() {
assertTrue(Double.isNaN(IrisInterpolation.rangeScale(0, 1, 5, 5, 5)));
assertTrue(Double.isInfinite(IrisInterpolation.rangeScale(0, 1, 5, 5, 6)));
}
@Test
public void rangeScaleMapsAcrossTheRange() {
assertEquals(0.25, IrisInterpolation.rangeScale(0, 1, 0, 8, 2), TOLERANCE);
}
@Test
public void inheritedInterpolationStillBlends() {
assertEquals(2.5, IrisInterpolation.lerp(2, 3, 0.5), TOLERANCE);
assertEquals(1.5, IrisInterpolation.blerp(1, 2, 1, 2, 0.5, 0.5), TOLERANCE);
assertEquals(2.5, IrisInterpolation.hermite(1, 2, 3, 4, 0.5, 0, 0), TOLERANCE);
}
}