- move more active properties into their collections:

scene.active_keying_set --> scene.keying_sets.active
  ...same for active_uv_texture. active_vertex_color, active_keyconfig, 

- move mesh.add_uv_layer() and mesh.add_vertex_color() into their collections
  also have them return the newly created layer and dont set the layer active.

  uvtex = mesh.uv_layers.new(name)
  vcol = mesh.vertex_colors.new(name)
This commit is contained in:
2010-08-23 22:16:45 +00:00
parent 1be4eda552
commit f6c323aa42
35 changed files with 317 additions and 164 deletions

View File

@@ -1064,6 +1064,32 @@ 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, char *name)
{
CustomData *fdata;
CustomDataLayer *cdl;
int index;
ED_mesh_color_add(C, NULL, NULL, me, name, FALSE);
fdata= rna_mesh_fdata(me);
index= CustomData_number_of_layers(fdata, CD_MCOL) - 1;
cdl= (index == -1)? NULL: &fdata->layers[index];
return cdl;
}
static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, char *name)
{
CustomData *fdata;
CustomDataLayer *cdl;
int index;
ED_mesh_uv_texture_add(C, NULL, NULL, me, name, FALSE);
fdata= rna_mesh_fdata(me);
index= CustomData_number_of_layers(fdata, CD_MTFACE) - 1;
cdl= (index == -1)? NULL: &fdata->layers[index];
return cdl;
}
#else
static void rna_def_mvert_group(BlenderRNA *brna)
@@ -1630,6 +1656,78 @@ static void rna_def_mesh_faces(BlenderRNA *brna, PropertyRNA *cprop)
}
/* mesh.vertex_colors */
static void rna_def_vertex_colors(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
PropertyRNA *prop;
FunctionRNA *func;
PropertyRNA *parm;
RNA_def_property_srna(cprop, "VertexColors");
srna= RNA_def_struct(brna, "VertexColors", NULL);
RNA_def_struct_sdna(srna, "Mesh");
RNA_def_struct_ui_text(srna, "Vertex Colors", "Collection of vertex colors");
func= RNA_def_function(srna, "new", "rna_Mesh_vertex_color_new");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh.");
parm= RNA_def_string(func, "name", "UVTex", 0, "", "UV Texture name.");
parm= RNA_def_pointer(func, "layer", "MeshColorLayer", "", "The newly created layer.");
RNA_def_function_return(func, parm);
/*
func= RNA_def_function(srna, "remove", "rna_Mesh_vertex_color_remove");
RNA_def_function_ui_description(func, "Remove a vertex color layer.");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm= RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove.");
RNA_def_property_flag(parm, PROP_REQUIRED);
*/
prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED);
RNA_def_property_struct_type(prop, "MeshColorLayer");
RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_vertex_color_get", "rna_Mesh_active_vertex_color_set", NULL, NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active Vertex Color Layer", "Active vertex color layer");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
}
/* mesh.uv_layers */
static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
PropertyRNA *prop;
FunctionRNA *func;
PropertyRNA *parm;
RNA_def_property_srna(cprop, "UVTextures");
srna= RNA_def_struct(brna, "UVTextures", NULL);
RNA_def_struct_sdna(srna, "Mesh");
RNA_def_struct_ui_text(srna, "UV Textures", "Collection of uv textures");
func= RNA_def_function(srna, "new", "rna_Mesh_uv_texture_new");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Add a UV texture layer to Mesh.");
parm= RNA_def_string(func, "name", "UVTex", 0, "", "UV Texture name.");
parm= RNA_def_pointer(func, "layer", "MeshColorLayer", "", "The newly created layer.");
RNA_def_function_return(func, parm);
/*
func= RNA_def_function(srna, "remove", "rna_Mesh_uv_layers_remove");
RNA_def_function_ui_description(func, "Remove a vertex color layer.");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm= RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove.");
RNA_def_property_flag(parm, PROP_REQUIRED);
*/
prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED);
RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_uv_texture_get", "rna_Mesh_active_uv_texture_set", NULL, NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active UV Texture", "Active UV texture");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
}
static void rna_def_mesh(BlenderRNA *brna)
{
StructRNA *srna;
@@ -1672,13 +1770,7 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_textures_begin", 0, 0, 0, "rna_Mesh_uv_textures_length", 0, 0);
RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
RNA_def_property_ui_text(prop, "UV Textures", "");
prop= RNA_def_property(srna, "active_uv_texture", PROP_POINTER, PROP_UNSIGNED);
RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_uv_texture_get", "rna_Mesh_active_uv_texture_set", NULL, NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active UV Texture", "Active UV texture");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
rna_def_uv_textures(brna, prop);
prop= RNA_def_property(srna, "active_uv_texture_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_funcs(prop, "rna_Mesh_active_uv_texture_index_get", "rna_Mesh_active_uv_texture_index_set", "rna_Mesh_active_uv_texture_index_range");
@@ -1712,14 +1804,9 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_collection_funcs(prop, "rna_Mesh_vertex_colors_begin", 0, 0, 0, "rna_Mesh_vertex_colors_length", 0, 0);
RNA_def_property_struct_type(prop, "MeshColorLayer");
RNA_def_property_ui_text(prop, "Vertex Colors", "");
rna_def_vertex_colors(brna, prop);
prop= RNA_def_property(srna, "active_vertex_color", PROP_POINTER, PROP_UNSIGNED);
RNA_def_property_struct_type(prop, "MeshColorLayer");
RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_vertex_color_get", "rna_Mesh_active_vertex_color_set", NULL, NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active Vertex Color Layer", "Active vertex color layer");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
/* TODO, remove and make a collection property */
prop= RNA_def_property(srna, "active_vertex_color_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_funcs(prop, "rna_Mesh_active_vertex_color_index_get", "rna_Mesh_active_vertex_color_index_set", "rna_Mesh_active_vertex_color_index_range");
RNA_def_property_ui_text(prop, "Active Vertex Color Index", "Active vertex color index");