From 98e8216da1ecab6877223857b2d882eab2a578c0 Mon Sep 17 00:00:00 2001 From: F Zotter Date: Fri, 11 Oct 2024 14:48:35 +0200 Subject: [PATCH] clarifying comment for #172 --- Intern/rayx-core/src/Shader/Collision.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Intern/rayx-core/src/Shader/Collision.cpp b/Intern/rayx-core/src/Shader/Collision.cpp index b4aa6384..40148f0d 100644 --- a/Intern/rayx-core/src/Shader/Collision.cpp +++ b/Intern/rayx-core/src/Shader/Collision.cpp @@ -485,11 +485,12 @@ Collision RAYX_API findCollisionInElementCoords(Ray r, Surface surface, Cutout c if (!inCutout(cutout, col.hitpoint.x, col.hitpoint.z)) { col.found = false; } - - // Both r.m_direction and col.normal are in element-coordinates. - // The collision normal should point "out of the surface", i.e. in the direction that the ray came from. - // In other words we want `dot(r.m_direction, col.normal) <= 0`. - // Later on, we'd like to remove this hotfix, and each individual get*Collision function should already satisfy this constraint. + // Both r.m_direction and col.normal are in element coordinates. + // The collision normal should point 'outward from the surface', meaning it should oppose the ray's direction. + // In other words, we want `dot(r.m_direction, col.normal) <= 0`. + // The default normal may oppose the concave part of the overall shape + // Depending on whether the element is hit on a concave or convex surface, + // we flip the normal to ensure it points against the ray's direction. if (dot(r.m_direction, col.normal) > 0.0) { col.normal = col.normal * -1.0; }