mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Fix #6779
This commit is contained in:
parent
a30ee99728
commit
781e8f5f00
1 changed files with 66 additions and 38 deletions
|
@ -380,7 +380,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
+ return ret;
|
+ return ret;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ final List<AABB> boxes = shape.toAabbs();
|
+ final List<AABB> boxes = shape.toAabbsStrict();
|
||||||
+
|
+
|
||||||
+ boolean ret = false;
|
+ boolean ret = false;
|
||||||
+
|
+
|
||||||
|
@ -416,7 +416,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ } else {
|
+ } else {
|
||||||
+ final List<AABB> boxes = shape.toAabbs();
|
+ final List<AABB> boxes = shape.toAabbsStrict();
|
||||||
+ for (int i = 0, len = boxes.size(); i < len; ++i) {
|
+ for (int i = 0, len = boxes.size(); i < len; ++i) {
|
||||||
+ final AABB box = boxes.get(i);
|
+ final AABB box = boxes.get(i);
|
||||||
+ if (!isEmpty(box)) {
|
+ if (!isEmpty(box)) {
|
||||||
|
@ -845,6 +845,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
|
+ public List<AABB> toAabbsStrict() {
|
||||||
|
+ return this.toAabbs();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
+ protected int findIndex(Direction.Axis enumdirection_enumaxis, double d0) { // findPointIndexAfterOffset
|
+ protected int findIndex(Direction.Axis enumdirection_enumaxis, double d0) { // findPointIndexAfterOffset
|
||||||
+ switch (enumdirection_enumaxis.ordinal()) {
|
+ switch (enumdirection_enumaxis.ordinal()) {
|
||||||
+ case 0:
|
+ case 0:
|
||||||
|
@ -1269,9 +1274,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
ArrayVoxelShape(DiscreteVoxelShape shape, DoubleList xPoints, DoubleList yPoints, DoubleList zPoints) {
|
ArrayVoxelShape(DiscreteVoxelShape shape, DoubleList xPoints, DoubleList yPoints, DoubleList zPoints) {
|
||||||
+ // Paper start - optimise multi-aabb shapes
|
+ // Paper start - optimise multi-aabb shapes
|
||||||
+ this(shape, xPoints, yPoints, zPoints, null, 0.0, 0.0, 0.0);
|
+ this(shape, xPoints, yPoints, zPoints, null, null, 0.0, 0.0, 0.0);
|
||||||
+ }
|
+ }
|
||||||
+ ArrayVoxelShape(DiscreteVoxelShape shape, DoubleList xPoints, DoubleList yPoints, DoubleList zPoints, net.minecraft.world.phys.AABB[] boundingBoxesRepresentation, double offsetX, double offsetY, double offsetZ) {
|
+ ArrayVoxelShape(DiscreteVoxelShape shape, DoubleList xPoints, DoubleList yPoints, DoubleList zPoints, net.minecraft.world.phys.AABB[] toAABBs, net.minecraft.world.phys.AABB[] boundingBoxesRepresentation, double offsetX, double offsetY, double offsetZ) {
|
||||||
+ // Paper end - optimise multi-aabb shapes
|
+ // Paper end - optimise multi-aabb shapes
|
||||||
super(shape);
|
super(shape);
|
||||||
int i = shape.getXSize() + 1;
|
int i = shape.getXSize() + 1;
|
||||||
|
@ -1281,7 +1286,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
throw (IllegalArgumentException)Util.pauseInIde(new IllegalArgumentException("Lengths of point arrays must be consistent with the size of the VoxelShape."));
|
throw (IllegalArgumentException)Util.pauseInIde(new IllegalArgumentException("Lengths of point arrays must be consistent with the size of the VoxelShape."));
|
||||||
}
|
}
|
||||||
+ // Paper start - optimise multi-aabb shapes
|
+ // Paper start - optimise multi-aabb shapes
|
||||||
+ this.boundingBoxesRepresentation = boundingBoxesRepresentation == null ? this.toAabbs().toArray(EMPTY) : boundingBoxesRepresentation;
|
+
|
||||||
|
+ this.toAABBs = toAABBs == null ? this.toAabbs().toArray(EMPTY) : toAABBs;
|
||||||
|
+ this.boundingBoxesRepresentation = boundingBoxesRepresentation == null ? this.toAabbsStrict().toArray(EMPTY) : boundingBoxesRepresentation;
|
||||||
+ this.offsetX = offsetX;
|
+ this.offsetX = offsetX;
|
||||||
+ this.offsetY = offsetY;
|
+ this.offsetY = offsetY;
|
||||||
+ this.offsetZ = offsetZ;
|
+ this.offsetZ = offsetZ;
|
||||||
|
@ -1318,6 +1325,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
+ static final net.minecraft.world.phys.AABB[] EMPTY = new net.minecraft.world.phys.AABB[0];
|
+ static final net.minecraft.world.phys.AABB[] EMPTY = new net.minecraft.world.phys.AABB[0];
|
||||||
+ final net.minecraft.world.phys.AABB[] boundingBoxesRepresentation;
|
+ final net.minecraft.world.phys.AABB[] boundingBoxesRepresentation;
|
||||||
|
+ final net.minecraft.world.phys.AABB[] toAABBs;
|
||||||
+
|
+
|
||||||
+ final double offsetX;
|
+ final double offsetX;
|
||||||
+ final double offsetY;
|
+ final double offsetY;
|
||||||
|
@ -1341,9 +1349,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public java.util.List<net.minecraft.world.phys.AABB> toAabbs() {
|
+ public java.util.List<net.minecraft.world.phys.AABB> toAabbs() {
|
||||||
+ if (this.boundingBoxesRepresentation == null) {
|
+ if (this.toAABBs == null) {
|
||||||
+ return super.toAabbs();
|
+ return super.toAabbs();
|
||||||
+ }
|
+ }
|
||||||
|
+ java.util.List<net.minecraft.world.phys.AABB> ret = new java.util.ArrayList<>(this.toAABBs.length);
|
||||||
|
+
|
||||||
|
+ double offX = this.offsetX;
|
||||||
|
+ double offY = this.offsetY;
|
||||||
|
+ double offZ = this.offsetZ;
|
||||||
|
+
|
||||||
|
+ for (net.minecraft.world.phys.AABB boundingBox : this.toAABBs) {
|
||||||
|
+ ret.add(boundingBox.move(offX, offY, offZ));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public java.util.List<net.minecraft.world.phys.AABB> toAabbsStrict() {
|
||||||
|
+ if (this.boundingBoxesRepresentation == null) {
|
||||||
|
+ return super.toAabbsStrict();
|
||||||
|
+ }
|
||||||
+ java.util.List<net.minecraft.world.phys.AABB> ret = new java.util.ArrayList<>(this.boundingBoxesRepresentation.length);
|
+ java.util.List<net.minecraft.world.phys.AABB> ret = new java.util.ArrayList<>(this.boundingBoxesRepresentation.length);
|
||||||
+
|
+
|
||||||
+ double offX = this.offsetX;
|
+ double offX = this.offsetX;
|
||||||
|
@ -1383,7 +1409,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ zPoints = new DoubleListOffsetExposed(getList(this.zs), offsetZ = z);
|
+ zPoints = new DoubleListOffsetExposed(getList(this.zs), offsetZ = z);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ return new ArrayVoxelShape(this.shape, xPoints, yPoints, zPoints, this.boundingBoxesRepresentation, offsetX, offsetY, offsetZ);
|
+ return new ArrayVoxelShape(this.shape, xPoints, yPoints, zPoints, this.toAABBs, this.boundingBoxesRepresentation, offsetX, offsetY, offsetZ);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
|
@ -1467,38 +1493,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
public static VoxelShape box(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
public static VoxelShape box(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
||||||
@@ -0,0 +0,0 @@ public final class Shapes {
|
@@ -0,0 +0,0 @@ public final class Shapes {
|
||||||
}
|
return new CubeVoxelShape(bitSetDiscreteVoxelShape);
|
||||||
|
}
|
||||||
public static VoxelShape create(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
} else {
|
||||||
- if (!(maxX - minX < 1.0E-7D) && !(maxY - minY < 1.0E-7D) && !(maxZ - minZ < 1.0E-7D)) {
|
|
||||||
- int i = findBits(minX, maxX);
|
|
||||||
- int j = findBits(minY, maxY);
|
|
||||||
- int k = findBits(minZ, maxZ);
|
|
||||||
- if (i >= 0 && j >= 0 && k >= 0) {
|
|
||||||
- if (i == 0 && j == 0 && k == 0) {
|
|
||||||
- return block();
|
|
||||||
- } else {
|
|
||||||
- int l = 1 << i;
|
|
||||||
- int m = 1 << j;
|
|
||||||
- int n = 1 << k;
|
|
||||||
- BitSetDiscreteVoxelShape bitSetDiscreteVoxelShape = BitSetDiscreteVoxelShape.withFilledBounds(l, m, n, (int)Math.round(minX * (double)l), (int)Math.round(minY * (double)m), (int)Math.round(minZ * (double)n), (int)Math.round(maxX * (double)l), (int)Math.round(maxY * (double)m), (int)Math.round(maxZ * (double)n));
|
|
||||||
- return new CubeVoxelShape(bitSetDiscreteVoxelShape);
|
|
||||||
- }
|
|
||||||
- } else {
|
|
||||||
- return new ArrayVoxelShape(BLOCK.shape, (DoubleList)DoubleArrayList.wrap(new double[]{minX, maxX}), (DoubleList)DoubleArrayList.wrap(new double[]{minY, maxY}), (DoubleList)DoubleArrayList.wrap(new double[]{minZ, maxZ}));
|
- return new ArrayVoxelShape(BLOCK.shape, (DoubleList)DoubleArrayList.wrap(new double[]{minX, maxX}), (DoubleList)DoubleArrayList.wrap(new double[]{minY, maxY}), (DoubleList)DoubleArrayList.wrap(new double[]{minZ, maxZ}));
|
||||||
- }
|
+ return new io.papermc.paper.voxel.AABBVoxelShape(new AABB(minX, minY, minZ, maxX, maxY, maxZ)); // Paper
|
||||||
- } else {
|
}
|
||||||
- return empty();
|
} else {
|
||||||
- }
|
return empty();
|
||||||
+ return new io.papermc.paper.voxel.AABBVoxelShape(new AABB(minX, minY, minZ, maxX, maxY, maxZ)); // Paper
|
|
||||||
}
|
|
||||||
|
|
||||||
public static VoxelShape create(AABB box) {
|
|
||||||
- return create(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
|
|
||||||
+ return new io.papermc.paper.voxel.AABBVoxelShape(box); // Paper
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
@@ -0,0 +0,0 @@ public final class Shapes {
|
@@ -0,0 +0,0 @@ public final class Shapes {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1651,6 +1653,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
this.shape = voxels;
|
this.shape = voxels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class VoxelShape {
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start - strict AABB retrieval
|
||||||
|
+ public void forAllBoxesStrict(Shapes.DoubleLineConsumer doubleLineConsumer) {
|
||||||
|
+ DoubleList doubleList = this.getCoords(Direction.Axis.X);
|
||||||
|
+ DoubleList doubleList2 = this.getCoords(Direction.Axis.Y);
|
||||||
|
+ DoubleList doubleList3 = this.getCoords(Direction.Axis.Z);
|
||||||
|
+ this.shape.forAllBoxes((i, j, k, l, m, n) -> {
|
||||||
|
+ doubleLineConsumer.consume(doubleList.getDouble(i), doubleList2.getDouble(j), doubleList3.getDouble(k), doubleList.getDouble(l), doubleList2.getDouble(m), doubleList3.getDouble(n));
|
||||||
|
+ }, false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public List<AABB> toAabbsStrict() {
|
||||||
|
+ List<AABB> list = Lists.newArrayList();
|
||||||
|
+ this.forAllBoxesStrict((x1, y1, z1, x2, y2, z2) -> {
|
||||||
|
+ list.add(new AABB(x1, y1, z1, x2, y2, z2));
|
||||||
|
+ });
|
||||||
|
+ return list;
|
||||||
|
+ }
|
||||||
|
+ // Paper end - strict AABB retrieval
|
||||||
|
+
|
||||||
|
public List<AABB> toAabbs() {
|
||||||
|
List<AABB> list = Lists.newArrayList();
|
||||||
|
this.forAllBoxes((x1, y1, z1, x2, y2, z2) -> {
|
||||||
@@ -0,0 +0,0 @@ public abstract class VoxelShape {
|
@@ -0,0 +0,0 @@ public abstract class VoxelShape {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue