Cache x coordinate multiplier for CollisionUtil#sliceShapeOptimised

This is consistent with how the rest of the collision patch iterates
the voxel bitset.
This commit is contained in:
Spottedleaf
2024-08-12 16:56:26 -07:00
parent e68d381fc5
commit a749c7282b
2 changed files with 7 additions and 5 deletions

View File

@@ -103,8 +103,8 @@ public abstract class PoiManagerMixin extends SectionStorage<Object> implements
*/
@Overwrite
public int sectionsToVillage(final SectionPos pos) {
this.villageDistanceTracker.propagateUpdates(); // Paper - replace distance tracking util
return convertBetweenLevels(this.villageDistanceTracker.getLevel(CoordinateUtils.getChunkSectionKey(pos))); // Paper - replace distance tracking util
this.villageDistanceTracker.propagateUpdates();
return convertBetweenLevels(this.villageDistanceTracker.getLevel(CoordinateUtils.getChunkSectionKey(pos)));
}
/**

View File

@@ -331,13 +331,15 @@ public final class CollisionUtil {
final BitSetDiscreteVoxelShape shape = new BitSetDiscreteVoxelShape(local_len_x, local_len_y, local_len_z);
final int idx_off = shape_sz + shape_sy*size_z + shape_sx*(size_z*size_y);
final int bitset_mul_x = size_z*size_y;
final int idx_off = shape_sz + shape_sy*size_z + shape_sx*bitset_mul_x;
final int shape_mul_x = local_len_y*local_len_z;
for (int x = 0; x < local_len_x; ++x) {
boolean setX = false;
for (int y = 0; y < local_len_y; ++y) {
boolean setY = false;
for (int z = 0; z < local_len_z; ++z) {
final int unslicedIdx = idx_off + z + y*size_z + x*(size_z*size_y);
final int unslicedIdx = idx_off + z + y*size_z + x*bitset_mul_x;
if ((bitset[unslicedIdx >>> 6] & (1L << unslicedIdx)) == 0L) {
continue;
}
@@ -348,7 +350,7 @@ public final class CollisionUtil {
shape.zMax = Math.max(shape.zMax, z + 1);
shape.storage.set(
z + y*local_len_z + x*(local_len_y*local_len_z)
z + y*local_len_z + x*shape_mul_x
);
}