diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-11-19 15:19:06 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-11-19 15:19:06 +0400 |
commit | 000312ab515b77f00725a91b235685ff0c774e57 (patch) | |
tree | f6f36e58e1d4df2a65be158a3f7e4364bf55a8ec /source/blender/editors/object/object_edit.c | |
parent | c566e408e42836c136d8818cbea93ce870be09ea (diff) |
Remove Surface modifier when removing force field from object
Summary:
Before this adding Surface type of force field and removing
this field would leave Surface modifier alive in the stack.
This might be really misleading and annoying.
Now removing force field will ensure no modifiers needed for
it are remained in the stack.
This also fixes missing notifier to redraw modifier stack
when changing force field type.
Reviewers: brecht, campbellbarton
Reviewed By: brecht
Differential Revision: http://developer.blender.org/D13
Diffstat (limited to 'source/blender/editors/object/object_edit.c')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index bd4c2e997fe..02cbc1060df 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1110,6 +1110,23 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, View3D * /* ******************* force field toggle operator ***************** */ +void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object) +{ + PartDeflect *pd = object->pd; + ModifierData *md = modifiers_findByType(object, eModifierType_Surface); + + /* add/remove modifier as needed */ + if (!md) { + if (pd && (pd->shape == PFIELD_SHAPE_SURFACE) && ELEM(pd->forcefield, PFIELD_GUIDE, PFIELD_TEXTURE) == 0) + if (ELEM4(object->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVE)) + ED_object_modifier_add(NULL, bmain, scene, object, NULL, eModifierType_Surface); + } + else { + if (!pd || pd->shape != PFIELD_SHAPE_SURFACE || pd->forcefield != PFIELD_FORCE) + ED_object_modifier_remove(NULL, bmain, object, md); + } +} + static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = CTX_data_active_object(C); @@ -1122,7 +1139,9 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) else ob->pd->forcefield = 0; - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); + ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } |