diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/object/object_add.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 22 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 10 |
4 files changed, 34 insertions, 6 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index f5a304a718b..be8fe3e6db7 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -3617,6 +3617,13 @@ static int object_transform_to_mouse_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Object not found"); return OPERATOR_CANCELLED; } + + /* Don't transform a linked object. There's just nothing to do here in this case, so return + * #OPERATOR_FINISHED. */ + if (ID_IS_LINKED(ob)) { + return OPERATOR_FINISHED; + } + /* Ensure the locations are updated so snap reads the evaluated active location. */ CTX_data_ensure_evaluated_depsgraph(C); 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) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index f9bc309af9f..26db02be289 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -752,6 +752,7 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid); /* ID drag and drop */ ID *WM_drag_asset_id_import(wmDragAsset *asset_drag, int flag_extra); +bool WM_drag_asset_will_import_linked(const wmDrag *drag); void WM_drag_add_local_ID(struct wmDrag *drag, struct ID *id, struct ID *from_parent); struct ID *WM_drag_get_local_ID(const struct wmDrag *drag, short idcode); struct ID *WM_drag_get_local_ID_from_event(const struct wmEvent *event, short idcode); diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 21f5925b037..638aca6c98e 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -577,6 +577,16 @@ ID *WM_drag_asset_id_import(wmDragAsset *asset_drag, const int flag_extra) return NULL; } +bool WM_drag_asset_will_import_linked(const wmDrag *drag) +{ + if (drag->type != WM_DRAG_ASSET) { + return false; + } + + const wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0); + return asset_drag->import_type == FILE_ASSET_IMPORT_LINK; +} + /** * When dragging a local ID, return that. Otherwise, if dragging an asset-handle, link or append * that depending on what was chosen by the drag-box (currently append only in fact). |