diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_object.h | 4 | ||||
-rw-r--r-- | source/blender/editors/include/ED_transform.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 17 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 3 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 130 | ||||
-rw-r--r-- | source/blender/editors/scene/scene_edit.c | 8 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_detail.c | 5 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 16 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_convert.c | 9 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_convert.h | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_convert_sculpt.c | 17 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_mode.c | 3 |
12 files changed, 49 insertions, 167 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index cd25ee54392..5c33513f0a4 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -295,10 +295,6 @@ struct Object *ED_object_add_type(struct bContext *C, unsigned short local_view_bits) ATTR_NONNULL(1) ATTR_RETURNS_NONNULL; -void ED_object_single_users(struct Main *bmain, - struct Scene *scene, - const bool full, - const bool copy_groups); void ED_object_single_user(struct Main *bmain, struct Scene *scene, struct Object *ob); /* object motion paths */ diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index a62deb9d69f..29ed0485490 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -97,7 +97,6 @@ enum TfmMode { #define CTX_OBMODE_XFORM_OBDATA (1 << 11) /** Transform object parents without moving their children. */ #define CTX_OBMODE_XFORM_SKIP_CHILDREN (1 << 12) -#define CTX_SCULPT (1 << 13) /* Standalone call to get the transformation center corresponding to the current situation * returns 1 if successful, 0 otherwise (usually means there's no selection) diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 33f600f30a1..5f56a93c5eb 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -486,10 +486,13 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr /** * Recursive implementation for #UI_panel_set_expand_from_list_data. + * + * \return Whether the closed flag for the panel or any subpanels changed. */ -static void panel_set_expand_from_list_data_recursive(Panel *panel, short flag, short *flag_index) +static bool panel_set_expand_from_list_data_recursive(Panel *panel, short flag, short *flag_index) { bool open = (flag & (1 << *flag_index)); + bool changed = (open == (bool)(panel->flag & PNL_CLOSEDY)); if (open) { panel->flag &= ~PNL_CLOSEDY; } @@ -498,8 +501,9 @@ static void panel_set_expand_from_list_data_recursive(Panel *panel, short flag, } LISTBASE_FOREACH (Panel *, child, &panel->children) { *flag_index = *flag_index + 1; - panel_set_expand_from_list_data_recursive(child, flag, flag_index); + changed |= panel_set_expand_from_list_data_recursive(child, flag, flag_index); } + return changed; } /** @@ -518,7 +522,11 @@ void UI_panel_set_expand_from_list_data(const bContext *C, Panel *panel) short expand_flag = panel->type->get_list_data_expand_flag(C, panel); short flag_index = 0; - panel_set_expand_from_list_data_recursive(panel, expand_flag, &flag_index); + + /* Start panel animation if the open state was changed. */ + if (panel_set_expand_from_list_data_recursive(panel, expand_flag, &flag_index)) { + panel_activate_state(C, panel, PANEL_STATE_ANIMATION); + } } /** @@ -555,7 +563,8 @@ static void set_panels_list_data_expand_flag(const bContext *C, ARegion *region) continue; } - if (panel->type->flag & PNL_INSTANCED) { + /* Check for #PNL_ACTIVE so we only set the expand flag for active panels. */ + if (panel_type->flag & PNL_INSTANCED && panel->runtime_flag & PNL_ACTIVE) { short expand_flag = 0; /* Initialize to quite complaining compiler, value not used. */ short flag_index = 0; get_panel_expand_flag(panel, &expand_flag, &flag_index); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 0bd49f74db9..a6c5814e88a 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1259,7 +1259,8 @@ static int modifier_move_to_index_invoke(bContext *C, wmOperator *op, const wmEv void OBJECT_OT_modifier_move_to_index(wmOperatorType *ot) { ot->name = "Move Active Modifier to Index"; - ot->description = "Move the active modifier to an index in the stack"; + ot->description = + "Change the modifier's index in the stack so it evaluates after the set number of others"; ot->idname = "OBJECT_OT_modifier_move_to_index"; ot->invoke = modifier_move_to_index_invoke; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 0e8545e07ba..eed3f2ea90c 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1853,27 +1853,6 @@ void ED_object_single_user(Main *bmain, Scene *scene, Object *ob) BKE_main_id_clear_newpoins(bmain); } -static void new_id_matar(Main *bmain, Material **matar, const int totcol) -{ - ID *id; - int a; - - for (a = 0; a < totcol; a++) { - id = (ID *)matar[a]; - if (id && !ID_IS_LINKED(id)) { - if (id->newid) { - matar[a] = (Material *)id->newid; - id_us_plus(id->newid); - id_us_min(id); - } - else if (id->us > 1) { - matar[a] = ID_NEW_SET(id, BKE_material_copy(bmain, matar[a])); - id_us_min(id); - } - } - } -} - static void single_obdata_users( Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, const int flag) { @@ -2017,115 +1996,6 @@ static void single_mat_users( FOREACH_OBJECT_FLAG_END; } -static void single_mat_users_expand(Main *bmain) -{ - /* only when 'parent' blocks are LIB_TAG_NEW */ - Object *ob; - Mesh *me; - Curve *cu; - MetaBall *mb; - bGPdata *gpd; - - for (ob = bmain->objects.first; ob; ob = ob->id.next) { - if (ob->id.tag & LIB_TAG_NEW) { - new_id_matar(bmain, ob->mat, ob->totcol); - } - } - - for (me = bmain->meshes.first; me; me = me->id.next) { - if (me->id.tag & LIB_TAG_NEW) { - new_id_matar(bmain, me->mat, me->totcol); - } - } - - for (cu = bmain->curves.first; cu; cu = cu->id.next) { - if (cu->id.tag & LIB_TAG_NEW) { - new_id_matar(bmain, cu->mat, cu->totcol); - } - } - - for (mb = bmain->metaballs.first; mb; mb = mb->id.next) { - if (mb->id.tag & LIB_TAG_NEW) { - new_id_matar(bmain, mb->mat, mb->totcol); - } - } - - for (gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) { - if (gpd->id.tag & LIB_TAG_NEW) { - new_id_matar(bmain, gpd->mat, gpd->totcol); - } - } -} - -/* used for copying scenes */ -void ED_object_single_users(Main *bmain, - Scene *scene, - const bool full, - const bool copy_collections) -{ - single_object_users(bmain, scene, NULL, 0, copy_collections); - - if (full) { - single_obdata_users(bmain, scene, NULL, NULL, 0); - single_object_action_users(bmain, scene, NULL, NULL, 0); - single_mat_users_expand(bmain); - - /* Duplicating obdata and other IDs may require another update of the collections and objects - * pointers, especially regarding drivers and custom props, see T66641. - * Note that this whole scene duplication code and 'make single user' functions have to be - * rewritten at some point to make use of proper modern ID management code, - * but that is no small task. - * For now we are doomed to that kind of band-aid to try to cover most of remapping cases. */ - - /* Will also handle the master collection. */ - BKE_libblock_relink_to_newid(&scene->id); - - /* Collection and object pointers in collections */ - libblock_relink_collection(scene->master_collection, false); - } - - /* Relink nodetrees' pointers that have been duplicated. */ - FOREACH_NODETREE_BEGIN (bmain, ntree, id) { - /* This is a bit convoluted, we want to root ntree of copied IDs and only those, - * so we first check that old ID has been copied and that ntree is root tree of old ID, - * then get root tree of new ID and remap its pointers to new ID... */ - if (id->newid && (&ntree->id != id)) { - ntree = ntreeFromID(id->newid); - BKE_libblock_relink_to_newid(&ntree->id); - } - } - FOREACH_NODETREE_END; - - /* Relink datablock pointer properties */ - { - IDP_RelinkProperty(scene->id.properties); - - FOREACH_SCENE_OBJECT_BEGIN (scene, ob) { - if (!ID_IS_LINKED(ob)) { - IDP_RelinkProperty(ob->id.properties); - } - } - FOREACH_SCENE_OBJECT_END; - - if (scene->nodetree) { - IDP_RelinkProperty(scene->nodetree->id.properties); - LISTBASE_FOREACH (bNode *, node, &scene->nodetree->nodes) { - IDP_RelinkProperty(node->prop); - } - } - - if (scene->world) { - IDP_RelinkProperty(scene->world->id.properties); - } - - if (scene->clip) { - IDP_RelinkProperty(scene->clip->id.properties); - } - } - BKE_main_id_clear_newpoins(bmain); - DEG_relations_tag_update(bmain); -} - /** \} */ /* ------------------------------------------------------------------- */ diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c index d78b1532a39..c32bb69db4e 100644 --- a/source/blender/editors/scene/scene_edit.c +++ b/source/blender/editors/scene/scene_edit.c @@ -61,13 +61,13 @@ Scene *ED_scene_add(Main *bmain, bContext *C, wmWindow *win, eSceneCopyMethod me else { /* different kinds of copying */ Scene *scene_old = WM_window_get_active_scene(win); - scene_new = BKE_scene_copy(bmain, scene_old, method); - - /* these can't be handled in blenkernel currently, so do them here */ + /* We are going to deep-copy collections, objects and various object data, we need to have + * up-to-date obdata for that. */ if (method == SCE_COPY_FULL) { ED_editors_flush_edits(bmain); - ED_object_single_users(bmain, scene_new, true, true); } + + scene_new = BKE_scene_duplicate(bmain, scene_old, method); } WM_window_set_active_scene(bmain, C, win, scene_new); diff --git a/source/blender/editors/sculpt_paint/sculpt_detail.c b/source/blender/editors/sculpt_paint/sculpt_detail.c index b7d1cd8c005..f071deaa219 100644 --- a/source/blender/editors/sculpt_paint/sculpt_detail.c +++ b/source/blender/editors/sculpt_paint/sculpt_detail.c @@ -259,8 +259,11 @@ static int sample_detail(bContext *C, int mx, int my, int mode) ED_view3d_viewcontext_init(C, &vc, depsgraph); Object *ob = vc.obact; - SculptSession *ss = ob->sculpt; + if (ob == NULL) { + return OPERATOR_CANCELLED; + } + SculptSession *ss = ob->sculpt; if (!ss->pbvh) { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 79090bd633e..d8503a28774 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -45,7 +45,6 @@ #include "ED_keyframing.h" #include "ED_node.h" #include "ED_screen.h" -#include "ED_sculpt.h" #include "ED_space_api.h" #include "WM_api.h" @@ -1767,10 +1766,6 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } } - if ((t->options & CTX_SCULPT) && !(t->options & CTX_PAINT_CURVE)) { - ED_sculpt_end_transform(C); - } - if ((prop = RNA_struct_find_property(op->ptr, "correct_uv"))) { RNA_property_boolean_set( op->ptr, prop, (t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) != 0); @@ -1851,13 +1846,6 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } } - if (CTX_wm_view3d(C) != NULL) { - Object *ob = CTX_data_active_object(C); - if (ob && ob->mode == OB_MODE_SCULPT && ob->sculpt) { - options |= CTX_SCULPT; - } - } - t->options = options; t->mode = mode; @@ -1924,10 +1912,6 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve createTransData(C, t); // make TransData structs from selection - if ((t->options & CTX_SCULPT) && !(t->options & CTX_PAINT_CURVE)) { - ED_sculpt_init_transform(C); - } - if (t->data_len_all == 0) { postTrans(C, t); return 0; diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c index fcca9b06451..8496642185d 100644 --- a/source/blender/editors/transform/transform_convert.c +++ b/source/blender/editors/transform/transform_convert.c @@ -916,6 +916,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) case TC_OBJECT_TEXSPACE: special_aftertrans_update__object(C, t); break; + case TC_SCULPT: + special_aftertrans_update__sculpt(C, t); + break; case TC_SEQ_DATA: special_aftertrans_update__sequencer(C, t); break; @@ -932,7 +935,6 @@ void special_aftertrans_update(bContext *C, TransInfo *t) case TC_MESH_UV: case TC_PAINT_CURVE_VERTS: case TC_PARTICLE_VERTS: - case TC_SCULPT: case TC_NONE: default: break; @@ -1013,7 +1015,8 @@ void createTransData(bContext *C, TransInfo *t) convert_type = TC_CURSOR_VIEW3D; } } - else if ((t->options & CTX_SCULPT) && !(t->options & CTX_PAINT_CURVE)) { + else if (!(t->options & CTX_PAINT_CURVE) && (t->spacetype == SPACE_VIEW3D) && ob && + (ob->mode == OB_MODE_SCULPT) && ob->sculpt) { convert_type = TC_SCULPT; } else if (t->options & CTX_TEXTURE) { @@ -1255,7 +1258,7 @@ void createTransData(bContext *C, TransInfo *t) createTransParticleVerts(C, t); break; case TC_SCULPT: - createTransSculpt(t); + createTransSculpt(C, t); init_prop_edit = false; break; case TC_SEQ_DATA: diff --git a/source/blender/editors/transform/transform_convert.h b/source/blender/editors/transform/transform_convert.h index 872f05418c4..fdb6767a267 100644 --- a/source/blender/editors/transform/transform_convert.h +++ b/source/blender/editors/transform/transform_convert.h @@ -176,8 +176,9 @@ void createTransParticleVerts(bContext *C, TransInfo *t); void recalcData_particles(TransInfo *t); /* transform_convert_sculpt.c */ -void createTransSculpt(TransInfo *t); +void createTransSculpt(bContext *C, TransInfo *t); void recalcData_sculpt(TransInfo *t); +void special_aftertrans_update__sculpt(bContext *C, TransInfo *t); /* transform_convert_sequencer.c */ void createTransSeqData(TransInfo *t); diff --git a/source/blender/editors/transform/transform_convert_sculpt.c b/source/blender/editors/transform/transform_convert_sculpt.c index b439c9a1731..0ac6bd9264f 100644 --- a/source/blender/editors/transform/transform_convert_sculpt.c +++ b/source/blender/editors/transform/transform_convert_sculpt.c @@ -39,7 +39,7 @@ * * \{ */ -void createTransSculpt(TransInfo *t) +void createTransSculpt(bContext *C, TransInfo *t) { TransData *td; @@ -99,6 +99,9 @@ void createTransSculpt(TransInfo *t) copy_m3_m3(td->smtx, obmat_inv); copy_m3_m4(td->mtx, ob->obmat); copy_m3_m4(td->axismtx, ob->obmat); + + BLI_assert(!(t->options & CTX_PAINT_CURVE)); + ED_sculpt_init_transform(C); } /** \} */ @@ -113,4 +116,16 @@ void recalcData_sculpt(TransInfo *t) ED_sculpt_update_modal_transform(t->context); } +void special_aftertrans_update__sculpt(bContext *C, TransInfo *t) +{ + Scene *scene = t->scene; + if (ID_IS_LINKED(scene)) { + /* `ED_sculpt_init_transform` was not called in this case. */ + return; + } + + BLI_assert(!(t->options & CTX_PAINT_CURVE)); + ED_sculpt_end_transform(C); +} + /** \} */ diff --git a/source/blender/editors/transform/transform_mode.c b/source/blender/editors/transform/transform_mode.c index c2c880b03ff..e1fd22f06be 100644 --- a/source/blender/editors/transform/transform_mode.c +++ b/source/blender/editors/transform/transform_mode.c @@ -46,6 +46,7 @@ #include "BLT_translation.h" #include "transform.h" +#include "transform_convert.h" #include "transform_snap.h" /* Own include. */ @@ -937,7 +938,7 @@ void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float ma if (td->ext && td->ext->size) { float fsize[3]; - if ((t->options & CTX_SCULPT) || t->flag & (T_OBJECT | T_TEXTURE | T_POSE)) { + if (ELEM(t->data_type, TC_SCULPT, TC_OBJECT, TC_OBJECT_TEXSPACE, TC_POSE)) { float obsizemat[3][3]; /* Reorient the size mat to fit the oriented object. */ mul_m3_m3m3(obsizemat, tmat, td->axismtx); |