diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-28 18:18:04 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-28 18:18:04 +0400 |
commit | 1ba5db129b27cec4cf7c9ceca549e1dd0746d001 (patch) | |
tree | 8dcfea142c2ca7f42a553b3b33f309b8e5950f42 /source/blender/editors | |
parent | c8c743b60947ca4a5ba85d66b2abccf60c504a53 (diff) |
recent fix for #31581 could crash when doing edge slide on a mesh with no UV's.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/transform/transform.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 4dee3514142..928b9c2fc62 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4992,6 +4992,7 @@ void projectSVData(TransInfo *t, int final) BMEditMesh *em = sld->em; SmallHash visit; int i; + short has_uv; if (!em) return; @@ -5004,6 +5005,8 @@ void projectSVData(TransInfo *t, int final) if (em->bm->shapenr > 1) return; + has_uv = CustomData_has_layer(&(em->bm->ldata), CD_MLOOPUV); + BLI_smallhash_init(&visit); for (i = 0, sv = sld->sv; i < sld->totsv; sv++, i++) { @@ -5011,8 +5014,6 @@ void projectSVData(TransInfo *t, int final) BMFace *f; BMIter liter_v; BMLoop *l_v; - float uv_med[2] = {0.0, 0.0}; - int tot_loops = 0; /* BMESH_TODO, this interpolates between vertex/loops which are not moved * (are only apart of a face attached to a slide vert), couldn't we iterate BM_LOOPS_OF_VERT @@ -5141,17 +5142,22 @@ void projectSVData(TransInfo *t, int final) /* make sure every loop of the vertex has identical uv data. Use this temporarily to * fix #31581 until proper data correction/ support for islands is done */ - BM_ITER_ELEM (l_v, &liter_v, sv->v, BM_LOOPS_OF_VERT) { - MLoopUV *uv = CustomData_bmesh_get(&em->bm->ldata, l_v->head.data, CD_MLOOPUV); - add_v2_v2(uv_med, uv->uv); - tot_loops++; - } + /* XXX - this only does the active UV layer which is not really good, should do _all_ uv's - campbell */ + if (has_uv) { + float uv_med[2] = {0.0, 0.0}; + int tot_loops = 0; + BM_ITER_ELEM (l_v, &liter_v, sv->v, BM_LOOPS_OF_VERT) { + MLoopUV *uv = CustomData_bmesh_get(&em->bm->ldata, l_v->head.data, CD_MLOOPUV); + add_v2_v2(uv_med, uv->uv); + tot_loops++; + } - mul_v2_fl(uv_med, 1.0/tot_loops); + mul_v2_fl(uv_med, 1.0/tot_loops); - BM_ITER_ELEM (l_v, &liter_v, sv->v, BM_LOOPS_OF_VERT) { - MLoopUV *uv = CustomData_bmesh_get(&em->bm->ldata, l_v->head.data, CD_MLOOPUV); - copy_v2_v2(uv->uv, uv_med); + BM_ITER_ELEM (l_v, &liter_v, sv->v, BM_LOOPS_OF_VERT) { + MLoopUV *uv = CustomData_bmesh_get(&em->bm->ldata, l_v->head.data, CD_MLOOPUV); + copy_v2_v2(uv->uv, uv_med); + } } } |