Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-06-20 06:47:53 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-06-20 07:39:13 +0300
commit2d60c496a200288f100c11845ccb196f04e45ba3 (patch)
tree4f115960d47a2ec92fd584d746da3a9182c87082 /source/blender/blenlib
parent513f566b40a5bde4d89797aecf7c0ad3e4d1a20b (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')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h5
-rw-r--r--source/blender/blenlib/intern/math_geom.c13
2 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index c744c5d13d3..49188964f3b 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -105,6 +105,11 @@ bool is_quad_flip_v3_first_third_fast(const float v1[3],
const float v2[3],
const float v3[3],
const float v4[3]);
+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]);
/********************************* Distance **********************************/
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.