mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-04 15:41:40 +00:00
* perf: SpatialPlayerIndex for isChunkNearPlayer * perf: ensureCapacity with collectTickingChunks * perf: optimize getSlopeDistance * perf: optimize AABB Intersections * perf: implement custom arrays for regions and caches * perf: Improve SortedArraySet sorting (needs testing) * rebase 1.21.4 * perf: optimize ClientBoundLightUpdatePacketData * perf: O(1) Array Writes during Chunk Loading * perf: Optimize LinearPalette (no not the linear format) * perf: Rewrite ConcurrentLongHashSet * rebase 1.21.4 * Fix Multithreaded Tracker (#236) * duke gonna arrest me * i hate git v2 * rebase * dont worry ill change the name of this patch * perf: Rewrite ConcurrentLongHashSet again * perf: Optimize sendChunk * [ci skip] * cleanup * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * cleanup * remove streams on LinearPalette and SerializableChunkData * actually commit them lmao * actually commit them lmao 2 * fix * rebase * perf: clone less (could help with skyblocks) * perf: more unload stuff * perf: manual loop unrolling and bulk copy * initial size for SerializeableChunkData * perf: async chunkSend * cleanup asyncChunkSend * remove experimental tag * rebase --------- Co-authored-by: Creeam <102713261+HaHaWTH@users.noreply.github.com> Co-authored-by: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
70 lines
2.8 KiB
Diff
70 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Sun, 16 Feb 2025 19:03:23 +0100
|
|
Subject: [PATCH] Optimize AABB
|
|
|
|
|
|
diff --git a/net/minecraft/world/phys/AABB.java b/net/minecraft/world/phys/AABB.java
|
|
index f64c04b32dd2d0fe143fc8bf9f498e52beb66a58..3a41291aa9c0d728b54cf962360303750725bc82 100644
|
|
--- a/net/minecraft/world/phys/AABB.java
|
|
+++ b/net/minecraft/world/phys/AABB.java
|
|
@@ -220,13 +220,14 @@ public class AABB {
|
|
}
|
|
|
|
public AABB intersect(AABB other) {
|
|
- double max = Math.max(this.minX, other.minX);
|
|
- double max1 = Math.max(this.minY, other.minY);
|
|
- double max2 = Math.max(this.minZ, other.minZ);
|
|
- double min = Math.min(this.maxX, other.maxX);
|
|
- double min1 = Math.min(this.maxY, other.maxY);
|
|
- double min2 = Math.min(this.maxZ, other.maxZ);
|
|
- return new AABB(max, max1, max2, min, min1, min2);
|
|
+ return new AABB(
|
|
+ this.minX > other.minX ? this.minX : other.minX,
|
|
+ this.minY > other.minY ? this.minY : other.minY,
|
|
+ this.minZ > other.minZ ? this.minZ : other.minZ,
|
|
+ this.maxX < other.maxX ? this.maxX : other.maxX,
|
|
+ this.maxY < other.maxY ? this.maxY : other.maxY,
|
|
+ this.maxZ < other.maxZ ? this.maxZ : other.maxZ
|
|
+ );
|
|
}
|
|
|
|
public AABB minmax(AABB other) {
|
|
@@ -258,16 +259,33 @@ public class AABB {
|
|
}
|
|
|
|
public boolean intersects(AABB other) {
|
|
- return this.intersects(other.minX, other.minY, other.minZ, other.maxX, other.maxY, other.maxZ);
|
|
+ // Removed redundant method call overhead
|
|
+ return this.minX < other.maxX &&
|
|
+ this.maxX > other.minX &&
|
|
+ this.minY < other.maxY &&
|
|
+ this.maxY > other.minY &&
|
|
+ this.minZ < other.maxZ &&
|
|
+ this.maxZ > other.minZ;
|
|
}
|
|
|
|
public boolean intersects(double x1, double y1, double z1, double x2, double y2, double z2) {
|
|
- return this.minX < x2 && this.maxX > x1 && this.minY < y2 && this.maxY > y1 && this.minZ < z2 && this.maxZ > z1;
|
|
+ // No temporary variables needed, direct comparison
|
|
+ return this.minX < x2 &&
|
|
+ this.maxX > x1 &&
|
|
+ this.minY < y2 &&
|
|
+ this.maxY > y1 &&
|
|
+ this.minZ < z2 &&
|
|
+ this.maxZ > z1;
|
|
}
|
|
|
|
public boolean intersects(Vec3 min, Vec3 max) {
|
|
return this.intersects(
|
|
- Math.min(min.x, max.x), Math.min(min.y, max.y), Math.min(min.z, max.z), Math.max(min.x, max.x), Math.max(min.y, max.y), Math.max(min.z, max.z)
|
|
+ min.x < max.x ? min.x : max.x,
|
|
+ min.y < max.y ? min.y : max.y,
|
|
+ min.z < max.z ? min.z : max.z,
|
|
+ min.x > max.x ? min.x : max.x,
|
|
+ min.y > max.y ? min.y : max.y,
|
|
+ min.z > max.z ? min.z : max.z
|
|
);
|
|
}
|
|
|