Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-11-16 08:48:44 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-11-16 08:48:44 +0300
commit64ab084ca5fa171d39e799f143cff1d661267cf3 (patch)
tree30e232e915e8777542a0e0c38e8566ae09338235 /source/blender/blenkernel/intern/layer_utils.c
parenta3a6d6a670f1074de3a83fef2f58c72bd66b270d (diff)
Grease Pencil: adjust behavior of target object detection
First detect the other selected object, then check it can be written to. Otherwise the target object could be the first one found when looping over objects which is random from the user perspective. Move the type check to the operator, which also checks the data isn't library data which was being ignored.
Diffstat (limited to 'source/blender/blenkernel/intern/layer_utils.c')
-rw-r--r--source/blender/blenkernel/intern/layer_utils.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/layer_utils.c b/source/blender/blenkernel/intern/layer_utils.c
index b48aef2d05e..974a5a24e8a 100644
--- a/source/blender/blenkernel/intern/layer_utils.c
+++ b/source/blender/blenkernel/intern/layer_utils.c
@@ -192,15 +192,28 @@ bool BKE_view_layer_filter_edit_mesh_has_edges(Object *ob, void *UNUSED(user_dat
return false;
}
-/** Select first selected object of the type specified. */
-Object *BKE_view_layer_first_selected_object_by_type(struct ViewLayer *view_layer,
- const struct View3D *v3d,
- const short ob_type)
+/**
+ * Use this in rare cases we need to detect a pair of objects (active, selected).
+ * This returns the other non-active selected object.
+ *
+ * Returns NULL with it finds multiple other selected objects
+ * as behavior in this case would be random from the user perspective.
+ */
+Object *BKE_view_layer_non_active_selected_object(struct ViewLayer *view_layer,
+ const struct View3D *v3d)
{
+ Object *ob_active = OBACT(view_layer);
Object *ob_result = NULL;
FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob_iter) {
- if (ob_iter->type == ob_type) {
+ if (ob_iter == ob_active) {
+ continue;
+ }
+
+ if (ob_result == NULL) {
ob_result = ob_iter;
+ }
+ else {
+ ob_result = NULL;
break;
}
}