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:
authorJulian Eisel <julian@blender.org>2021-10-26 21:25:19 +0300
committerJulian Eisel <julian@blender.org>2021-10-26 21:30:51 +0300
commitf81c514bd22a25b2c6951e506f64252e0f5e84bf (patch)
tree1113861df8300cb3c835defd9d72474ea5a06b7c /source/blender/editors/space_view3d/space_view3d.c
parent18ace3b541eec120ad75fa7bbbaa15d9fb9b6c12 (diff)
Assets: Disable snap-dragging for linking object assets
The location of a linked object isn't editable, or at least it will be reset when reloading the file. So the drag & drop shouldn't even pretend like this would work, so disable the snapping of the object and the bounding-box to show the snapped object location while dragging.
Diffstat (limited to 'source/blender/editors/space_view3d/space_view3d.c')
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 559e11e96a1..37d013e7bd9 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -526,6 +526,12 @@ static void view3d_ob_drop_draw_activate(struct wmDropBox *drop, wmDrag *drag)
return;
}
+ /* Don't use the snap cursor when linking the object. Object transform isn't editable then and
+ * would be reset on reload. */
+ if (WM_drag_asset_will_import_linked(drag)) {
+ return;
+ }
+
state = drop->draw_data = ED_view3d_cursor_snap_active();
state->draw_plane = true;
@@ -552,8 +558,10 @@ static void view3d_ob_drop_draw_activate(struct wmDropBox *drop, wmDrag *drag)
static void view3d_ob_drop_draw_deactivate(struct wmDropBox *drop, wmDrag *UNUSED(drag))
{
V3DSnapCursorState *state = drop->draw_data;
- ED_view3d_cursor_snap_deactive(state);
- drop->draw_data = NULL;
+ if (state) {
+ ED_view3d_cursor_snap_deactive(state);
+ drop->draw_data = NULL;
+ }
}
static bool view3d_ob_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
@@ -762,12 +770,14 @@ static void view3d_ob_drop_copy_external_asset(wmDrag *drag, wmDropBox *drop)
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
ED_outliner_select_sync_from_object_tag(C);
- V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_get();
- float obmat_final[4][4];
+ V3DSnapCursorState *snap_state = drop->draw_data;
+ if (snap_state) {
+ float obmat_final[4][4];
- view3d_ob_drop_matrix_from_snap(snap_state, (Object *)id, obmat_final);
+ view3d_ob_drop_matrix_from_snap(snap_state, (Object *)id, obmat_final);
- RNA_float_set_array(drop->ptr, "matrix", &obmat_final[0][0]);
+ RNA_float_set_array(drop->ptr, "matrix", &obmat_final[0][0]);
+ }
}
static void view3d_collection_drop_copy(wmDrag *drag, wmDropBox *drop)