diff options
8 files changed, 90 insertions, 62 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 2f352a880ca..1d28d7f52c7 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -248,7 +248,7 @@ void BKE_object_data_select_update( void BKE_object_eval_flush_base_flags( struct Depsgraph *depsgraph, - struct ViewLayer *view_layer, + struct Scene *scene, const int view_layer_index, struct Object *object, int base_index, const bool is_from_set); diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index d043fcc9d1c..c8612c1d55c 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -445,9 +445,14 @@ void BKE_object_data_select_update(Depsgraph *UNUSED(depsgraph), } void BKE_object_eval_flush_base_flags(Depsgraph *UNUSED(depsgraph), - ViewLayer *view_layer, - Object *object, int base_index, bool is_from_set) + Scene *scene, const int view_layer_index, + Object *object, int base_index, + const bool is_from_set) { + /* TODO(sergey): Avoid list lookup. */ + BLI_assert(view_layer_index >= 0); + ViewLayer *view_layer = BLI_findlink(&scene->view_layers, view_layer_index); + BLI_assert(view_layer != NULL); BLI_assert(view_layer->object_bases_array != NULL); BLI_assert(base_index >= 0); BLI_assert(base_index < MEM_allocN_len(view_layer->object_bases_array) / sizeof(Base *)); diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index cab675ccd2e..62710240109 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -387,6 +387,9 @@ UndoStep *BKE_undosys_step_push_init(UndoStack *ustack, bContext *C, const char return BKE_undosys_step_push_init_with_type(ustack, C, name, ut); } +/** + * \param C: Can be NULL from some callers if their encoding function doesn't need it + */ bool BKE_undosys_step_push_with_type(UndoStack *ustack, bContext *C, const char *name, const UndoType *ut) { UNDO_NESTED_ASSERT(false); @@ -395,7 +398,7 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack, bContext *C, const char /* Might not be final place for this to be called - probably only want to call it from some * undo handlers, not all of them? */ - BKE_main_override_static_operations_create(CTX_data_main(C), false); + BKE_main_override_static_operations_create(G.main, false); /* Remove all undos after (also when 'ustack->step_active == NULL'). */ while (ustack->steps.last != ustack->step_active) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index af321cb70e8..2e251c84fda 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -526,14 +526,16 @@ void DepsgraphNodeBuilder::build_object_flags( if (base_index == -1) { return; } - /* TODO(sergey): Is this really best component to be used? */ + Scene *scene_cow = get_cow_datablock(scene_); Object *object_cow = get_cow_datablock(object); const bool is_from_set = (linked_state == DEG_ID_LINKED_VIA_SET); + /* TODO(sergey): Is this really best component to be used? */ add_operation_node(&object->id, DEG_NODE_TYPE_LAYER_COLLECTIONS, function_bind(BKE_object_eval_flush_base_flags, _1, - view_layer_, + scene_cow, + view_layer_index_, object_cow, base_index, is_from_set), DEG_OPCODE_OBJECT_BASE_FLAGS); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 757cacc6050..0180aa3b734 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -234,6 +234,7 @@ protected: /* State which demotes currently built entities. */ Scene *scene_; ViewLayer *view_layer_; + int view_layer_index_; GHash *cow_id_hash_; BuilderMap built_map_; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc index 390619aeeaa..750b0054ee5 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc @@ -70,6 +70,8 @@ void DepsgraphNodeBuilder::build_view_layer( ViewLayer *view_layer, eDepsNode_LinkedState_Type linked_state) { + view_layer_index_ = BLI_findindex(&scene->view_layers, view_layer); + BLI_assert(view_layer_index_ != -1); /* Scene ID block. */ add_id_node(&scene->id); /* Time source. */ @@ -134,14 +136,12 @@ void DepsgraphNodeBuilder::build_view_layer( build_movieclip(clip); } /* Collections. */ - int view_layer_index = BLI_findindex(&scene->view_layers, view_layer); - BLI_assert(view_layer_index != -1); add_operation_node(&scene->id, DEG_NODE_TYPE_LAYER_COLLECTIONS, function_bind(BKE_layer_eval_view_layer_indexed, _1, &scene_cow->id, - view_layer_index), + view_layer_index_), DEG_OPCODE_VIEW_LAYER_EVAL); /* Parameters evaluation for scene relations mainly. */ add_operation_node(&scene->id, diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index ce044d1cf48..2c6b84c2aef 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -391,34 +391,39 @@ static EditBone *get_nearest_editbonepoint( bool findunsel, bool use_cycle, Base **r_base, int *r_selmask) { - bArmature *arm = (bArmature *)vc->obedit->data; - EditBone *ebone_next_act = arm->act_edbone; - - EditBone *ebone; - rcti rect; - unsigned int buffer[MAXPICKBUF]; - unsigned int hitresult, besthitresult = BONESEL_NOSEL; - int i, mindep = 5; - int hits12, hits5 = 0; - - static int last_mval[2] = {-100, -100}; + uint buffer[MAXPICKBUF]; + struct { + uint hitresult; + Base *base; + EditBone *ebone; + } best = { + .hitresult = BONESEL_NOSEL, + .base = NULL, + .ebone = NULL, + }; /* find the bone after the current active bone, so as to bump up its chances in selection. * this way overlapping bones will cycle selection state as with objects. */ - if (ebone_next_act && - EBONE_VISIBLE(arm, ebone_next_act) && - ebone_next_act->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) + EditBone *ebone_next_act = ((bArmature *)vc->obedit->data)->act_edbone; { - ebone_next_act = ebone_next_act->next ? ebone_next_act->next : arm->edbo->first; - } - else { - ebone_next_act = NULL; + bArmature *arm = (bArmature *)vc->obedit->data; + if (ebone_next_act && + EBONE_VISIBLE(arm, ebone_next_act) && + ebone_next_act->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) + { + ebone_next_act = ebone_next_act->next ? ebone_next_act->next : arm->edbo->first; + } + else { + ebone_next_act = NULL; + } } bool do_nearest = false; /* define if we use solid nearest select or not */ if (use_cycle) { + static int last_mval[2] = {-100, -100}; + if (vc->v3d->drawtype > OB_WIRE) { do_nearest = true; if (len_manhattan_v2v2_int(vc->mval, last_mval) < 3) { @@ -434,32 +439,35 @@ static EditBone *get_nearest_editbonepoint( } /* matching logic from 'mixed_bones_object_selectbuffer' */ - const int select_mode = (do_nearest ? VIEW3D_SELECT_PICK_NEAREST : VIEW3D_SELECT_PICK_ALL); int hits = 0; /* we _must_ end cache before return, use 'goto cache_end' */ view3d_opengl_select_cache_begin(); - BLI_rcti_init_pt_radius(&rect, vc->mval, 12); - hits12 = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, select_mode); - if (hits12 == 1) { - hits = selectbuffer_ret_hits_12(buffer, hits12); - goto cache_end; - } - else if (hits12 > 0) { - int offs; - - offs = 4 * hits12; - BLI_rcti_init_pt_radius(&rect, vc->mval, 5); - hits5 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode); - - if (hits5 == 1) { - hits = selectbuffer_ret_hits_5(buffer, hits12, hits5); + { + const int select_mode = (do_nearest ? VIEW3D_SELECT_PICK_NEAREST : VIEW3D_SELECT_PICK_ALL); + rcti rect; + BLI_rcti_init_pt_radius(&rect, vc->mval, 12); + const int hits12 = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, select_mode); + if (hits12 == 1) { + hits = selectbuffer_ret_hits_12(buffer, hits12); goto cache_end; } + else if (hits12 > 0) { + int offs; + + offs = 4 * hits12; + BLI_rcti_init_pt_radius(&rect, vc->mval, 5); + const int hits5 = view3d_opengl_select(vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode); + + if (hits5 == 1) { + hits = selectbuffer_ret_hits_5(buffer, hits12, hits5); + goto cache_end; + } - if (hits5 > 0) { hits = selectbuffer_ret_hits_5(buffer, hits12, hits5); goto cache_end; } - else { hits = selectbuffer_ret_hits_12(buffer, hits12); goto cache_end; } + if (hits5 > 0) { hits = selectbuffer_ret_hits_5(buffer, hits12, hits5); goto cache_end; } + else { hits = selectbuffer_ret_hits_12(buffer, hits12); goto cache_end; } + } } cache_end: @@ -471,16 +479,20 @@ cache_end: /* See if there are any selected bones in this group */ if (hits > 0) { if (hits == 1) { - if (!(buffer[3] & BONESEL_NOSEL)) - besthitresult = buffer[3]; + if (!(buffer[3] & BONESEL_NOSEL)) { + best.hitresult = buffer[3]; + best.base = ED_armature_base_and_ebone_from_select_buffer( + bases, bases_len, best.hitresult, &best.ebone); + } } else { - for (i = 0; i < hits; i++) { - hitresult = buffer[3 + (i * 4)]; + int dep_min = 5; + for (int i = 0; i < hits; i++) { + const uint hitresult = buffer[3 + (i * 4)]; if (!(hitresult & BONESEL_NOSEL)) { Base *base = NULL; + EditBone *ebone; base = ED_armature_base_and_ebone_from_select_buffer(bases, bases_len, hitresult, &ebone); - arm = base->object->data; int dep; /* clicks on bone points get advantage */ @@ -515,32 +527,36 @@ cache_end: dep -= 1; } - if (dep < mindep) { - mindep = dep; - besthitresult = hitresult; + if (dep < dep_min) { + dep_min = dep; + best.hitresult = hitresult; + best.base = base; + best.ebone = ebone; } } } } - if (!(besthitresult & BONESEL_NOSEL)) { - Base *base = NULL; - base = ED_armature_base_and_ebone_from_select_buffer(bases, bases_len, hitresult, &ebone); - arm = base->object->data; - *r_base = base; + if (!(best.hitresult & BONESEL_NOSEL)) { + *r_base = best.base; *r_selmask = 0; - if (besthitresult & BONESEL_ROOT) + if (best.hitresult & BONESEL_ROOT) { *r_selmask |= BONE_ROOTSEL; - if (besthitresult & BONESEL_TIP) + } + if (best.hitresult & BONESEL_TIP) { *r_selmask |= BONE_TIPSEL; - if (besthitresult & BONESEL_BONE) + } + if (best.hitresult & BONESEL_BONE) { *r_selmask |= BONE_SELECTED; - return ebone; + } + MEM_freeN(bases); + return best.ebone; } } *r_selmask = 0; *r_base = NULL; + MEM_freeN(bases); return NULL; } diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 3afa682e75f..1747d2fbc23 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -147,6 +147,7 @@ static void rna_Armature_redraw_data(Main *UNUSED(bmain), Scene *UNUSED(scene), { ID *id = ptr->id.data; + DEG_id_tag_update(id, DEG_TAG_COPY_ON_WRITE); WM_main_add_notifier(NC_GEOM | ND_DATA, id); } |