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>2013-08-14 15:29:58 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-08-14 15:29:58 +0400
commit503b7d5b9a385fdcd220df3142857300d912d80c (patch)
treed25f1c3c59edd0e8c30faf984cc681af9ada9fc8 /source/blender/makesrna
parent1979720d0324b84e4993557d30ff833f71e688fd (diff)
add materials.clear() method, matching other python list method.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_ID.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 76337da3261..26febf217a6 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -347,7 +347,7 @@ int rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assig
static void rna_IDMaterials_append_id(ID *id, Material *ma)
{
- material_append_id(id, ma);
+ BKE_material_append_id(id, ma);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, id);
WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id);
@@ -367,7 +367,7 @@ static Material *rna_IDMaterials_pop_id(ID *id, ReportList *reports, int index_i
return NULL;
}
- ma = material_pop_id(id, index_i, remove_material_slot);
+ ma = BKE_material_pop_id(id, index_i, remove_material_slot);
if (*totcol == totcol_orig) {
BKE_report(reports, RPT_ERROR, "No material to removed");
@@ -381,6 +381,15 @@ static Material *rna_IDMaterials_pop_id(ID *id, ReportList *reports, int index_i
return ma;
}
+static void rna_IDMaterials_clear_id(ID *id, int remove_material_slot)
+{
+ BKE_material_clear_id(id, remove_material_slot);
+
+ DAG_id_tag_update(id, OB_RECALC_DATA);
+ WM_main_add_notifier(NC_OBJECT | ND_DRAW, id);
+ WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id);
+}
+
static void rna_Library_filepath_set(PointerRNA *ptr, const char *value)
{
Library *lib = (Library *)ptr->data;
@@ -499,6 +508,10 @@ static void rna_def_ID_materials(BlenderRNA *brna)
RNA_def_boolean(func, "update_data", 0, "", "Update data by re-adjusting the material slots assigned");
parm = RNA_def_pointer(func, "material", "Material", "", "Material to remove");
RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "clear", "rna_IDMaterials_clear_id");
+ RNA_def_function_ui_description(func, "Remove all materials from the data block");
+ RNA_def_boolean(func, "update_data", 0, "", "Update data by re-adjusting the material slots assigned");
}
static void rna_def_ID(BlenderRNA *brna)