mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 12:52:19 +00:00
SDL GPU backend, TESR Batching/caching API, Tracy Integration (#1993)
This commit is contained in:
1 parent
413df76ad4
commit
8da561d3b6
647 files changed
+60152
-5331
No files matched your search
@@ -3,8 +3,15 @@ package net.coderbot.iris.shadows.frustum;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
public class BoxCuller {
|
||||
private static final double SNAP = 16.0;
|
||||
private static final double PAD = SNAP * 0.5;
|
||||
|
||||
private double maxDistance;
|
||||
|
||||
private double cameraX;
|
||||
private double cameraY;
|
||||
private double cameraZ;
|
||||
|
||||
private double minAllowedX;
|
||||
private double maxAllowedX;
|
||||
private double minAllowedY;
|
||||
@@ -12,21 +19,52 @@ public class BoxCuller {
|
||||
private double minAllowedZ;
|
||||
private double maxAllowedZ;
|
||||
|
||||
private double minRelX;
|
||||
private double maxRelX;
|
||||
private double minRelY;
|
||||
private double maxRelY;
|
||||
private double minRelZ;
|
||||
private double maxRelZ;
|
||||
|
||||
public BoxCuller(double maxDistance) {
|
||||
this.maxDistance = maxDistance;
|
||||
}
|
||||
|
||||
public void setMaxDistance(double maxDistance) {
|
||||
this.maxDistance = maxDistance;
|
||||
computeBounds();
|
||||
}
|
||||
|
||||
public void setPosition(double cameraX, double cameraY, double cameraZ) {
|
||||
this.minAllowedX = cameraX - maxDistance;
|
||||
this.maxAllowedX = cameraX + maxDistance;
|
||||
this.minAllowedY = cameraY - maxDistance;
|
||||
this.maxAllowedY = cameraY + maxDistance;
|
||||
this.minAllowedZ = cameraZ - maxDistance;
|
||||
this.maxAllowedZ = cameraZ + maxDistance;
|
||||
this.cameraX = cameraX;
|
||||
this.cameraY = cameraY;
|
||||
this.cameraZ = cameraZ;
|
||||
computeBounds();
|
||||
}
|
||||
|
||||
private void computeBounds() {
|
||||
final double centerX = snap(cameraX);
|
||||
final double centerY = snap(cameraY);
|
||||
final double centerZ = snap(cameraZ);
|
||||
final double half = maxDistance + PAD;
|
||||
|
||||
this.minAllowedX = centerX - half;
|
||||
this.maxAllowedX = centerX + half;
|
||||
this.minAllowedY = centerY - half;
|
||||
this.maxAllowedY = centerY + half;
|
||||
this.minAllowedZ = centerZ - half;
|
||||
this.maxAllowedZ = centerZ + half;
|
||||
|
||||
this.minRelX = minAllowedX - cameraX;
|
||||
this.maxRelX = maxAllowedX - cameraX;
|
||||
this.minRelY = minAllowedY - cameraY;
|
||||
this.maxRelY = maxAllowedY - cameraY;
|
||||
this.minRelZ = minAllowedZ - cameraZ;
|
||||
this.maxRelZ = maxAllowedZ - cameraZ;
|
||||
}
|
||||
|
||||
private static double snap(double v) {
|
||||
return Math.floor(v / SNAP) * SNAP + SNAP * 0.5;
|
||||
}
|
||||
|
||||
public boolean isCulled(AxisAlignedBB aabb) {
|
||||
@@ -48,14 +86,14 @@ public class BoxCuller {
|
||||
|
||||
// View-relative coordinates version
|
||||
public boolean isCulledViewRelative(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
|
||||
if (maxX < -this.maxDistance || minX > this.maxDistance) {
|
||||
if (maxX < this.minRelX || minX > this.maxRelX) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (maxY < -this.maxDistance || minY > this.maxDistance) {
|
||||
if (maxY < this.minRelY || minY > this.maxRelY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return maxZ < -this.maxDistance || minZ > this.maxDistance;
|
||||
return maxZ < this.minRelZ || minZ > this.maxRelZ;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user