diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-03-05 23:34:48 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-03-05 23:34:48 +0300 |
commit | dbdd79fabe2934de6184c0230f91b2e8af716a7b (patch) | |
tree | 1a9ea8439a6330f6bda57a5488056ce78bf6bc1d /source/blender/makesrna/intern | |
parent | 4326f8af08c845eeb4eb45800ca047f690044007 (diff) |
UV/VCol layers creation: add option to not init those new data.
`ED_mesh_uv_texture_add()`/`ED_mesh_color_add()` would always either
copy data from current active one, or (for UVs), generate default
'valid' UVs for every face.
This commit adds an option to not do that, just keeping default values
from raw CDLayer creation. It is only used/exposed from RNA API
currently.
This is especially useful for importer add-ons, since some formats
support multiple layers of those kind, as well as 'partial' dataset not
explicitely defining values for all mesh items.
Preliminary step to fix T62224.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 9494d0f49c6..c9a8da51e40 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1368,12 +1368,12 @@ static int rna_Mesh_tot_face_get(PointerRNA *ptr) return me->edit_mesh ? me->edit_mesh->bm->totfacesel : 0; } -static PointerRNA rna_Mesh_vertex_color_new(struct Mesh *me, const char *name) +static PointerRNA rna_Mesh_vertex_color_new(struct Mesh *me, const char *name, const bool do_init) { PointerRNA ptr; CustomData *ldata; CustomDataLayer *cdl = NULL; - int index = ED_mesh_color_add(me, name, false); + int index = ED_mesh_color_add(me, name, false, do_init); if (index != -1) { ldata = rna_mesh_ldata_helper(me); @@ -1415,12 +1415,12 @@ DEFINE_CUSTOMDATA_PROPERTY_API(polygon, int, CD_PROP_INT, pdata, totpoly, MeshPo DEFINE_CUSTOMDATA_PROPERTY_API(polygon, string, CD_PROP_STR, pdata, totpoly, MeshPolygonStringPropertyLayer) #undef DEFINE_CUSTOMDATA_PROPERTY_API -static PointerRNA rna_Mesh_uv_layers_new(struct Mesh *me, const char *name) +static PointerRNA rna_Mesh_uv_layers_new(struct Mesh *me, const char *name, const bool do_init) { PointerRNA ptr; CustomData *ldata; CustomDataLayer *cdl = NULL; - int index = ED_mesh_uv_texture_add(me, name, false); + int index = ED_mesh_uv_texture_add(me, name, false, do_init); if (index != -1) { ldata = rna_mesh_ldata_helper(me); @@ -2213,6 +2213,8 @@ static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Mesh_vertex_color_new"); RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh"); RNA_def_string(func, "name", "Col", 0, "", "Vertex color name"); + RNA_def_boolean(func, "do_init", true, "", + "Whether new layer's data should be initialized by copying current active one"); parm = RNA_def_pointer(func, "layer", "MeshLoopColorLayer", "", "The newly created layer"); RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); RNA_def_function_return(func, parm); @@ -2255,6 +2257,9 @@ static void rna_def_uv_layers(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_Mesh_uv_layers_new"); RNA_def_function_ui_description(func, "Add a UV map layer to Mesh"); RNA_def_string(func, "name", "UVMap", 0, "", "UV map name"); + RNA_def_boolean(func, "do_init", true, "", + "Whether new layer's data should be initialized by copying current active one, " + "or if none is active, with a default UVmap"); parm = RNA_def_pointer(func, "layer", "MeshUVLoopLayer", "", "The newly created layer"); RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); RNA_def_function_return(func, parm); |