[Bf-blender-cvs] [2191590] master: Polyfill: simply re-ordering checks gives ~%15 speedup

Campbell Barton noreply at git.blender.org
Tue May 20 09:22:22 CEST 2014


Commit: 21915907114c4dcc5ebc286493331170ac62c2df
Author: Campbell Barton
Date:   Tue May 20 17:15:12 2014 +1000
https://developer.blender.org/rB21915907114c4dcc5ebc286493331170ac62c2df

Polyfill: simply re-ordering checks gives ~%15 speedup

===================================================================

M	source/blender/blenlib/intern/polyfill2d.c

===================================================================

diff --git a/source/blender/blenlib/intern/polyfill2d.c b/source/blender/blenlib/intern/polyfill2d.c
index 34aad5c..629c9ea 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;
 			}




More information about the Bf-blender-cvs mailing list