allow far plane to go further out

This commit is contained in:
David Rose 2010-06-08 22:49:44 +00:00
parent 864f8c4f08
commit 9d14c7867b
2 changed files with 10 additions and 2 deletions

View File

@ -369,6 +369,14 @@ ConfigVariableDouble default_far
("default-far", 100000.0,
PRC_DESC("The default far clipping distance for all cameras."));
ConfigVariableDouble lens_far_limit
("lens-far-limit", 0.0000001,
PRC_DESC("This number is used to reduce the effect of numeric inaccuracies "
"in Lens::extrude(). It should be a very small, positive number, "
"almost zero; set it larger if Lens::extrude() returns values "
"that appear meaningless, and set it smaller if you appear to be "
"unable to move the far plane out far enough."));
ConfigVariableDouble default_fov
("default-fov", 30.0,
PRC_DESC("The default field of view in degrees for all cameras. This is "

View File

@ -1360,7 +1360,7 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point)
LVecBase4f full(point2d[0], point2d[1], -1.0f, 1.0f);
full = projection_mat_inv.xform(full);
float recip_full3 = 1.0f / max(full[3], 0.00001f);
float recip_full3 = 1.0 / max((double)full[3], (double)lens_far_limit);
near_point.set(full[0] * recip_full3,
full[1] * recip_full3,
full[2] * recip_full3);
@ -1374,7 +1374,7 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point)
// past infinity and comes back in behind the lens, which is just
// crazy. Truncating it to zero keeps the far plane from moving
// too far out.
float recip_full3 = 1.0f / max(full[3], 0.00001f);
float recip_full3 = 1.0 / max((double)full[3], (double)lens_far_limit);
far_point.set(full[0] * recip_full3,
full[1] * recip_full3,
full[2] * recip_full3);