diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-06-29 04:48:50 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-06-29 04:51:36 +0300 |
commit | 20f634cfc21086777164dd1ba1287181c037d911 (patch) | |
tree | ac56fa5c266c562e3349ef2be9ba1db2ac012719 /source/blender | |
parent | a21549f822420d418c1b1189bfb2678f52f44e1f (diff) |
Fix T48755: Crash UV unwrapping
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_parametrizer.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 59f9cd16908..4713ea73b58 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -740,6 +740,16 @@ static PVert *p_vert_add(PHandle *handle, PHashKey key, const float co[3], PEdge { PVert *v = (PVert *)BLI_memarena_alloc(handle->arena, sizeof(*v)); copy_v3_v3(v->co, co); + + /* Sanity check, a single nan/inf point causes the entire result to be invalid. + * Note that values within the calculation may _become_ non-finite, + * so the rest of the code still needs to take this possability into account. */ + for (int i = 0; i < 3; i++) { + if (UNLIKELY(!finite(v->co[i]))) { + v->co[i] = 0.0f; + } + } + v->u.key = key; v->edge = e; v->flag = 0; @@ -3040,8 +3050,10 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf) p_chart_boundaries(chart, NULL, &outer); - if (!p_chart_symmetry_pins(chart, outer, &pin1, &pin2)) + /* outer can be NULL with non-finite coords. */ + if (outer && !p_chart_symmetry_pins(chart, outer, &pin1, &pin2)) { p_chart_extrema_verts(chart, &pin1, &pin2); + } chart->u.lscm.pin1 = pin1; chart->u.lscm.pin2 = pin2; |