Skip to content

Commit ba46c86

Browse files
committed
simplified method
1 parent 3b0470c commit ba46c86

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

include/omath/projection/camera.hpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff 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:

0 commit comments

Comments
 (0)