Major occlusion search optimizations #34

Merged
embeddedt merged 11 commits from occlusion-opts into stonecutter 2026-08-18 19:59:03 -04:00
3 changed files with 30 additions and 0 deletions
Showing only changes of commit c3d030bcf3 - Show all commits

No files matched your search

@@ -58,6 +58,10 @@ public final class Viewport {
); );
} }
public int intersectCameraRelativeBox(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
return this.frustum.intersectAab(minX, minY, minZ, maxX, maxY, maxZ);
}
public CameraTransform getTransform() { public CameraTransform getTransform() {
return this.transform; return this.transform;
} }
@@ -1,5 +1,22 @@
package org.embeddedt.embeddium.impl.render.viewport.frustum; package org.embeddedt.embeddium.impl.render.viewport.frustum;
public interface Frustum { public interface Frustum {
/**
* Returned when the box is known to be fully inside the frustum.
*/
int FULLY_INSIDE = 0;
/**
* Returned when the box is at least partially within the frustum.
*/
int PARTIALLY_INSIDE = 1;
/**
* Returned when the box is outside the frustum.
*/
int OUTSIDE = 2;
boolean testAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ); boolean testAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ);
default int intersectAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
return testAab(minX, minY, minZ, maxX, maxY, maxZ) ? PARTIALLY_INSIDE : OUTSIDE;
}
} }
@@ -13,4 +13,13 @@ public final class SimpleFrustum implements Frustum {
public boolean testAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) { public boolean testAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
return this.frustum.testAab(minX, minY, minZ, maxX, maxY, maxZ); return this.frustum.testAab(minX, minY, minZ, maxX, maxY, maxZ);
} }
@Override
public int intersectAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
return switch (this.frustum.intersectAab(minX, minY, minZ, maxX, maxY, maxZ)) {
case FrustumIntersection.INSIDE -> Frustum.FULLY_INSIDE;
case FrustumIntersection.INTERSECT -> Frustum.PARTIALLY_INSIDE;
default -> Frustum.OUTSIDE;
};
}
} }