diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-23 20:12:11 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-23 20:12:11 +0400 |
commit | 85497e35d0a012e8584022cfa021dd1b8435d17b (patch) | |
tree | 4262bec6539efdddc3e71d0fffe0e69f235db28d /source/blender/makesrna/intern/rna_object.c | |
parent | f48cc83b3e7327565c17fc18f42881099941b4bf (diff) |
Added method clear to most of collections which supports new/remove.
This method not added to animation-specific structures yet/
Diffstat (limited to 'source/blender/makesrna/intern/rna_object.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 6e797146f12..9dd6d2e8175 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1156,6 +1156,16 @@ static void rna_Object_constraints_remove(Object *object, ReportList *reports, b WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, object); } +static void rna_Object_constraints_clear(Object *object) +{ + free_constraints(&object->constraints); + + ED_object_constraint_update(object); + ED_object_constraint_set_active(object, NULL); + + WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, object); +} + static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports, const char *name, int type) { return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type); @@ -1164,6 +1174,15 @@ static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, Report static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md) { ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md); + + WM_main_add_notifier(NC_OBJECT|ND_MODIFIER|NA_REMOVED, object); +} + +static void rna_Object_modifier_clear(Object *object, bContext *C) +{ + ED_object_modifier_clear(CTX_data_main(C), CTX_data_scene(C), object); + + WM_main_add_notifier(NC_OBJECT|ND_MODIFIER|NA_REMOVED, object); } static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) @@ -1195,6 +1214,13 @@ static void rna_Object_vgroup_remove(Object *ob, bDeformGroup *defgroup) WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob); } +static void rna_Object_vgroup_clear(Object *ob) +{ + ED_vgroup_clear(ob); + + WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob); +} + static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *reports, int index_len, int *index, float weight, int assignmode) { @@ -1636,6 +1662,9 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop) /* constraint to remove */ parm= RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_Object_constraints_clear"); + RNA_def_function_ui_description(func, "Remove all constraint from this object"); } /* object.modifiers */ @@ -1684,6 +1713,11 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop) /* target to remove*/ parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + /* clear all modifiers */ + func= RNA_def_function(srna, "clear", "rna_Object_modifier_clear"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Remove all modifiers from the object"); } /* object.particle_systems */ @@ -1758,6 +1792,9 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Delete vertex group from object"); parm= RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_Object_vgroup_clear"); + RNA_def_function_ui_description(func, "Delete all vertex groups from object"); } |