File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -398,20 +398,19 @@ namespace omath::projection
398398 return true ;
399399 if (data[1 ] < -1 .0f - eps || data[1 ] > 1 .0f + eps)
400400 return true ;
401-
402- // z range depends on the NDC depth convention
401+ return is_ndc_z_value_out_of_bounds (data[3 ]);
402+ }
403+ template <class ZType >
404+ [[nodiscard]]
405+ constexpr static bool is_ndc_z_value_out_of_bounds (const ZType& z_ndc) noexcept
406+ {
407+ constexpr auto eps = std::numeric_limits<float >::epsilon ();
403408 if constexpr (depth_range == NDCDepthRange::ZERO_TO_ONE)
404- {
405- if (data[2 ] < 0 .0f - eps || data[2 ] > 1 .0f + eps)
406- return true ;
407- }
408- else
409- {
410- if (data[2 ] < -1 .0f - eps || data[2 ] > 1 .0f + eps)
411- return true ;
412- }
409+ return z_ndc < 0 .0f - eps || z_ndc > 1 .0f + eps;
410+ if constexpr (depth_range == NDCDepthRange::ZERO_TO_ONE)
411+ return z_ndc < -1 .0f - eps || z_ndc > 1 .0f + eps;
413412
414- return false ;
413+ std::unreachable () ;
415414 }
416415
417416 // NDC REPRESENTATION:
You can’t perform that action at this time.
0 commit comments