From 000312ab515b77f00725a91b235685ff0c774e57 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 19 Nov 2013 17:19:06 +0600 Subject: 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 --- release/scripts/addons | 2 +- source/blender/editors/include/ED_object.h | 2 ++ source/blender/editors/object/object_edit.c | 21 ++++++++++++++++++++- source/blender/editors/object/object_modifier.c | 3 --- source/blender/makesrna/intern/rna_object_force.c | 16 ++-------------- source/blenderplayer/bad_level_call_stubs/stubs.c | 1 + 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/release/scripts/addons b/release/scripts/addons index 2bfbbe4182d..3adbc8f30b2 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 2bfbbe4182d7e5d5332d963054f298c9fddc5f09 +Subproject commit 3adbc8f30b229e7c9ff465183d5ab0acbbdf921a diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 0d11108d81f..4155dbb5565 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -219,6 +219,8 @@ struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( int *free, const unsigned int selection_mask); +void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object); + #ifdef __cplusplus } #endif 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; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 0c794a974ef..01dafe69d31 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -298,9 +298,6 @@ static int object_modifier_remove(Main *bmain, Object *ob, ModifierData *md, *sort_depsgraph = 1; } else if (md->type == eModifierType_Surface) { - if (ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE) - ob->pd->shape = PFIELD_SHAPE_PLANE; - *sort_depsgraph = 1; } else if (md->type == eModifierType_Multires) { diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 33ae256c042..2a93925a8e5 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -517,21 +517,9 @@ static void rna_FieldSettings_shape_update(Main *bmain, Scene *scene, PointerRNA { if (!particle_id_check(ptr)) { Object *ob = (Object *)ptr->id.data; - PartDeflect *pd = ob->pd; - ModifierData *md = modifiers_findByType(ob, 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(ob->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVE)) - ED_object_modifier_add(NULL, bmain, scene, ob, NULL, eModifierType_Surface); - } - else { - if (!pd || pd->shape != PFIELD_SHAPE_SURFACE) - ED_object_modifier_remove(NULL, bmain, ob, md); - } - + ED_object_check_force_modifiers(bmain, scene, ob); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); + WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); } } diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 80f3a617bac..f61b54ac360 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -353,6 +353,7 @@ void ED_object_modifier_clear(struct Main *bmain, struct Object *ob) {STUB_ASSER void ED_object_editmode_enter(struct bContext *C, int flag) {STUB_ASSERT(0);} void ED_object_editmode_exit(struct bContext *C, int flag) {STUB_ASSERT(0);} bool ED_object_editmode_load(struct Object *obedit) {STUB_ASSERT(0); return false; } +void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object) {STUB_ASSERT(0);} int uiLayoutGetActive(struct uiLayout *layout) {STUB_ASSERT(0); return 0;} int uiLayoutGetOperatorContext(struct uiLayout *layout) {STUB_ASSERT(0); return 0;} int uiLayoutGetAlignment(struct uiLayout *layout) {STUB_ASSERT(0); return 0;} -- cgit v1.2.3