Browse Source

gobj: support infinite near distance in PerspectiveLens

Useful when rendering with near/far planes flipped around.
rdb 7 years ago
parent
commit
cf240d95c1
1 changed files with 5 additions and 0 deletions
  1. 5 0
      panda/src/gobj/perspectiveLens.cxx

+ 5 - 0
panda/src/gobj/perspectiveLens.cxx

@@ -71,9 +71,14 @@ do_compute_projection_mat(Lens::CData *lens_cdata) {
   PN_stdfloat fNear = do_get_near(lens_cdata);
   PN_stdfloat a, b;
 
+  // Take the limits if either near or far is infinite.
   if (cinf(fFar)) {
     a = 1;
     b = -2 * fNear;
+  } else if (cinf(fNear)) {
+    // This is valid if the near/far planes are inverted.
+    a = -1;
+    b = 2 * fFar;
   } else {
     PN_stdfloat far_minus_near = fFar-fNear;
     a = (fFar + fNear);