diff options
Diffstat (limited to 'source/blender/draw/intern/shaders/common_math_geom_lib.glsl')
-rw-r--r-- | source/blender/draw/intern/shaders/common_math_geom_lib.glsl | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/draw/intern/shaders/common_math_geom_lib.glsl b/source/blender/draw/intern/shaders/common_math_geom_lib.glsl index 6b0a7b028ee..7b701d1d81b 100644 --- a/source/blender/draw/intern/shaders/common_math_geom_lib.glsl +++ b/source/blender/draw/intern/shaders/common_math_geom_lib.glsl @@ -83,6 +83,13 @@ float line_unit_box_intersect_dist(vec3 lineorigin, vec3 linedirection) return min_v3(furthestplane); } +float line_unit_box_intersect_dist_safe(vec3 lineorigin, vec3 linedirection) +{ + vec3 safe_linedirection = max(vec3(1e-8), abs(linedirection)) * + mix(vec3(1.0), -vec3(1.0), lessThan(linedirection, vec3(0.0))); + return line_unit_box_intersect_dist(lineorigin, safe_linedirection); +} + /** \} */ /* ---------------------------------------------------------------------- */ |