Add FrustumIntersectionf.distanceToPlane()
@@ -605,6 +605,33 @@ public class FrustumIntersection {
return plane;
}
+ /**
+ * Compute the signed distance from the given axis-aligned box to the <code>plane</code>.
+ *
+ * @param minX
+ * the x-coordinate of the minimum corner
+ * @param minY
+ * the y-coordinate of the minimum corner
+ * @param minZ
+ * the z-coordinate of the minimum corner
+ * @param maxX
+ * the x-coordinate of the maximum corner
+ * @param maxY
+ * the y-coordinate of the maximum corner
+ * @param maxZ
+ * the z-coordinate of the maximum corner
+ * @param plane
+ * one of
+ * {@link #PLANE_NX}, {@link #PLANE_PX},
+ * {@link #PLANE_NY}, {@link #PLANE_PY},
+ * {@link #PLANE_NZ} and {@link #PLANE_PZ}
+ * @return the signed distance of the axis-aligned box to the plane
+ */
+ public float distanceToPlane(float minX, float minY, float minZ, float maxX, float maxY, float maxZ, int plane) {
+ return planes[plane].x * (planes[plane].x < 0 ? maxX : minX) + planes[plane].y * (planes[plane].y < 0 ? maxY : minY)
+ + planes[plane].z * (planes[plane].z < 0 ? maxZ : minZ) + planes[plane].w;
+ }
+
/**
* Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by <code>this</code> frustum culler
* and, if the box is not inside this frustum, return the index of the plane that culled it.
