Major occlusion search optimizations #34
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;
|
||||||
}
|
}
|
||||||
|
|||||||
+17
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+9
@@ -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;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user