Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-26 06:39:05 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-26 06:39:05 +0400
commit44010fb6590cc540b1e87e4753603fc34b378ff8 (patch)
tree99ddcf5383dacc66c99cf23662dbb527c2173286 /source/blender/editors/mesh/mesh_data.c
parent94b8b8913e0283850cd2f05361a8980ecbe4870c (diff)
fix [#30657] New UV layers created with Mesh.uv_textures.new reset previous ones.
adding UV's from python was resetting the active UV layer but not setting the new layer to active, resetting existing UV's.
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r--source/blender/editors/mesh/mesh_data.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 770fd68079a..736f8b976f8 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -206,7 +206,7 @@ static void copy_editface_active_customdata(BMEditMesh *em, int type, int index)
#endif
}
-int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
+int ED_mesh_uv_loop_reset_ex(struct bContext *C, struct Mesh *me, const int layernum)
{
BMEditMesh *em= me->edit_btmesh;
MLoopUV *luv;
@@ -232,7 +232,7 @@ int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
i = 0;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
- luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
+ luv = CustomData_bmesh_get_n(&em->bm->ldata, l->head.data, CD_MLOOPUV, layernum);
BLI_array_append(uvs, luv->uv);
i++;
}
@@ -244,14 +244,16 @@ int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
/* Collect Mesh UVs */
MPoly *mp;
+ MLoopUV *mloouv;
BLI_assert(CustomData_has_layer(&me->ldata, CD_MLOOPUV));
+ mloouv = CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, layernum);
for (j = 0; j < me->totpoly; j++) {
mp = &me->mpoly[j];
for (i = 0; i < mp->totloop; i++) {
- luv = &me->mloopuv[mp->loopstart + i];
+ luv = &mloouv[mp->loopstart + i];
BLI_array_append(uvs, luv->uv);
}
@@ -303,8 +305,6 @@ int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
fuvs += len;
}
- /* BMESH_TODO: Copy poly UVs onto CD_MTFACE layer for tessellated faces */
-
BLI_array_free(uvs);
BLI_array_free(polylengths);
@@ -314,6 +314,14 @@ int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
return 1;
}
+int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
+{
+ /* could be ldata or pdata */
+ CustomData *pdata = GET_CD_DATA(me, pdata);
+ const int layernum = CustomData_get_active_layer_index(pdata, CD_MTEXPOLY);
+ return ED_mesh_uv_loop_reset_ex(C, me, layernum);
+}
+
int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_set)
{
BMEditMesh *em;
@@ -372,7 +380,7 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s
mesh_update_customdata_pointers(me, TRUE);
}
- ED_mesh_uv_loop_reset(C, me);
+ ED_mesh_uv_loop_reset_ex(C, me, layernum);
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);