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).
This commit is contained in:
Bastien Montagne 2015-02-06 15:03:51 +01:00
parent f4f468fc48
commit 31170ec19e
Notes: blender-bot 2023-02-14 09:30:54 +01:00
Referenced by issue #43578, Triangulation hangs in infinite loop (Export->Collada hangs)
1 changed files with 4 additions and 1 deletions

View File

@ -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 {