diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-28 16:33:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-28 16:33:56 +0300 |
commit | a2b370dd6f55d6114da3ec1d86788e9c9786822f (patch) | |
tree | 8f5adc8b06e8f9506155e4906dd7ff5d11fdc987 /source/blender/editors/object/object_modifier.c | |
parent | c4933cccfa74836ff88a6904abfaf52c8e0cde87 (diff) |
py/rna api
- object.modifiers.add()/remove()
- armature.edit_bones.active wasnt named correctly
Diffstat (limited to 'source/blender/editors/object/object_modifier.c')
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 7ab49f5c838..88763f63f7b 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -43,6 +43,7 @@ #include "BLI_math.h" #include "BLI_listbase.h" +#include "BLI_string.h" #include "BKE_action.h" #include "BKE_curve.h" @@ -78,7 +79,7 @@ /******************************** API ****************************/ -ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int type) +ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, char *name, int type) { ModifierData *md=NULL, *new_md=NULL; ModifierTypeInfo *mti = modifierType_getInfo(type); @@ -94,7 +95,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object * /* don't need to worry about the new modifier's name, since that is set to the number * of particle systems which shouldn't have too many duplicates */ - object_add_particle_system(scene, ob); + new_md = object_add_particle_system(scene, ob, name); } else { /* get new modifier data to add */ @@ -110,8 +111,12 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object * } else BLI_addtail(&ob->modifiers, new_md); - + + if(name) + BLI_strncpy(new_md->name, name, sizeof(new_md->name)); + /* make sure modifier data has unique name */ + modifier_unique_name(&ob->modifiers, new_md); /* special cases */ @@ -148,8 +153,10 @@ int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, Mod if(obmd==md) break; - if(!obmd) + if(!obmd) { + BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'.", ob->id.name, md->name); return 0; + } /* special cases */ if(md->type == eModifierType_ParticleSystem) { @@ -482,7 +489,7 @@ static int modifier_add_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); int type= RNA_enum_get(op->ptr, "type"); - if(!ED_object_modifier_add(op->reports, scene, ob, type)) + if(!ED_object_modifier_add(op->reports, scene, ob, NULL, type)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); |