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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-06-27 05:10:39 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-06-27 05:10:39 +0400
commitd839a9ae9ccbf17375e28cc92aa75a0cb4cf6b11 (patch)
tree3ee663e436f751f799dcd3542788f10be4cb121d /source/blender/makesrna/intern/rna_mesh.c
parent524b8614373df3e1eb212939f048a79b75450c28 (diff)
RNA
* Added support for passing collections to/from RNA functions, this is done using a ListBase of CollectionPointerLink, which is a standard ListBase link + PointerRNA. * Added editable active uv/vcol layer to Mesh. * Armature.bones now includes all bones, not only the ones without parents. * Modifier UV layer fields now are allowed to be empty, previously this would set the name during modifier evaluation if there was none.
Diffstat (limited to 'source/blender/makesrna/intern/rna_mesh.c')
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index da90b9f4c76..e56760f5ca3 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -234,6 +234,29 @@ static int rna_Mesh_uv_layers_length(PointerRNA *ptr)
return rna_CustomDataLayer_length(ptr, CD_MTFACE);
}
+static PointerRNA rna_Mesh_active_uv_layer_get(PointerRNA *ptr)
+{
+ Mesh *me= (Mesh*)ptr->data;
+ int index= CustomData_get_active_layer_index(&me->fdata, CD_MTFACE);
+ CustomDataLayer *cdl= (index == -1)? NULL: &me->fdata.layers[index];
+
+ return rna_pointer_inherit_refine(ptr, &RNA_MeshTextureFaceLayer, cdl);
+}
+
+static void rna_Mesh_active_uv_layer_set(PointerRNA *ptr, PointerRNA value)
+{
+ Mesh *me= (Mesh*)ptr->data;
+ CustomDataLayer *cdl;
+ int a;
+
+ for(cdl=me->fdata.layers, a=0; a<me->fdata.totlayer; cdl++, a++) {
+ if(value.data == cdl) {
+ CustomData_set_layer_active_index(&me->fdata, CD_MTFACE, a);
+ return;
+ }
+ }
+}
+
static void rna_MeshTextureFace_uv1_get(PointerRNA *ptr, float *values)
{
MTFace *mtface= (MTFace*)ptr->data;
@@ -348,6 +371,29 @@ static int rna_Mesh_vcol_layers_length(PointerRNA *ptr)
return rna_CustomDataLayer_length(ptr, CD_MCOL);
}
+static PointerRNA rna_Mesh_active_vcol_layer_get(PointerRNA *ptr)
+{
+ Mesh *me= (Mesh*)ptr->data;
+ int index= CustomData_get_active_layer_index(&me->fdata, CD_MCOL);
+ CustomDataLayer *cdl= (index == -1)? NULL: &me->fdata.layers[index];
+
+ return rna_pointer_inherit_refine(ptr, &RNA_MeshColorLayer, cdl);
+}
+
+static void rna_Mesh_active_vcol_layer_set(PointerRNA *ptr, PointerRNA value)
+{
+ Mesh *me= (Mesh*)ptr->data;
+ CustomDataLayer *cdl;
+ int a;
+
+ for(cdl=me->fdata.layers, a=0; a<me->fdata.totlayer; cdl++, a++) {
+ if(value.data == cdl) {
+ CustomData_set_layer_active_index(&me->fdata, CD_MCOL, a);
+ return;
+ }
+ }
+}
+
static void rna_MeshColorLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
@@ -1075,18 +1121,34 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "MeshSticky");
RNA_def_property_ui_text(prop, "Sticky", "Sticky texture coordinates.");
+ /* UV layers */
+
prop= RNA_def_property(srna, "uv_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_layers_begin", 0, 0, 0, "rna_Mesh_uv_layers_length", 0, 0, 0, 0);
RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
RNA_def_property_ui_text(prop, "UV Layers", "");
+ prop= RNA_def_property(srna, "active_uv_layer", PROP_POINTER, PROP_UNSIGNED);
+ RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
+ RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_uv_layer_get", "rna_Mesh_active_uv_layer_set", NULL);
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Active UV Layer", "Active UV layer.");
+
+ /* VCol layers */
+
prop= RNA_def_property(srna, "vcol_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_vcol_layers_begin", 0, 0, 0, "rna_Mesh_vcol_layers_length", 0, 0, 0, 0);
RNA_def_property_struct_type(prop, "MeshColorLayer");
RNA_def_property_ui_text(prop, "Vertex Color Layers", "");
+ prop= RNA_def_property(srna, "active_vcol_layer", PROP_POINTER, PROP_UNSIGNED);
+ RNA_def_property_struct_type(prop, "MeshColorLayer");
+ RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_vcol_layer_get", "rna_Mesh_active_vcol_layer_set", NULL);
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Active Vertex Color Layer", "Active vertex color layer.");
+
prop= RNA_def_property(srna, "float_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_float_layers_begin", 0, 0, 0, "rna_Mesh_float_layers_length", 0, 0, 0, 0);