diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_modifier.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/fluid.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 11 | ||||
-rw-r--r-- | source/blender/editors/object/object_data_transfer.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_hook.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 14 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 206 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 20 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_ui_common.c | 11 | ||||
-rw-r--r-- | source/blender/nodes/geometry/node_geometry_tree.cc | 9 |
13 files changed, 218 insertions, 86 deletions
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 2491f0953c0..b0a7d89e3d8 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -407,6 +407,7 @@ struct ModifierData *BKE_modifier_new(int type); void BKE_modifier_free_ex(struct ModifierData *md, const int flag); void BKE_modifier_free(struct ModifierData *md); +void BKE_modifier_remove_from_list(struct Object *ob, struct ModifierData *md); /* Generate new UUID for the given modifier. */ void BKE_modifier_session_uuid_generate(struct ModifierData *md); diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 434456a922e..7eac4bf32e3 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -4559,7 +4559,7 @@ void BKE_fluid_particle_system_destroy(struct Object *ob, const int particle_typ if (psys->part->type == particle_type) { /* clear modifier */ pfmd = psys_get_modifier(ob, psys); - BLI_remlink(&ob->modifiers, pfmd); + BKE_modifier_remove_from_list(ob, pfmd); BKE_modifier_free((ModifierData *)pfmd); /* clear particle system */ diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 3c8b685a0e0..de820786549 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -212,6 +212,26 @@ void BKE_modifier_free(ModifierData *md) BKE_modifier_free_ex(md, 0); } +/** + * Use instead of `BLI_remlink` when the object's active modifier should change. + */ +void BKE_modifier_remove_from_list(Object *ob, ModifierData *md) +{ + BLI_assert(BLI_findindex(&ob->modifiers, md) != -1); + + if (md->flag & eModifierFlag_Active) { + /* Prefer the previous modifier but use the next if this modifier is the first in the list. */ + if (md->prev != NULL) { + BKE_object_modifier_set_active(ob, md->prev); + } + else if (md->next != NULL) { + BKE_object_modifier_set_active(ob, md->next); + } + } + + BLI_remlink(&ob->modifiers, md); +} + void BKE_modifier_session_uuid_generate(ModifierData *md) { md->session_uuid = BLI_session_uuid_generate(); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 0b331fb88d2..d516de535f9 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4046,7 +4046,7 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob /* Clear modifier, skip empty ones. */ psmd = psys_get_modifier(ob, psys); if (psmd) { - BLI_remlink(&ob->modifiers, psmd); + BKE_modifier_remove_from_list(ob, (ModifierData *)psmd); BKE_modifier_free((ModifierData *)psmd); } @@ -5401,7 +5401,7 @@ void BKE_particle_system_blend_read_lib(BlendLibReader *reader, else { /* particle modifier must be removed before particle system */ ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); - BLI_remlink(&ob->modifiers, psmd); + BKE_modifier_remove_from_list(ob, (ModifierData *)psmd); BKE_modifier_free((ModifierData *)psmd); BLI_remlink(particles, psys); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index e4b6cfe5f08..15cad7c36eb 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -2450,20 +2450,13 @@ int ui_handler_panel_region(bContext *C, continue; } - /* All mouse clicks inside panels should return in break, but continue handling - * in case there is a sub-panel header at the mouse location. */ - if (event->type == LEFTMOUSE && - ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER)) { - retval = WM_UI_HANDLER_BREAK; - } - if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { + /* All mouse clicks inside panel headers should return in break. */ + retval = WM_UI_HANDLER_BREAK; if (ELEM(event->type, EVT_RETKEY, EVT_PADENTER, LEFTMOUSE)) { - retval = WM_UI_HANDLER_BREAK; ui_handle_panel_header(C, block, mx, event->type, event->ctrl, event->shift); } else if (event->type == RIGHTMOUSE) { - retval = WM_UI_HANDLER_BREAK; ui_popup_context_menu_for_panel(C, region, block->panel); } break; diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index 99989f86381..4cbb8858bf4 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -864,7 +864,7 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op) static int datalayout_transfer_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return datalayout_transfer_exec(C, op); } return WM_menu_invoke(C, op, event); diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 91c9916d227..d56ee17a73f 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -717,7 +717,7 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op) /* remove functionality */ - BLI_remlink(&ob->modifiers, (ModifierData *)hmd); + BKE_modifier_remove_from_list(ob, (ModifierData *)hmd); BKE_modifier_free((ModifierData *)hmd); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 207057ea6a6..c5783135323 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -156,10 +156,16 @@ bool edit_modifier_poll_generic(struct bContext *C, const bool is_editmode_allowed, const bool is_liboverride_allowed); void edit_modifier_properties(struct wmOperatorType *ot); -bool edit_modifier_invoke_properties(struct bContext *C, - struct wmOperator *op, - const struct wmEvent *event, - int *r_retval); +bool edit_modifier_invoke_properties(struct bContext *C, struct wmOperator *op); +bool edit_modifier_invoke_properties_with_hover_no_active(struct bContext *C, + struct wmOperator *op, + const struct wmEvent *event, + int *r_retval); +bool edit_modifier_invoke_properties_with_hover(struct bContext *C, + struct wmOperator *op, + const struct wmEvent *event, + int *r_retval); + struct ModifierData *edit_modifier_property_get(struct wmOperator *op, struct Object *ob, int type); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index b05f3454391..1a499075d5d 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -36,6 +36,7 @@ #include "DNA_meshdata_types.h" #include "DNA_object_force_types.h" #include "DNA_scene_types.h" +#include "DNA_space_types.h" #include "BLI_bitmap.h" #include "BLI_listbase.h" @@ -386,7 +387,7 @@ static bool object_modifier_remove( ob->mode &= ~OB_MODE_PARTICLE_EDIT; } - BLI_remlink(&ob->modifiers, md); + BKE_modifier_remove_from_list(ob, md); BKE_modifier_free(md); BKE_object_free_derived_caches(ob); @@ -446,8 +447,7 @@ bool ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *m } } - BLI_remlink(&ob->modifiers, md); - BLI_insertlinkbefore(&ob->modifiers, md->prev, md); + BLI_listbase_swaplinks(&ob->modifiers, md, md->prev); } else { BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the start of the list"); @@ -471,8 +471,7 @@ bool ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData } } - BLI_remlink(&ob->modifiers, md); - BLI_insertlinkafter(&ob->modifiers, md->next, md); + BLI_listbase_swaplinks(&ob->modifiers, md, md->next); } else { BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the end of the list"); @@ -898,7 +897,7 @@ bool ED_object_modifier_apply(Main *bmain, md_eval->mode = prev_mode; if (!keep_modifier) { - BLI_remlink(&ob->modifiers, md); + BKE_modifier_remove_from_list(ob, md); BKE_modifier_free(md); } @@ -916,6 +915,7 @@ int ED_object_modifier_copy( nmd = object_copy_particle_system(bmain, scene, ob, ((ParticleSystemModifierData *)md)->psys); BLI_remlink(&ob->modifiers, nmd); BLI_insertlinkafter(&ob->modifiers, md, nmd); + BKE_object_modifier_set_active(ob, nmd); return true; } @@ -1027,7 +1027,7 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) /** \} */ /* ------------------------------------------------------------------- */ -/** \name Generic Functions For Operators +/** \name Generic Poll Function and Properties * * Using modifier names and data context. * \{ */ @@ -1093,16 +1093,15 @@ static void edit_modifier_report_property(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_HIDDEN); } -/** - * \param event: If this isn't NULL, the operator will also look for panels underneath - * the cursor with customdata set to a modifier. - * \param r_retval: This should be used if #event is used in order to to return - * #OPERATOR_PASS_THROUGH to check other operators with the same key set. - */ -bool edit_modifier_invoke_properties(bContext *C, - wmOperator *op, - const wmEvent *event, - int *r_retval) +/** \} */ + +/* ------------------------------------------------------------------- */ +/** \name Generic Invoke Functions + * + * Using modifier names and data context. + * \{ */ + +static bool edit_modifier_properties_base(bContext *C, wmOperator *op) { if (RNA_struct_property_is_set(op->ptr, "modifier")) { return true; @@ -1115,27 +1114,101 @@ bool edit_modifier_invoke_properties(bContext *C, return true; } - /* Check the custom data of panels under the mouse for a modifier. */ - if (event != NULL) { - PointerRNA *panel_ptr = UI_region_panel_custom_data_under_cursor(C, event); + return false; +} - if (!(panel_ptr == NULL || RNA_pointer_is_null(panel_ptr))) { - if (RNA_struct_is_a(panel_ptr->type, &RNA_Modifier)) { - ModifierData *md = panel_ptr->data; - RNA_string_set(op->ptr, "modifier", md->name); - return true; - } - BLI_assert(r_retval != NULL); /* We need the return value in this case. */ - if (r_retval != NULL) { - *r_retval = (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED); - } - return false; +static bool edit_modifier_properties_active(bContext *C, wmOperator *op) +{ + Object *ob = ED_object_active_context(C); + if (ob != NULL) { + ModifierData *md = BKE_object_active_modifier(ob); + if (md != NULL) { + RNA_string_set(op->ptr, "modifier", md->name); + return true; } } + return false; +} + +/** + * Check the custom data of panels under the mouse for a modifier. + */ +static bool edit_modifier_properties_hover(bContext *C, + wmOperator *op, + const wmEvent *event, + int *r_retval) +{ + PointerRNA *panel_ptr = UI_region_panel_custom_data_under_cursor(C, event); + + if (!(panel_ptr == NULL || RNA_pointer_is_null(panel_ptr))) { + if (RNA_struct_is_a(panel_ptr->type, &RNA_Modifier)) { + ModifierData *md = panel_ptr->data; + RNA_string_set(op->ptr, "modifier", md->name); + return true; + } + BLI_assert(r_retval != NULL); /* We need the return value in this case. */ + if (r_retval != NULL) { + *r_retval = (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED); + } + return false; + } + if (r_retval != NULL) { *r_retval = OPERATOR_CANCELLED; } + + return false; +} + +/** + * \param event: If this isn't NULL, the operator will also look for panels underneath + * the cursor with customdata set to a modifier. + * \param r_retval: This should be used if #event is used in order to to return + * #OPERATOR_PASS_THROUGH to check other operators with the same key set. + */ +bool edit_modifier_invoke_properties(bContext *C, wmOperator *op) +{ + if (edit_modifier_properties_base(C, op)) { + return true; + } + if (edit_modifier_properties_active(C, op)) { + return true; + } + + return false; +} + +bool edit_modifier_invoke_properties_with_hover_no_active(bContext *C, + wmOperator *op, + const wmEvent *event, + int *r_retval) +{ + if (edit_modifier_properties_base(C, op)) { + return true; + } + if (edit_modifier_properties_hover(C, op, event, r_retval)) { + return true; + } + + return false; +} + +bool edit_modifier_invoke_properties_with_hover(bContext *C, + wmOperator *op, + const wmEvent *event, + int *r_retval) +{ + if (edit_modifier_properties_base(C, op)) { + return true; + } + if (edit_modifier_properties_active(C, op)) { + return true; + } + if (edit_modifier_properties_hover(C, op, event, r_retval)) { + return true; + } + return false; } @@ -1201,7 +1274,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) static int modifier_remove_invoke(bContext *C, wmOperator *op, const wmEvent *event) { int retval; - if (edit_modifier_invoke_properties(C, op, event, &retval)) { + if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) { return modifier_remove_exec(C, op); } return retval; @@ -1247,7 +1320,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op) static int modifier_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *event) { int retval; - if (edit_modifier_invoke_properties(C, op, event, &retval)) { + if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) { return modifier_move_up_exec(C, op); } return retval; @@ -1292,7 +1365,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op) static int modifier_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *event) { int retval; - if (edit_modifier_invoke_properties(C, op, event, &retval)) { + if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) { return modifier_move_down_exec(C, op); } return retval; @@ -1335,7 +1408,7 @@ static int modifier_move_to_index_exec(bContext *C, wmOperator *op) static int modifier_move_to_index_invoke(bContext *C, wmOperator *op, const wmEvent *event) { int retval; - if (edit_modifier_invoke_properties(C, op, event, &retval)) { + if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) { return modifier_move_to_index_exec(C, op); } return retval; @@ -1440,7 +1513,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op) static int modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *event) { int retval; - if (edit_modifier_invoke_properties(C, op, event, &retval)) { + if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) { return modifier_apply_exec(C, op); } return retval; @@ -1484,7 +1557,7 @@ static int modifier_apply_as_shapekey_exec(bContext *C, wmOperator *op) static int modifier_apply_as_shapekey_invoke(bContext *C, wmOperator *op, const wmEvent *event) { int retval; - if (edit_modifier_invoke_properties(C, op, event, &retval)) { + if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) { return modifier_apply_as_shapekey_exec(C, op); } return retval; @@ -1549,7 +1622,7 @@ static int modifier_convert_exec(bContext *C, wmOperator *op) static int modifier_convert_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return modifier_convert_exec(C, op); } return OPERATOR_CANCELLED; @@ -1596,7 +1669,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op) static int modifier_copy_invoke(bContext *C, wmOperator *op, const wmEvent *event) { int retval; - if (edit_modifier_invoke_properties(C, op, event, &retval)) { + if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) { return modifier_copy_exec(C, op); } return retval; @@ -1623,11 +1696,23 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) /** \name Set Active Modifier Operator * \{ */ +static int object_modifier_clear_active(bContext *C) +{ + Object *ob = ED_object_active_context(C); + + BKE_object_modifier_set_active(ob, NULL); + + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); + + return OPERATOR_FINISHED; +} + static int modifier_set_active_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); + /* If there is no modifier set for this operator, clear the active modifier field. */ BKE_object_modifier_set_active(ob, md); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); @@ -1637,10 +1722,21 @@ static int modifier_set_active_exec(bContext *C, wmOperator *op) static int modifier_set_active_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - int retval; - if (edit_modifier_invoke_properties(C, op, event, &retval)) { + int retval; /* Dummy variable, this operator always clears the active if no modifier is set. */ + if (edit_modifier_invoke_properties_with_hover_no_active(C, op, event, &retval)) { return modifier_set_active_exec(C, op); } + + /* In the modifier tab (not for grease pencil), allow any event to clear the active modifier. + * These checks are important, otherwise clicks in other tabs will still clear the active + * modifier. And they are necessary because we don't want to limit where the operator could + * run with the poll function. */ + SpaceProperties *sbuts = CTX_wm_space_properties(C); + Object *ob = ED_object_active_context(C); + if (sbuts != NULL && sbuts->mainb == BCONTEXT_MODIFIER && ob->type != OB_GPENCIL) { + return object_modifier_clear_active(C); + } + return retval; } @@ -1695,7 +1791,7 @@ static int multires_higher_levels_delete_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return multires_higher_levels_delete_exec(C, op); } return OPERATOR_CANCELLED; @@ -1771,7 +1867,7 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) static int multires_subdivide_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return multires_subdivide_exec(C, op); } return OPERATOR_CANCELLED; @@ -1846,7 +1942,7 @@ static int multires_reshape_exec(bContext *C, wmOperator *op) static int multires_reshape_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return multires_reshape_exec(C, op); } return OPERATOR_CANCELLED; @@ -1907,7 +2003,7 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEv Mesh *me = ob->data; char path[FILE_MAX]; - if (!edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (!edit_modifier_invoke_properties(C, op)) { return OPERATOR_CANCELLED; } @@ -2025,7 +2121,7 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op) static int multires_base_apply_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return multires_base_apply_exec(C, op); } return OPERATOR_CANCELLED; @@ -2077,7 +2173,7 @@ static int multires_unsubdivide_exec(bContext *C, wmOperator *op) static int multires_unsubdivide_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return multires_unsubdivide_exec(C, op); } return OPERATOR_CANCELLED; @@ -2133,7 +2229,7 @@ static int multires_rebuild_subdiv_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return multires_rebuild_subdiv_exec(C, op); } return OPERATOR_CANCELLED; @@ -2496,7 +2592,7 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op) static int skin_armature_create_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return skin_armature_create_exec(C, op); } return OPERATOR_CANCELLED; @@ -2572,7 +2668,7 @@ static int correctivesmooth_bind_exec(bContext *C, wmOperator *op) static int correctivesmooth_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return correctivesmooth_bind_exec(C, op); } return OPERATOR_CANCELLED; @@ -2647,7 +2743,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) static int meshdeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return meshdeform_bind_exec(C, op); } return OPERATOR_CANCELLED; @@ -2701,7 +2797,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op) static int explode_refresh_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return explode_refresh_exec(C, op); } return OPERATOR_CANCELLED; @@ -2902,7 +2998,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) static int ocean_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return ocean_bake_exec(C, op); } return OPERATOR_CANCELLED; @@ -2979,7 +3075,7 @@ static int laplaciandeform_bind_exec(bContext *C, wmOperator *op) static int laplaciandeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return laplaciandeform_bind_exec(C, op); } return OPERATOR_CANCELLED; @@ -3046,7 +3142,7 @@ static int surfacedeform_bind_exec(bContext *C, wmOperator *op) static int surfacedeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - if (edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (edit_modifier_invoke_properties(C, op)) { return surfacedeform_bind_exec(C, op); } return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 29393e8a8d1..8841b1955bf 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -550,7 +550,7 @@ static void object_remove_parent_deform_modifiers(Object *ob, const Object *par) /* free modifier if match */ if (free) { - BLI_remlink(&ob->modifiers, md); + BKE_modifier_remove_from_list(ob, md); BKE_modifier_free(md); } } diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 022408ba32e..b84859543b7 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -676,6 +676,23 @@ static void rna_Modifier_dependency_update(Main *bmain, Scene *scene, PointerRNA DEG_relations_tag_update(bmain); } +static void rna_Modifier_is_active_set(PointerRNA *ptr, bool value) +{ + ModifierData *md = ptr->data; + + if (value) { + /* Disable the active flag of all other modif-iers. */ + for (ModifierData *prev_md = md->prev; prev_md != NULL; prev_md = prev_md->prev) { + prev_md->flag &= ~eModifierFlag_Active; + } + for (ModifierData *next_md = md->next; next_md != NULL; next_md = next_md->next) { + next_md->flag &= ~eModifierFlag_Active; + } + + md->flag |= eModifierFlag_Active; + } +} + /* Vertex Groups */ # define RNA_MOD_VGROUP_NAME_SET(_type, _prop) \ @@ -7261,8 +7278,9 @@ void RNA_def_modifier(BlenderRNA *brna) prop = RNA_def_property(srna, "is_active", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", eModifierFlag_Active); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Modifier_is_active_set"); RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_ui_text(prop, "Active", "The active modifier in the list"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL); diff --git a/source/blender/modifiers/intern/MOD_ui_common.c b/source/blender/modifiers/intern/MOD_ui_common.c index 6c348474390..166d77624e8 100644 --- a/source/blender/modifiers/intern/MOD_ui_common.c +++ b/source/blender/modifiers/intern/MOD_ui_common.c @@ -306,20 +306,11 @@ static void modifier_panel_header(const bContext *C, Panel *panel) int index = BLI_findindex(&ob->modifiers, md); /* Modifier Icon. */ - uiItemS_ex(layout, 0.1f); sub = uiLayoutRow(layout, true); if (mti->isDisabled && mti->isDisabled(scene, md, 0)) { uiLayoutSetRedAlert(sub, true); } - uiLayoutSetEmboss(sub, UI_EMBOSS_NONE); - uiItemFullO(sub, - "OBJECT_OT_modifier_set_active", - "", - RNA_struct_ui_icon(ptr->type), - NULL, - WM_OP_INVOKE_DEFAULT, - 0, - NULL); + uiItemL(sub, "", RNA_struct_ui_icon(ptr->type)); row = uiLayoutRow(layout, true); diff --git a/source/blender/nodes/geometry/node_geometry_tree.cc b/source/blender/nodes/geometry/node_geometry_tree.cc index dc806e7c2da..cce6bded541 100644 --- a/source/blender/nodes/geometry/node_geometry_tree.cc +++ b/source/blender/nodes/geometry/node_geometry_tree.cc @@ -28,6 +28,7 @@ #include "DNA_modifier_types.h" #include "DNA_node_types.h" +#include "DNA_space_types.h" #include "RNA_access.h" @@ -48,7 +49,14 @@ static void geometry_node_tree_get_from_context(const bContext *C, const ModifierData *md = BKE_object_active_modifier(ob); + SpaceNode *snode = CTX_wm_space_node(C); + BLI_assert(snode != NULL); + + /* Don't change the node tree if there is no active modifier. */ if (md == nullptr) { + *r_ntree = snode->nodetree; + *r_from = snode->id; + *r_id = snode->from; return; } @@ -57,7 +65,6 @@ static void geometry_node_tree_get_from_context(const bContext *C, if (nmd->node_group != nullptr) { *r_from = &ob->id; *r_id = &ob->id; - // *r_id = &nmd->node_group->id; *r_ntree = nmd->node_group; } } |