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>2011-11-15 16:28:13 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-15 16:28:13 +0400
commit735eb3774b0965704400f877f2a4c1c819003bc3 (patch)
tree0b02e625fcb7fd39c3ccb7b3d54a4a4c4dc579de /source/blender/makesrna
parent3d724d8df55d56731e49e73c4fead32deef661e3 (diff)
patch [#27708] API for adding mesh properties
from Geoffrey Bantle (briggs)
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 48a4d055520..63a7df09792 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -1146,6 +1146,45 @@ static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bConte
return cdl;
}
+static CustomDataLayer *rna_Mesh_int_property_new(struct Mesh *me, struct bContext *C, const char *name)
+{
+ CustomDataLayer *cdl = NULL;
+ int index;
+
+ CustomData_add_layer_named(&me->fdata, CD_PROP_INT, CD_DEFAULT, NULL, me->totface, name);
+ index = CustomData_get_named_layer_index(&me->fdata, CD_PROP_INT, name);
+
+ cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
+
+ return cdl;
+}
+
+static CustomDataLayer *rna_Mesh_float_property_new(struct Mesh *me, struct bContext *C, const char *name)
+{
+ CustomDataLayer *cdl = NULL;
+ int index;
+
+ CustomData_add_layer_named(&me->fdata, CD_PROP_FLT, CD_DEFAULT, NULL, me->totface, name);
+ index = CustomData_get_named_layer_index(&me->fdata, CD_PROP_FLT, name);
+
+ cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
+
+ return cdl;
+}
+
+static CustomDataLayer *rna_Mesh_string_property_new(struct Mesh *me, struct bContext *C, const char *name)
+{
+ CustomDataLayer *cdl = NULL;
+ int index;
+
+ CustomData_add_layer_named(&me->fdata, CD_PROP_STR, CD_DEFAULT, NULL, me->totface, name);
+ index = CustomData_get_named_layer_index(&me->fdata, CD_PROP_STR, name);
+
+ cdl = (index == -1) ? NULL : &(me->fdata.layers[index]);
+
+ return cdl;
+}
+
static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, const char *name)
{
CustomData *fdata;
@@ -1750,6 +1789,69 @@ static void rna_def_vertex_colors(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
}
+/* mesh int layers */
+static void rna_def_int_layers(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "IntProperties");
+ srna= RNA_def_struct(brna, "IntProperties", NULL);
+ RNA_def_struct_sdna(srna, "Mesh");
+ RNA_def_struct_ui_text(srna, "Int Properties", "Collection of int properties");
+
+ func= RNA_def_function(srna, "new", "rna_Mesh_int_property_new");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function_ui_description(func, "Add a integer property layer to Mesh");
+ RNA_def_string(func, "name", "Int Prop", 0, "", "Int property name");
+ parm= RNA_def_pointer(func, "layer", "MeshIntPropertyLayer", "", "The newly created layer");
+ RNA_def_function_return(func, parm);
+}
+
+/* mesh float layers */
+static void rna_def_float_layers(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "FloatProperties");
+ srna= RNA_def_struct(brna, "FloatProperties", NULL);
+ RNA_def_struct_sdna(srna, "Mesh");
+ RNA_def_struct_ui_text(srna, "Float Properties", "Collection of float properties");
+
+ func= RNA_def_function(srna, "new", "rna_Mesh_float_property_new");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function_ui_description(func, "Add a float property layer to Mesh");
+ RNA_def_string(func, "name", "Float Prop", 0, "", "Float property name");
+ parm= RNA_def_pointer(func, "layer", "MeshFloatPropertyLayer", "", "The newly created layer");
+ RNA_def_function_return(func, parm);
+}
+
+/* mesh string layers */
+static void rna_def_string_layers(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "StringProperties");
+ srna= RNA_def_struct(brna, "StringProperties", NULL);
+ RNA_def_struct_sdna(srna, "Mesh");
+ RNA_def_struct_ui_text(srna, "String Properties", "Collection of string properties");
+
+ func= RNA_def_function(srna, "new", "rna_Mesh_string_property_new");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function_ui_description(func, "Add a string property layer to Mesh");
+ RNA_def_string(func, "name", "String Prop", 0, "", "String property name");
+ parm= RNA_def_pointer(func, "layer", "MeshStringPropertyLayer", "", "The newly created layer");
+ RNA_def_function_return(func, parm);
+}
+
/* mesh.uv_layers */
static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop)
{
@@ -1876,6 +1978,7 @@ static void rna_def_mesh(BlenderRNA *brna)
"rna_Mesh_float_layers_length", NULL, NULL, NULL);
RNA_def_property_struct_type(prop, "MeshFloatPropertyLayer");
RNA_def_property_ui_text(prop, "Float Property Layers", "");
+ rna_def_float_layers(brna, prop);
prop= RNA_def_property(srna, "layers_int", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
@@ -1883,6 +1986,7 @@ static void rna_def_mesh(BlenderRNA *brna)
"rna_Mesh_int_layers_length", NULL, NULL, NULL);
RNA_def_property_struct_type(prop, "MeshIntPropertyLayer");
RNA_def_property_ui_text(prop, "Int Property Layers", "");
+ rna_def_int_layers(brna, prop);
prop= RNA_def_property(srna, "layers_string", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
@@ -1890,6 +1994,7 @@ static void rna_def_mesh(BlenderRNA *brna)
"rna_Mesh_string_layers_length", NULL, NULL, NULL);
RNA_def_property_struct_type(prop, "MeshStringPropertyLayer");
RNA_def_property_ui_text(prop, "String Property Layers", "");
+ rna_def_string_layers(brna, prop);
prop= RNA_def_property(srna, "use_auto_smooth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_AUTOSMOOTH);