diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-05-20 11:15:12 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-05-20 11:21:57 +0400 |
commit | 21915907114c4dcc5ebc286493331170ac62c2df (patch) | |
tree | e92d7bc78dc3201c8d76aa1a22394276ec46d24b /source | |
parent | e2a9923a6b3d86d956ad68a085b32798d4bb773e (diff) |
Polyfill: simply re-ordering checks gives ~%15 speedup
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/intern/polyfill2d.c | 9 |
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; } |