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.
This commit is contained in:
parent
18ace3b541
commit
f81c514bd2
@ -3617,6 +3617,13 @@ static int object_transform_to_mouse_exec(bContext *C, wmOperator *op)
|
|||||||
BKE_report(op->reports, RPT_ERROR, "Object not found");
|
BKE_report(op->reports, RPT_ERROR, "Object not found");
|
||||||
return OPERATOR_CANCELLED;
|
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. */
|
/* Ensure the locations are updated so snap reads the evaluated active location. */
|
||||||
CTX_data_ensure_evaluated_depsgraph(C);
|
CTX_data_ensure_evaluated_depsgraph(C);
|
||||||
|
|
||||||
|
@ -526,6 +526,12 @@ static void view3d_ob_drop_draw_activate(struct wmDropBox *drop, wmDrag *drag)
|
|||||||
return;
|
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 = drop->draw_data = ED_view3d_cursor_snap_active();
|
||||||
state->draw_plane = true;
|
state->draw_plane = true;
|
||||||
|
|
||||||
@ -552,9 +558,11 @@ 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))
|
static void view3d_ob_drop_draw_deactivate(struct wmDropBox *drop, wmDrag *UNUSED(drag))
|
||||||
{
|
{
|
||||||
V3DSnapCursorState *state = drop->draw_data;
|
V3DSnapCursorState *state = drop->draw_data;
|
||||||
|
if (state) {
|
||||||
ED_view3d_cursor_snap_deactive(state);
|
ED_view3d_cursor_snap_deactive(state);
|
||||||
drop->draw_data = NULL;
|
drop->draw_data = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool view3d_ob_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
|
static bool view3d_ob_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
|
||||||
{
|
{
|
||||||
@ -762,13 +770,15 @@ static void view3d_ob_drop_copy_external_asset(wmDrag *drag, wmDropBox *drop)
|
|||||||
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
|
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
|
||||||
ED_outliner_select_sync_from_object_tag(C);
|
ED_outliner_select_sync_from_object_tag(C);
|
||||||
|
|
||||||
V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_get();
|
V3DSnapCursorState *snap_state = drop->draw_data;
|
||||||
|
if (snap_state) {
|
||||||
float obmat_final[4][4];
|
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)
|
static void view3d_collection_drop_copy(wmDrag *drag, wmDropBox *drop)
|
||||||
{
|
{
|
||||||
|
@ -752,6 +752,7 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid);
|
|||||||
|
|
||||||
/* ID drag and drop */
|
/* ID drag and drop */
|
||||||
ID *WM_drag_asset_id_import(wmDragAsset *asset_drag, int flag_extra);
|
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);
|
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(const struct wmDrag *drag, short idcode);
|
||||||
struct ID *WM_drag_get_local_ID_from_event(const struct wmEvent *event, short idcode);
|
struct ID *WM_drag_get_local_ID_from_event(const struct wmEvent *event, short idcode);
|
||||||
|
@ -577,6 +577,16 @@ ID *WM_drag_asset_id_import(wmDragAsset *asset_drag, const int flag_extra)
|
|||||||
return NULL;
|
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
|
* 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).
|
* that depending on what was chosen by the drag-box (currently append only in fact).
|
||||||
|
Loading…
Reference in New Issue
Block a user