[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48375] trunk/blender/source/blender/ editors/transform/transform.c: recent fix for #31581 could crash when doing edge slide on a mesh with no UV 's.
Campbell Barton
ideasman42 at gmail.com
Thu Jun 28 16:18:16 CEST 2012
Revision: 48375
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48375
Author: campbellbarton
Date: 2012-06-28 14:18:04 +0000 (Thu, 28 Jun 2012)
Log Message:
-----------
recent fix for #31581 could crash when doing edge slide on a mesh with no UV's.
Modified Paths:
--------------
trunk/blender/source/blender/editors/transform/transform.c
Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c 2012-06-28 13:12:52 UTC (rev 48374)
+++ trunk/blender/source/blender/editors/transform/transform.c 2012-06-28 14:18:04 UTC (rev 48375)
@@ -4992,6 +4992,7 @@
BMEditMesh *em = sld->em;
SmallHash visit;
int i;
+ short has_uv;
if (!em)
return;
@@ -5004,6 +5005,8 @@
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 @@
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 @@
/* 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);
+ }
}
}
More information about the Bf-blender-cvs
mailing list