From 44010fb6590cc540b1e87e4753603fc34b378ff8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 26 Mar 2012 02:39:05 +0000 Subject: [PATCH] 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. --- release/scripts/modules/rna_xml.py | 2 +- source/blender/editors/include/ED_mesh.h | 1 + source/blender/editors/mesh/mesh_data.c | 20 ++++++++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py index eae7840b69b..710035dc29f 100644 --- a/release/scripts/modules/rna_xml.py +++ b/release/scripts/modules/rna_xml.py @@ -346,7 +346,7 @@ def xml_file_run(context, filepath, rna_map): value = _get_context_val(context, rna_path) if value is not Ellipsis and value is not None: - print(" loading XML: %r" % rna_path) + print(" loading XML: %r -> %r" % (filepath, rna_path)) xml2rna(xml_node, root_rna=value) diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 5bb30ab6d40..35bf9d77b23 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -287,6 +287,7 @@ void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int c int ED_mesh_uv_texture_add(struct bContext *C, struct Mesh *me, const char *name, int active_set); int ED_mesh_uv_texture_remove(struct bContext *C, struct Object *ob, struct Mesh *me); 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); int ED_mesh_color_add(struct bContext *C, struct Scene *scene, struct Object *ob, struct Mesh *me, const char *name, int active_set); int ED_mesh_color_remove(struct bContext *C, struct Object *ob, struct Mesh *me); int ED_mesh_color_remove_named(struct bContext *C, struct Object *ob, struct Mesh *me, const char *name); 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);