diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-06-20 06:47:53 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-06-20 07:39:13 +0300 |
commit | 2d60c496a200288f100c11845ccb196f04e45ba3 (patch) | |
tree | 4f115960d47a2ec92fd584d746da3a9182c87082 /source/blender/blenlib/intern | |
parent | 513f566b40a5bde4d89797aecf7c0ad3e4d1a20b (diff) |
Mesh: minor optimization to concave quad check for tessellation
Use the face normal (when available) for a faster concave quad test.
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 6b1730f8ee8..0a5dc8517d8 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -6218,6 +6218,19 @@ bool is_quad_flip_v3_first_third_fast(const float v1[3], return dot_v3v3(cross_a, cross_b) > 0.0f; } +bool is_quad_flip_v3_first_third_fast_with_normal(const float v1[3], + const float v2[3], + const float v3[3], + const float v4[3], + const float normal[3]) +{ + float dir_v3v1[3], tangent[3]; + sub_v3_v3v3(dir_v3v1, v3, v1); + cross_v3_v3v3(tangent, dir_v3v1, normal); + const float dot = dot_v3v3(v1, tangent); + return (dot_v3v3(v4, tangent) >= dot) || (dot_v3v3(v2, tangent) <= dot); +} + /** * Return the value which the distance between points will need to be scaled by, * to define a handle, given both points are on a perfect circle. |