diff --git a/filament/src/Camera.cpp b/filament/src/Camera.cpp index 900af0ec4d..6ba5e7f261 100644 --- a/filament/src/Camera.cpp +++ b/filament/src/Camera.cpp @@ -22,6 +22,7 @@ #include "details/Engine.h" #include +#include #include @@ -80,25 +81,19 @@ void UTILS_NOINLINE FCamera::setProjection(Camera::Projection projection, double bottom, double top, double near, double far) noexcept { - // we silently make sure our preconditions are verified - // this is to avoid potential inconsistent state in the renderer later. - - if (UTILS_UNLIKELY(left == right)) { - left -= 1; - right += 1; - } - - if (UTILS_UNLIKELY(bottom == top)) { - bottom -= 1; - top += 1; - } - - if (UTILS_UNLIKELY(projection == Projection::PERSPECTIVE && near < 1.0 / 1024.0)) { - near = 1.0 / 1024.0; // about 1mm - } - - if (UTILS_UNLIKELY(near == far)) { - far += 1; + // we make sure our preconditions are verified, using default values, + // to avoid inconsistent states in the renderer later. + if (UTILS_UNLIKELY(left == right || + bottom == top || + (projection == Projection::PERSPECTIVE && (near <= 0 || far <= near)) || + (projection == Projection::ORTHO && (near == far)))) { + PANIC_LOG("Camera preconditions not met. Using default projection."); + left = -0.1; + right = 0.1; + bottom = -0.1; + top = 0.1; + near = 0.1; + far = 100.0; } mat4 p;