Fix relative max. Currently finds the minimum of all individual bounding box maximums. Updated to find maximum of all bounding box maximums (#869)

This commit is contained in:
iam 2022-04-04 22:20:46 -04:00 committed by GitHub
parent 5109acac42
commit 50c1083a48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -23,16 +23,16 @@ final class ShapeImpl implements Shape {
// Find bounds
{
double minX = 1, minY = 1, minZ = 1;
double maxX = 1, maxY = 1, maxZ = 1;
double maxX = 0, maxY = 0, maxZ = 0;
for (BoundingBox blockSection : blockSections) {
// Min
if (blockSection.minX() < minX) minX = blockSection.minX();
if (blockSection.minY() < minY) minY = blockSection.minY();
if (blockSection.minZ() < minZ) minZ = blockSection.minZ();
// Max
if (blockSection.maxX() < maxX) maxX = blockSection.maxX();
if (blockSection.maxY() < maxY) maxY = blockSection.maxY();
if (blockSection.maxZ() < maxZ) maxZ = blockSection.maxZ();
if (blockSection.maxX() > maxX) maxX = blockSection.maxX();
if (blockSection.maxY() > maxY) maxY = blockSection.maxY();
if (blockSection.maxZ() > maxZ) maxZ = blockSection.maxZ();
}
this.relativeStart = new Vec(minX, minY, minZ);
this.relativeEnd = new Vec(maxX, maxY, maxZ);

View File

@ -83,6 +83,6 @@ public class BlockTest {
Point end = Block.LANTERN.registry().collisionShape().relativeEnd();
assertEquals(start, new Vec(0.312, 0, 0.312));
assertEquals(end, new Vec(0.625, 0.437, 0.625));
assertEquals(end, new Vec(0.687, 0.562, 0.687));
}
}