mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-02 13:31:41 +01:00
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:
parent
5109acac42
commit
50c1083a48
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user