From 07a449b633f34331b79f25d80c90c8eb1bf8fc88 Mon Sep 17 00:00:00 2001 From: Orange Date: Mon, 8 Sep 2025 23:52:35 +0300 Subject: [PATCH] Simplifies raycast early exit condition Combines the infinite length raycast hit check into a single condition. This clarifies the logic and avoids redundant checks for early exit in the ray-triangle intersection test, improving performance. --- source/collision/line_tracer.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/collision/line_tracer.cpp b/source/collision/line_tracer.cpp index 311c99a..f03c445 100644 --- a/source/collision/line_tracer.cpp +++ b/source/collision/line_tracer.cpp @@ -50,12 +50,10 @@ namespace omath::collision const auto t_hit = side_b.dot(q) * inv_det; - if (ray.infinite_length) - { - if (t_hit <= k_epsilon) - return ray.end; - } - else if (t_hit <= k_epsilon || t_hit > 1.0f - k_epsilon) + if (ray.infinite_length && t_hit <= k_epsilon) + return ray.end; + + if (t_hit <= k_epsilon || t_hit > 1.0f - k_epsilon) return ray.end; return ray.start + ray_dir * t_hit;