Skip to content

Commit d8f1715

Browse files
committed
don't use invert() to invert the modelview matrix in camera()
1 parent 8e7d84c commit d8f1715

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4409,8 +4409,15 @@ public void camera(float eyeX, float eyeY, float eyeZ,
44094409
float tz = -eyeZ;
44104410
modelview.translate(tx, ty, tz);
44114411

4412-
modelviewInv.set(modelview);
4413-
modelviewInv.invert();
4412+
// The initial modelview transformation can be decomposed in a orthogonal
4413+
// matrix (with the inverse simply being the transpose), and a translation.
4414+
// The modelview inverse can then be calculated as follows, without need of
4415+
// employing the more general, slower, inverse() calculation.
4416+
modelviewInv.set(x0, y0, z0, 0,
4417+
x1, y1, z1, 0,
4418+
x2, y2, z2, 0,
4419+
0, 0, 0, 1);
4420+
modelviewInv.translate(-tx, -ty, -tz);
44144421

44154422
camera.set(modelview);
44164423
cameraInv.set(modelviewInv);

0 commit comments

Comments
 (0)