diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-02-04 18:22:05 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-02-04 18:22:05 +0400 |
commit | 8160829303bf3ba3c14f25cdb68aef5396faa56a (patch) | |
tree | 58a1a6b5b87e69ae91f52c4bbcabd673328f9afe /source/blender/makesrna/intern/rna_mesh.c | |
parent | 3e3ed974d79432662bfb7c694762c15682e3ca54 (diff) | |
parent | fc0ce537bab8731cc60fda282a6c97d4816011e5 (diff) |
Merged changes in the trunk up to revision 43881.
Diffstat (limited to 'source/blender/makesrna/intern/rna_mesh.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 4beda654ae8..c91542bca2d 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -27,6 +27,7 @@ #include <stdlib.h> +#include "RNA_access.h" #include "RNA_define.h" #include "rna_internal.h" @@ -1132,22 +1133,25 @@ static int rna_Mesh_tot_face_get(PointerRNA *ptr) return me->edit_mesh ? me->edit_mesh->totfacesel : 0; } -static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, const char *name) +static PointerRNA rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, const char *name) { + PointerRNA ptr; CustomData *fdata; CustomDataLayer *cdl= NULL; - int index; + int index= ED_mesh_color_add(C, NULL, NULL, me, name, FALSE); - if(ED_mesh_color_add(C, NULL, NULL, me, name, FALSE)) { + if(index != -1) { fdata= rna_mesh_fdata(me); - index= CustomData_get_named_layer_index(fdata, CD_MCOL, name); - cdl= (index == -1)? NULL: &fdata->layers[index]; + cdl= &fdata->layers[CustomData_get_layer_index_n(fdata, CD_MCOL, index)]; } - return cdl; + + RNA_pointer_create(&me->id, &RNA_MeshColorLayer, cdl, &ptr); + return ptr; } -static CustomDataLayer *rna_Mesh_int_property_new(struct Mesh *me, struct bContext *C, const char *name) +static PointerRNA rna_Mesh_int_property_new(struct Mesh *me, struct bContext *C, const char *name) { + PointerRNA ptr; CustomDataLayer *cdl = NULL; int index; @@ -1156,11 +1160,13 @@ static CustomDataLayer *rna_Mesh_int_property_new(struct Mesh *me, struct bConte cdl = (index == -1) ? NULL : &(me->fdata.layers[index]); - return cdl; + RNA_pointer_create(&me->id, &RNA_MeshIntPropertyLayer, cdl, &ptr); + return ptr; } -static CustomDataLayer *rna_Mesh_float_property_new(struct Mesh *me, struct bContext *C, const char *name) +static PointerRNA rna_Mesh_float_property_new(struct Mesh *me, struct bContext *C, const char *name) { + PointerRNA ptr; CustomDataLayer *cdl = NULL; int index; @@ -1169,11 +1175,13 @@ static CustomDataLayer *rna_Mesh_float_property_new(struct Mesh *me, struct bCon cdl = (index == -1) ? NULL : &(me->fdata.layers[index]); - return cdl; + RNA_pointer_create(&me->id, &RNA_MeshFloatPropertyLayer, cdl, &ptr); + return ptr; } -static CustomDataLayer *rna_Mesh_string_property_new(struct Mesh *me, struct bContext *C, const char *name) +static PointerRNA rna_Mesh_string_property_new(struct Mesh *me, struct bContext *C, const char *name) { + PointerRNA ptr; CustomDataLayer *cdl = NULL; int index; @@ -1182,21 +1190,24 @@ static CustomDataLayer *rna_Mesh_string_property_new(struct Mesh *me, struct bCo cdl = (index == -1) ? NULL : &(me->fdata.layers[index]); - return cdl; + RNA_pointer_create(&me->id, &RNA_MeshStringPropertyLayer, cdl, &ptr); + return ptr; } -static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, const char *name) +static PointerRNA rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, const char *name) { + PointerRNA ptr; CustomData *fdata; CustomDataLayer *cdl= NULL; - int index; + int index= ED_mesh_uv_texture_add(C, me, name, FALSE); - if(ED_mesh_uv_texture_add(C, me, name, FALSE)) { + if(index != -1) { fdata= rna_mesh_fdata(me); - index= CustomData_get_named_layer_index(fdata, CD_MTFACE, name); - cdl= (index == -1)? NULL: &fdata->layers[index]; + cdl= &fdata->layers[CustomData_get_layer_index_n(fdata, CD_MTFACE, index)]; } - return cdl; + + RNA_pointer_create(&me->id, &RNA_MeshTextureFaceLayer, cdl, &ptr); + return ptr; } #else @@ -1793,6 +1804,7 @@ static void rna_def_vertex_colors(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh"); RNA_def_string(func, "name", "Col", 0, "", "Vertex color name"); parm= RNA_def_pointer(func, "layer", "MeshColorLayer", "", "The newly created layer"); + RNA_def_property_flag(parm, PROP_RNAPTR); RNA_def_function_return(func, parm); /* @@ -1833,6 +1845,7 @@ static void rna_def_int_layers(BlenderRNA *brna, PropertyRNA *cprop) 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_property_flag(parm, PROP_RNAPTR); RNA_def_function_return(func, parm); } @@ -1854,6 +1867,7 @@ static void rna_def_float_layers(BlenderRNA *brna, PropertyRNA *cprop) 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_property_flag(parm, PROP_RNAPTR); RNA_def_function_return(func, parm); } @@ -1875,6 +1889,7 @@ static void rna_def_string_layers(BlenderRNA *brna, PropertyRNA *cprop) 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_property_flag(parm, PROP_RNAPTR); RNA_def_function_return(func, parm); } @@ -1897,6 +1912,7 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Add a UV texture layer to Mesh"); RNA_def_string(func, "name", "UVMap", 0, "", "UV map name"); parm= RNA_def_pointer(func, "layer", "MeshTextureFaceLayer", "", "The newly created layer"); + RNA_def_property_flag(parm, PROP_RNAPTR); RNA_def_function_return(func, parm); /* |