diff --git a/filament/src/Camera.cpp b/filament/src/Camera.cpp index 17f66529b3..863bd03af4 100644 --- a/filament/src/Camera.cpp +++ b/filament/src/Camera.cpp @@ -20,6 +20,8 @@ #include +#include + #include #include #include @@ -34,6 +36,10 @@ using namespace math; void Camera::setProjection(double const fovInDegrees, double const aspect, double const near, double const far, Fov const direction) { + FILAMENT_CHECK_PRECONDITION(near > 0 && far > near) + << "Camera preconditions not met in setProjection(): near <= 0 or far <= near, near=" + << near << ", far=" << far; + setCustomProjection( projection(direction, fovInDegrees, aspect, near), projection(direction, fovInDegrees, aspect, near, far), @@ -43,6 +49,10 @@ void Camera::setProjection(double const fovInDegrees, double const aspect, void Camera::setLensProjection(double const focalLengthInMillimeters, double const aspect, double const near, double const far) { + FILAMENT_CHECK_PRECONDITION(near > 0 && far > near) + << "Camera preconditions not met in setLensProjection(): near <= 0 or far <= near, near=" + << near << ", far=" << far; + setCustomProjection( projection(focalLengthInMillimeters, aspect, near), projection(focalLengthInMillimeters, aspect, near, far), diff --git a/filament/src/details/Camera.cpp b/filament/src/details/Camera.cpp index 1e09c22ff2..d006e22d4c 100644 --- a/filament/src/details/Camera.cpp +++ b/filament/src/details/Camera.cpp @@ -95,13 +95,8 @@ mat4 FCamera::projection(double const focalLengthInMillimeters, void UTILS_NOINLINE FCamera::setCustomProjection(mat4 const& projection, mat4 const& projectionForCulling, double const near, double const far) noexcept { - FILAMENT_CHECK_PRECONDITION(near > 0) - << "Camera preconditions not met in setCustomProjection(): near <= 0, near=" << near; - auto const& featureFlags = mEngine.features.engine.debug; - FILAMENT_FLAG_GUARDED_CHECK_PRECONDITION(far > near, - featureFlags.assert_camera_projection_near_far) - << "Camera preconditions not met in setCustomProjection(): far <= near, near=" - << near << ", far=" << far; + FILAMENT_CHECK_PRECONDITION(near != far) + << "Camera preconditions not met in setCustomProjection(): near = far = " << near; for (auto& eyeProjection: mEyeProjection) { eyeProjection = projection; @@ -115,13 +110,8 @@ void UTILS_NOINLINE FCamera::setCustomEyeProjection(mat4 const* projection, size mat4 const& projectionForCulling, double const near, double const far) { const Engine::Config& config = mEngine.getConfig(); - FILAMENT_CHECK_PRECONDITION(near > 0) - << "Camera preconditions not met in setCustomEyeProjection(): near <= 0, near=" << near; - auto const& featureFlags = mEngine.features.engine.debug; - FILAMENT_FLAG_GUARDED_CHECK_PRECONDITION(far > near, - featureFlags.assert_camera_projection_near_far) - << "Camera preconditions not met in setCustomEyeProjection(): far <= near, near=" - << near << ", far=" << far; + FILAMENT_CHECK_PRECONDITION(near != far) + << "Camera preconditions not met in setCustomEyeProjection(): near = far = " << near; FILAMENT_CHECK_PRECONDITION(count >= config.stereoscopicEyeCount) << "All eye projections must be supplied together, count must be >= " diff --git a/filament/src/details/Engine.h b/filament/src/details/Engine.h index 4923ac1567..83c731f324 100644 --- a/filament/src/details/Engine.h +++ b/filament/src/details/Engine.h @@ -778,7 +778,6 @@ public: bool assert_material_instance_texture_descriptor_set_compatible = CORRECTNESS_ASSERTION_DEFAULT; bool assert_texture_can_generate_mipmap = CORRECTNESS_ASSERTION_DEFAULT; - bool assert_camera_projection_near_far = CORRECTNESS_ASSERTION_DEFAULT; } debug; struct { bool disable_gpu_frame_complete_metric = true; @@ -848,9 +847,6 @@ public: { "engine.debug.assert_texture_can_generate_mipmap", "Assert if a texture has the correct usage set for generating mipmaps.", &features.engine.debug.assert_texture_can_generate_mipmap, false }, - { "engine.debug.assert_camera_projection_near_far", - "Assert that the near plane is smaller than the far plane.", - &features.engine.debug.assert_camera_projection_near_far, false }, { "material.check_crc32_after_loading", "Verify the checksum of package data when a material is loaded.", &features.material.check_crc32_after_loading, false },