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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-26 08:23:18 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-26 08:23:18 +0400
commit452f7c38687527d3283395fb6d716cb63a2d8f60 (patch)
tree80c52c8918946ca6205ae3bf4be630878666bb52 /source
parent48f0444760ea33c67d607b4f1e1dadd66e1eea76 (diff)
setting the active texture layer from python would get the UV layer out of sync. (entering editmode would show the wrong UV layer)
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c19
-rw-r--r--source/blender/makesrna/intern/rna_mesh_utils.h16
2 files changed, 24 insertions, 11 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 7eef6630924..ad5b72079a9 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -483,13 +483,20 @@ static int rna_CustomDataLayer_clone_get(PointerRNA *ptr, CustomData *data, int
static void rna_CustomDataLayer_active_set(PointerRNA *ptr, CustomData *data, int value, int type, int render)
{
- int n = ((CustomDataLayer*)ptr->data) - data->layers;
+ int n = (((CustomDataLayer*)ptr->data) - data->layers) - CustomData_get_layer_index(data, type);
if (value == 0)
return;
- if (render) CustomData_set_layer_render_index(data, type, n);
- else CustomData_set_layer_active_index(data, type, n);
+ if (render) CustomData_set_layer_render(data, type, n);
+ else CustomData_set_layer_active(data, type, n);
+
+ /* sync loop layer */
+ if (type == CD_MTEXPOLY) {
+ CustomData *ldata = rna_mesh_ldata(ptr);
+ if (render) CustomData_set_layer_render(ldata, CD_MLOOPUV, n);
+ else CustomData_set_layer_active(ldata, CD_MLOOPUV, n);
+ }
}
static void rna_CustomDataLayer_clone_set(PointerRNA *ptr, CustomData *data, int value, int type, int render)
@@ -2178,12 +2185,6 @@ static void rna_def_mesh_loops(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_struct_sdna(srna, "Mesh");
RNA_def_struct_ui_text(srna, "Mesh Loops", "Collection of mesh loops");
-#if 0 /* BMESH_TODO */
- prop = RNA_def_property(srna, "active", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "act_face");
- RNA_def_property_ui_text(prop, "Active Polygon", "The active polygon for this mesh");
-#endif
-
func = RNA_def_function(srna, "add", "ED_mesh_loops_add");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of loops to add", 0, INT_MAX);
diff --git a/source/blender/makesrna/intern/rna_mesh_utils.h b/source/blender/makesrna/intern/rna_mesh_utils.h
index b00271f0e16..f262e717eef 100644
--- a/source/blender/makesrna/intern/rna_mesh_utils.h
+++ b/source/blender/makesrna/intern/rna_mesh_utils.h
@@ -99,9 +99,16 @@
int a; \
if (data) { \
CustomDataLayer *layer; \
- for (layer = data->layers, a = 0; a<data->totlayer; layer++, a++) { \
+ int layer_index = CustomData_get_layer_index(data, layer_type); \
+ for (layer = data->layers, a = 0; layer_index + a < data->totlayer; layer++, a++) { \
if (value.data == layer) { \
- CustomData_set_layer_##active_type##_index(data, layer_type, a); \
+ CustomData_set_layer_##active_type(data, layer_type, a); \
+ \
+ /* keep loops in sync */ \
+ if (layer_type == CD_MTEXPOLY) { \
+ CustomData *ldata = rna_mesh_ldata_helper(me); \
+ CustomData_set_layer_##active_type(ldata, CD_MLOOPUV, a); \
+ } \
mesh_update_customdata_pointers(me, TRUE); \
return; \
} \
@@ -126,6 +133,11 @@
CustomData *data = rna_mesh_##customdata_type(ptr); \
if (data) { \
CustomData_set_layer_##active_type(data, layer_type, value); \
+ /* keep loops in sync */ \
+ if (layer_type == CD_MTEXPOLY) { \
+ CustomData *ldata = rna_mesh_ldata_helper(me); \
+ CustomData_set_layer_##active_type(ldata, CD_MLOOPUV, value); \
+ } \
mesh_update_customdata_pointers(me, TRUE); \
} \
}