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>2014-05-20 11:15:12 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-05-20 11:21:57 +0400
commit21915907114c4dcc5ebc286493331170ac62c2df (patch)
treee92d7bc78dc3201c8d76aa1a22394276ec46d24b /source/blender/blenlib/intern/polyfill2d.c
parente2a9923a6b3d86d956ad68a085b32798d4bb773e (diff)
Polyfill: simply re-ordering checks gives ~%15 speedup
Diffstat (limited to 'source/blender/blenlib/intern/polyfill2d.c')
-rw-r--r--source/blender/blenlib/intern/polyfill2d.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/polyfill2d.c b/source/blender/blenlib/intern/polyfill2d.c
index 34aad5c07e9..629c9ea6de6 100644
--- a/source/blender/blenlib/intern/polyfill2d.c
+++ b/source/blender/blenlib/intern/polyfill2d.c
@@ -328,9 +328,12 @@ static bool pf_ear_tip_check(PolyFill *pf, const unsigned int index_ear_tip)
/* Because the polygon has clockwise winding order,
* the area sign will be positive if the point is strictly inside.
* It will be 0 on the edge, which we want to include as well. */
- if ((span_tri_v2_sign(v1, v2, v) != CONCAVE) &&
- (span_tri_v2_sign(v2, v3, v) != CONCAVE) &&
- (span_tri_v2_sign(v3, v1, v) != CONCAVE))
+
+ /* note: check (v3, v1) first since it fails _far_ more often then the other 2 checks (those fail equally).
+ * It's logical - the chance is low that points exist on the same side as the ear we're clipping off. */
+ if ((span_tri_v2_sign(v3, v1, v) != CONCAVE) &&
+ (span_tri_v2_sign(v1, v2, v) != CONCAVE) &&
+ (span_tri_v2_sign(v2, v3, v) != CONCAVE))
{
return false;
}