Skip to content

Commit f7b69cf

Browse files
zzueggclaude
andauthored
fix: correct parallel projection frustum plane normals for left/right (jMonkeyEngine#2640)
getLeft() returns up×direction but fromFrame() uses direction×up as the view matrix X axis. These are negatives of each other. The hardcoded parallel projection coefficients (1 for left, -1 for right) built plane normals from getLeft(), causing them to point opposite to the view matrix. This made frustum culling reject visible geometry for any camera with a non-standard orientation (e.g. looking along +Z) or asymmetric frustum values in parallel projection mode. Fix: negate the left/right coefficients so plane normals align with the view matrix's X axis. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8cdd545 commit f7b69cf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

jme3-core/src/main/java/com/jme3/renderer/Camera.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,10 +1344,14 @@ public void onFrustumChange() {
13441344
coeffTop[0] = -frustumNear * inverseLength;
13451345
coeffTop[1] = frustumTop * inverseLength;
13461346
} else {
1347-
coeffLeft[0] = 1;
1347+
// getLeft() returns up×direction, but the view matrix (fromFrame)
1348+
// uses direction×up = -getLeft() as its X axis. Negate the left/right
1349+
// coefficients so the frustum plane normals match the view matrix,
1350+
// giving correct culling for any camera orientation.
1351+
coeffLeft[0] = -1;
13481352
coeffLeft[1] = 0;
13491353

1350-
coeffRight[0] = -1;
1354+
coeffRight[0] = 1;
13511355
coeffRight[1] = 0;
13521356

13531357
coeffBottom[0] = 1;

0 commit comments

Comments
 (0)