Skip to content

Commit

Permalink
clarifying comment for #172
Browse files Browse the repository at this point in the history
  • Loading branch information
F Zotter committed Oct 11, 2024
1 parent 181f5c3 commit 1216902
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Intern/rayx-core/src/Shader/Collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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-space 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 point toward the 'inside' of the overall shape.
// Depending on whether the surface is hit from the 'outside' or 'inside',
// 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;
}
Expand Down

0 comments on commit 1216902

Please sign in to comment.