[Bf-blender-cvs] [7263fbd] gooseberry: Fix T43578: Beauty Triangulation would hang in infinite loop, due to float rpecision issue.

Bastien Montagne noreply at git.blender.org
Fri Feb 6 16:43:14 CET 2015


Commit: 7263fbd7a6ce7fb98d01618bdbad74c7658e8dbd
Author: Bastien Montagne
Date:   Fri Feb 6 15:03:51 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB7263fbd7a6ce7fb98d01618bdbad74c7658e8dbd

Fix T43578: Beauty Triangulation would hang in infinite loop, due to float rpecision issue.

Only recompute if cost is below -FLT_EPSILON, we can get cases where both cases generate
very tiny negative costs (see 'Cylinder.004' mesh in .blend attached to report).

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

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

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

diff --git a/source/blender/blenlib/intern/polyfill2d_beautify.c b/source/blender/blenlib/intern/polyfill2d_beautify.c
index 7914b7c..1f4b598 100644
--- a/source/blender/blenlib/intern/polyfill2d_beautify.c
+++ b/source/blender/blenlib/intern/polyfill2d_beautify.c
@@ -237,7 +237,10 @@ static void polyedge_beauty_cost_update_single(
 	{
 		/* recalculate edge */
 		const float cost = polyedge_rotate_beauty_calc(coords, tris, e);
-		if (cost < 0.0f) {
+		/* We can get cases where both choices generate very small negative costs, which leads to infinite loop.
+		 * Anyway, costs above that are not worth recomputing, maybe we could even optimze it to a smaller limit?
+		 * See T43578. */
+		if (cost < -FLT_EPSILON) {
 			eheap_table[i] = BLI_heap_insert(eheap, cost, e);
 		}
 		else {




More information about the Bf-blender-cvs mailing list