diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-05-01 06:40:53 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-05-01 06:40:53 +0400 |
commit | 77a0d70cdb006a97e82bb11843ef72edc784b250 (patch) | |
tree | 4831a9d5d355bfbcf273ad70c255f2391f745902 /source/blender/editors/uvedit/uvedit_unwrap_ops.c | |
parent | 5c009b5c9e49c575f9d3df3bad7d6517661c6400 (diff) |
fix [#35164] UV unwrapping crash blender
(own fail with misuse of alloca)
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_unwrap_ops.c')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_unwrap_ops.c | 83 |
1 files changed, 46 insertions, 37 deletions
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index dd124edbf6a..8f5580f9384 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -221,7 +221,38 @@ void uvedit_get_aspect(Scene *scene, Object *ob, BMEditMesh *em, float *aspx, fl } } -static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMEditMesh *em, +static void construct_param_handle_face_add(ParamHandle *handle, Scene *scene, BMEditMesh *em, + BMFace *efa, const int cd_loop_uv_offset) +{ + ParamKey key; + ParamKey *vkeys = BLI_array_alloca(vkeys, efa->len); + ParamBool *pin = BLI_array_alloca(pin, efa->len); + ParamBool *select = BLI_array_alloca(select, efa->len); + float **co = BLI_array_alloca(co, efa->len); + float **uv = BLI_array_alloca(uv, efa->len); + int i; + + BMIter liter; + BMLoop *l; + + key = (ParamKey)efa; + + /* let parametrizer split the ngon, it can make better decisions + * about which split is best for unwrapping than scanfill */ + BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) { + MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + + vkeys[i] = (ParamKey)BM_elem_index_get(l->v); + co[i] = l->v->co; + uv[i] = luv->uv; + pin[i] = (luv->flag & MLOOPUV_PINNED) != 0; + select[i] = uvedit_uv_select_test(em, scene, l) != 0; + } + + param_face_add(handle, key, i, vkeys, co, uv, pin, select, efa->no); +} + +static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMEditMesh *em, short implicit, short fill, short sel, short correct_aspect) { @@ -253,48 +284,26 @@ static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMEditMesh rng = BLI_rng_new(0); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - ParamKey key; - ParamKey *vkeys = BLI_array_alloca(vkeys, efa->len); - ParamBool *pin = BLI_array_alloca(pin, efa->len); - ParamBool *select = BLI_array_alloca(select, efa->len); - float **co = BLI_array_alloca(co, efa->len); - float **uv = BLI_array_alloca(uv, efa->len); - int i, lsel; - - if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0)) - continue; - - lsel = 0; - BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - if (uvedit_uv_select_test(em, scene, l)) { - lsel = 1; - break; - } - } - - if (implicit && !lsel) + if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0)) { continue; + } - key = (ParamKey)efa; - - /* let parametrizer split the ngon, it can make better decisions - * about which split is best for unwrapping than scanfill */ - i = 0; - - BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - - vkeys[i] = (ParamKey)BM_elem_index_get(l->v); - co[i] = l->v->co; - uv[i] = luv->uv; - pin[i] = (luv->flag & MLOOPUV_PINNED) != 0; - select[i] = uvedit_uv_select_test(em, scene, l) != 0; + if (implicit) { + bool is_loopsel = false; - i++; + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { + if (uvedit_uv_select_test(em, scene, l)) { + is_loopsel = true; + break; + } + } + if (is_loopsel == false) { + continue; + } } - param_face_add(handle, key, i, vkeys, co, uv, pin, select, efa->no); + construct_param_handle_face_add(handle, scene, em, efa, cd_loop_uv_offset); } if (!implicit) { |