Blender V5.3
view3d_dropboxes.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
11#include "BKE_asset.hh"
12#include "BKE_context.hh"
13#include "BKE_idprop.hh"
14#include "BKE_layer.hh"
15#include "BKE_lib_id.hh"
16#include "BKE_lib_remap.hh"
17#include "BKE_library.hh"
18#include "BKE_object.hh"
19
20#include "BLI_listbase.hh"
21#include "BLI_math_matrix_c.hh"
23#include "BLI_math_vector_c.hh"
24
25#include "BLT_translation.hh"
26
27#include "DEG_depsgraph.hh"
29
30#include "DNA_ID.h"
32#include "DNA_screen_types.h"
33
34#include "ED_object.hh"
35#include "ED_outliner.hh"
36#include "ED_screen.hh"
37#include "ED_undo.hh"
38#include "ED_view3d.hh"
39
40#include "UI_resources.hh"
41
42#include "RNA_access.hh"
43
44#include "WM_api.hh"
45#include "WM_types.hh"
46
47#include "view3d_intern.hh" /* own include */
48
49namespace blender {
50
52{
53 ScrArea *area = CTX_wm_area(C);
54 return ED_region_overlap_isect_any_xy(area, event->xy) == false;
55}
56
58 wmDrag *drag,
59 const wmEvent *event)
60{
61 const ScrArea *area = CTX_wm_area(C);
62
63 if (ED_region_overlap_isect_any_xy(area, event->xy)) {
64 return ID_Type(0);
65 }
67 return ID_Type(0);
68 }
69
70 ID *local_id = WM_drag_get_local_ID(drag, 0);
71 if (local_id) {
72 return GS(local_id->name);
73 }
74
75 wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
76 if (asset_drag) {
77 return asset_drag->asset->get_id_type();
78 }
79
80 return ID_Type(0);
81}
82
84 wmDrag *drag,
85 const wmEvent *event,
86 ID_Type id_type)
87{
89 return false;
90 }
91
92 return WM_drag_is_ID_type(drag, id_type);
93}
94
96{
98 if (state) {
99 return state;
100 }
101
103 drop->draw_data = state;
104 state->draw_plane = true;
105 return state;
106}
107
108static void view3d_drop_snap_exit(wmDropBox *drop, wmDrag * /*drag*/)
109{
110 V3DSnapCursorState *state = static_cast<V3DSnapCursorState *>(drop->draw_data);
111 if (state) {
113 drop->draw_data = nullptr;
114 }
115}
116
117static void view3d_ob_drop_on_enter(wmDropBox *drop, wmDrag *drag)
118{
119 /* Don't use the snap cursor when linking the object. Object transform isn't editable then and
120 * would be reset on reload. */
122 return;
123 }
124
126
127 float dimensions[3] = {0.0f};
128 if (drag->type == WM_DRAG_ID) {
129 Object *ob = id_cast<Object *>(WM_drag_get_local_ID(drag, ID_OB));
131 }
132 else {
134 IDProperty *dimensions_prop = BKE_asset_metadata_idprop_find(meta_data, "dimensions");
135 if (dimensions_prop) {
136 copy_v3_v3(dimensions, IDP_array_float_get(dimensions_prop));
137 }
138 }
139
140 if (!is_zero_v3(dimensions)) {
141 mul_v3_v3fl(state->box_dimensions, dimensions, 0.5f);
143 state->draw_box = true;
144 }
145}
146
147static bool view3d_ob_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
148{
149 return view3d_drop_id_in_main_region_poll(C, drag, event, ID_OB);
150}
152{
153 if (!view3d_ob_drop_poll(C, drag, event) || (drag->type != WM_DRAG_ASSET)) {
154 return false;
155 }
156 return true;
157}
158
163static bool view3d_ob_drop_poll_local_id(bContext *C, wmDrag *drag, const wmEvent *event)
164{
165 if (!view3d_ob_drop_poll(C, drag, event) || (drag->type != WM_DRAG_ID)) {
166 return false;
167 }
168 return true;
169}
170
171static bool view3d_collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
172{
173 return view3d_drop_id_in_main_region_poll(C, drag, event, ID_GR);
174}
175
177{
178 if (!view3d_collection_drop_poll(C, drag, event) || (drag->type != WM_DRAG_ID)) {
179 return false;
180 }
181 return true;
182}
183
185 wmDrag *drag,
186 const wmEvent *event)
187{
188 if (!view3d_collection_drop_poll(C, drag, event) || (drag->type != WM_DRAG_ASSET)) {
189 return false;
190 }
191 return true;
192}
193
194static bool view3d_mat_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
195{
196 if (!view3d_drop_id_in_main_region_poll(C, drag, event, ID_MA)) {
197 return false;
198 }
199
201
202 return (ob && ID_IS_EDITABLE(&ob->id) && !ID_IS_OVERRIDE_LIBRARY(&ob->id));
203}
204
206 wmDrag *drag,
207 const int xy[2],
208 wmDropBox * /*drop*/)
209{
210 const std::string name = WM_drag_get_item_name(drag);
211 ARegion *region = CTX_wm_region(C);
212 const int mval[2] = {
213 xy[0] - region->winrct.xmin,
214 xy[1] - region->winrct.ymin,
215 };
216 return ed::object::drop_named_material_tooltip(C, name, mval);
217}
218
219static bool view3d_world_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
220{
221 return view3d_drop_id_in_main_region_poll(C, drag, event, ID_WO);
222}
223
224static bool view3d_object_data_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
225{
227 if (id_type && OB_DATA_SUPPORT_ID(id_type)) {
228 return true;
229 }
230 return false;
231}
232
233static std::string view3d_object_data_drop_tooltip(bContext * /*C*/,
234 wmDrag * /*drag*/,
235 const int /*xy*/[2],
236 wmDropBox * /*drop*/)
237{
238 return TIP_("Create object instance from object-data");
239}
240
241static bool view3d_ima_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
242{
244 return false;
245 }
246 return WM_drag_is_ID_type(drag, ID_IM);
247}
248
250{
252 if (rv3d && (rv3d->persp == RV3D_CAMOB)) {
253 View3D *v3d = CTX_wm_view3d(C);
254 if (v3d && v3d->camera && v3d->camera->type == OB_CAMERA) {
255 return true;
256 }
257 }
258 return false;
259}
260
261static bool view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
262{
263 if (!view3d_ima_drop_poll(C, drag, event)) {
264 return false;
265 }
266
268 return false;
269 }
270
272}
273
274static bool view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
275{
276 if (!view3d_ima_drop_poll(C, drag, event)) {
277 return false;
278 }
279
281
282 if (ob == nullptr) {
283 return true;
284 }
285
286 if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
287 return true;
288 }
289
290 return false;
291}
292
293static bool view3d_geometry_nodes_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
294{
295 if (!view3d_drop_id_in_main_region_poll(C, drag, event, ID_NT)) {
296 return false;
297 }
298
299 if (drag->type == WM_DRAG_ID) {
300 const bNodeTree *node_tree = reinterpret_cast<const bNodeTree *>(
302 if (!node_tree) {
303 return false;
304 }
305 return node_tree->type == NTREE_GEOMETRY;
306 }
307
308 if (drag->type == WM_DRAG_ASSET) {
309 const wmDragAsset *asset_data = WM_drag_get_asset_data(drag, ID_NT);
310 if (!asset_data) {
311 return false;
312 }
313 const AssetMetaData *metadata = &asset_data->asset->get_metadata();
314 const IDProperty *tree_type = BKE_asset_metadata_idprop_find(metadata, "type");
315 if (!tree_type || IDP_int_get(tree_type) != NTREE_GEOMETRY) {
316 return false;
317 }
318 if (wmDropBox *drop_box = drag->drop_state.active_dropbox) {
319 const uint32_t uid = RNA_int_get(drop_box->ptr, "session_uid");
320 const bNodeTree *node_tree = reinterpret_cast<const bNodeTree *>(
322 if (node_tree) {
323 return node_tree->type == NTREE_GEOMETRY;
324 }
325 }
326 }
327 return true;
328}
329
331 wmDrag * /*drag*/,
332 const int xy[2],
333 wmDropBox *drop)
334{
335 ARegion *region = CTX_wm_region(C);
336 int mval[2] = {xy[0] - region->winrct.xmin, xy[1] - region->winrct.ymin};
337 return ed::object::drop_geometry_nodes_tooltip(C, drop->ptr, mval);
338}
339
341 Object *ob,
342 float obmat_final[4][4])
343{
345 BLI_assert(snap_state->draw_box || snap_state->draw_plane);
346 UNUSED_VARS_NDEBUG(snap_state);
347 copy_m4_m3(obmat_final, snap_data->plane_omat);
348 copy_v3_v3(obmat_final[3], snap_data->loc);
349
350 float scale[3];
351 mat4_to_size(scale, ob->object_to_world().ptr());
352 rescale_m4(obmat_final, scale);
353
354 if (const std::optional<Bounds<float3>> bb = BKE_object_boundbox_get(ob)) {
355 float3 offset = math::midpoint(bb->min, bb->max);
356 offset[2] = bb->min[2];
357 mul_mat3_m4_v3(obmat_final, offset);
358 sub_v3_v3(obmat_final[3], offset);
359 }
360}
361
362static void view3d_ob_drop_copy_local_id(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
363{
364 ID *id = WM_drag_get_local_ID(drag, ID_OB);
365
366 RNA_int_set(drop->ptr, "session_uid", id->session_uid);
367 /* Don't duplicate ID's which were just imported. Only do that for existing, local IDs. */
368 BLI_assert(drag->type != WM_DRAG_ASSET);
369
371 float obmat_final[4][4];
372
373 view3d_ob_drop_matrix_from_snap(snap_state, id_cast<Object *>(id), obmat_final);
374
375 RNA_float_set_array(drop->ptr, "matrix", &obmat_final[0][0]);
376}
377
386 Scene &scene,
387 ViewLayer &view_layer,
388 View3D &v3d,
389 const bool localize_parent_collections)
390{
391 Set<Collection *> collections_to_localize;
392
393 if (localize_parent_collections) {
394 /* Collect the collections containing the selected objects. */
395 for (Collection &collection : bmain.collections) {
396 if (ID_IS_LINKED(&collection) &&
397 /* This #BKE_view_layer_has_collection() check requires the view layer to be synced.
398 * That's why we first collect the collections before doing any changes. Otherwise we'd
399 * have to sync the view layer after every "make local" operation. */
400 BKE_view_layer_has_collection(&view_layer, &collection))
401 {
402 FOREACH_SELECTED_OBJECT_BEGIN (&view_layer, &v3d, ob_selected) {
403 if (BKE_collection_has_object(&collection, ob_selected)) {
404 collections_to_localize.add(&collection);
405 break;
406 }
407 }
409 }
410 }
411 }
412
413 Vector<ID *> localized_ids;
414
415 /* Make IDs local. When an ID gets made local, pointers to it will be remapped to the new local
416 * version. However, this doesn't work if the pointer is owned by linked data too.
417 *
418 * E.g. when multiple objects are linked/packed together, they may point to each other. An object
419 * that is being made local may be pointed to by another object that hasn't been made local yet.
420 * So this pointer cannot be remapped yet either.
421 *
422 * That's why we do another remapping pass below, over all IDs that were made local. This catches
423 * remaining old pointers.
424 */
425 {
426 const auto make_id_local = [&bmain, &localized_ids](ID *id) {
429 if (id->newid) {
431 BLI_assert(!ID_IS_LINKED(id->newid));
432
433 localized_ids.append(id);
434 }
435 };
436
437 for (Collection *collection : collections_to_localize) {
438 make_id_local(&collection->id);
439 }
440 BKE_view_layer_synced_ensure(bmain, &scene, &view_layer);
441
442 FOREACH_SELECTED_OBJECT_BEGIN (&view_layer, &v3d, ob_selected) {
443 make_id_local(&ob_selected->id);
444 }
446 }
447
448 /* Make sure all remaining pointers from the linked IDs are replaced by the new one. */
449 {
450 bke::id::IDRemapper remapper;
451 for (ID *id : localized_ids) {
452 remapper.add(id, id->newid);
453 }
455 }
456}
457
458/* Mostly the same logic as #view3d_collection_drop_copy_external_asset(), just different enough to
459 * make sharing code a bit difficult. */
461{
462 /* NOTE(@ideasman42): Selection is handled here, de-selecting objects before append,
463 * using auto-select to ensure the new objects are selected.
464 * This is done so #OBJECT_OT_transform_to_mouse (which runs after this drop handler)
465 * can use the context setup here to place the objects. */
466 BLI_assert(drag->type == WM_DRAG_ASSET);
467
468 wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
469 Main *bmain = CTX_data_main(C);
470 Scene *scene = CTX_data_scene(C);
471 ViewLayer *view_layer = CTX_data_view_layer(C);
472
473 BKE_view_layer_base_deselect_all(*bmain, scene, view_layer);
474
475 ID *id = WM_drag_asset_id_import(C, asset_drag, FILE_AUTOSELECT);
476 if (!id) {
477 return;
478 }
479
480 /* TODO(sergey): Only update relations for the current scene. */
483
484 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
485 Base *base = BKE_view_layer_base_find(view_layer, id_cast<Object *>(id));
486 if (base != nullptr) {
489 }
491
492 /* Make objects local so they can be transformed. */
494 make_selected_objects_local(*bmain, *scene, *view_layer, *CTX_wm_view3d(C), false);
495
496 /* Making the IDs local might result in a new, copied ID. */
497 if (id->newid) {
498 id = id->newid;
499 }
500 }
501
503
504 /* Do after making local, since that changes the session UID. */
505 RNA_int_set(drop->ptr, "session_uid", id->session_uid);
506
507 /* Make sure the depsgraph is evaluated so the new object's transforms are up-to-date.
508 * The evaluated #Object::object_to_world() will be copied back to the original object
509 * and used below. */
511
512 V3DSnapCursorState *snap_state = static_cast<V3DSnapCursorState *>(drop->draw_data);
513 if (snap_state) {
514 float obmat_final[4][4];
515
516 view3d_ob_drop_matrix_from_snap(snap_state, id_cast<Object *>(id), obmat_final);
517
518 RNA_float_set_array(drop->ptr, "matrix", &obmat_final[0][0]);
519 }
520}
521
523{
525 const wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
526 /* Linked collections cannot be transformed except when using instancing. Don't enable
527 * snapping. */
528 if (!asset_drag->import_settings.use_instance_collections) {
529 return;
530 }
531 }
532
534}
535
537 float r_loc[3],
538 float r_rot[3])
539{
541 BLI_assert(snap_state->draw_box || snap_state->draw_plane);
542 UNUSED_VARS_NDEBUG(snap_state);
543
544 mat3_normalized_to_eul(r_rot, snap_data->plane_omat);
545 copy_v3_v3(r_loc, snap_data->loc);
546}
547
549{
550 ID *id = WM_drag_get_local_ID(drag, ID_GR);
551 RNA_int_set(drop->ptr, "session_uid", int(id->session_uid));
552
554
555 float loc[3], rot[3];
557 RNA_float_set_array(drop->ptr, "location", loc);
558 RNA_float_set_array(drop->ptr, "rotation", rot);
559}
560
561/* Mostly the same logic as #view3d_ob_drop_copy_external_asset(), just different enough to make
562 * sharing code a bit difficult. */
564{
565 BLI_assert(drag->type == WM_DRAG_ASSET);
566
567 wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
568 Main *bmain = CTX_data_main(C);
569 Scene *scene = CTX_data_scene(C);
570 ViewLayer *view_layer = CTX_data_view_layer(C);
571
572 BKE_view_layer_base_deselect_all(*bmain, scene, view_layer);
573
574 const bool use_instance_collections = asset_drag->import_settings.use_instance_collections;
575 /* Temporarily disable instancing for the import, the drop operator handles that. */
576 asset_drag->import_settings.use_instance_collections = false;
577
578 ID *id = WM_drag_asset_id_import(C, asset_drag, FILE_AUTOSELECT);
579 if (!id) {
580 return;
581 }
582 Collection *collection = id_cast<Collection *>(id);
583
584 /* Reset temporary override. */
585 asset_drag->import_settings.use_instance_collections = use_instance_collections;
586
587 /* TODO(sergey): Only update relations for the current scene. */
590
591 /* Make an object active, just use the first one in the collection. */
592 CollectionObject *cobject = collection->gobject.first();
593 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
594 Base *base = cobject ? BKE_view_layer_base_find(view_layer, cobject->ob) : nullptr;
595 if (base) {
599 }
601
602 /* Make objects local so they can be transformed. */
603 if (WM_drag_asset_will_import_packed(drag) && !use_instance_collections) {
604 make_selected_objects_local(*bmain, *scene, *view_layer, *CTX_wm_view3d(C), true);
605
606 /* Making the IDs local might result in a new, copied ID. */
607 collection = id_cast<Collection *>(id->newid ? id->newid : id);
608 id = &collection->id;
609 }
610
612
613 /* Do after making local, since that changes the session UID. */
614 RNA_int_set(drop->ptr, "session_uid", int(id->session_uid));
615 RNA_boolean_set(drop->ptr, "use_instance", asset_drag->import_settings.use_instance_collections);
616
617 V3DSnapCursorState *snap_state = static_cast<V3DSnapCursorState *>(drop->draw_data);
618 if (snap_state) {
619 float loc[3], rot[3];
621 RNA_float_set_array(drop->ptr, "location", loc);
622 RNA_float_set_array(drop->ptr, "rotation", rot);
623 }
624
625 /* XXX Without an undo push here, there will be a crash when the user modifies operator
626 * properties. The stuff we do in these drop callbacks just isn't safe over undo/redo. */
627 ED_undo_push(C, "Drop Collection");
628}
629
630static void view3d_id_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
631{
633 if (id) {
635 }
636}
637
639{
640 view3d_id_drop_copy(C, drag, drop);
641 RNA_boolean_set(drop->ptr, "show_datablock_in_modifier", (drag->type != WM_DRAG_ASSET));
642}
643
645{
647 wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
648
649 std::optional<ID_Type> idtype = std::nullopt;
650 if (asset_drag) {
651 idtype = asset_drag->asset->get_id_type();
652 }
653 else if (id) {
654 idtype = GS(id->name);
655 }
656
657 if (idtype) {
658 RNA_enum_set(drop->ptr, "type", *idtype);
659 }
660 if (id) {
662 }
663}
664
666{
668
669 if (id) {
671 RNA_struct_property_unset(drop->ptr, "filepath");
672 return;
673 }
674}
675
677{
678 ListBaseT<wmDropBox> *lb = WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW);
679
680 wmDropBox *drop;
681 drop = WM_dropbox_add(lb,
682 "OBJECT_OT_add_named",
686 nullptr);
687
691
692 drop = WM_dropbox_add(lb,
693 "OBJECT_OT_transform_to_mouse",
697 nullptr);
698
702
703 drop = WM_dropbox_add(lb,
704 "OBJECT_OT_collection_external_asset_drop",
708 nullptr);
712 drop = WM_dropbox_add(lb,
713 "OBJECT_OT_collection_instance_add",
717 nullptr);
721
723 "OBJECT_OT_drop_named_material",
729 "OBJECT_OT_drop_geometry_nodes",
735 "VIEW3D_OT_camera_background_image_add",
739 nullptr);
741 "OBJECT_OT_empty_image_add",
745 nullptr);
747 "OBJECT_OT_data_instance_add",
753 "VIEW3D_OT_drop_world",
757 nullptr);
758}
759
760} // namespace blender
Main runtime representation of an asset.
#define IDP_int_get(prop)
#define IDP_array_float_get(prop)
#define FOREACH_SELECTED_OBJECT_BEGIN(_view_layer, _v3d, _instance)
Definition BKE_layer.hh:374
#define FOREACH_SELECTED_OBJECT_END
Definition BKE_layer.hh:386
General operations, lookup, etc. for blender objects.
#define TIP_(msgid)
ID and Library types, which are fundamental for SDNA.
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
Object groups, one object can be in many groups at once.
#define OB_DATA_SUPPORT_ID(_id_type)
#define C
Definition RandGen.cpp:29
#define ND_OB_ACTIVE
Definition WM_types.hh:459
#define NC_SCENE
Definition WM_types.hh:391
#define ND_LAYER_CONTENT
Definition WM_types.hh:472
#define UNUSED_VARS_NDEBUG(...)
bool add(const Key &key)
Definition BLI_set.hh:248
void append(const T &value)
void add(ID *old_id, ID *new_id)
#define rot(x, k)
float3x3 scale(float3x3 mat, float2 scale)
const int state
std::string drop_geometry_nodes_tooltip(bContext *C, PointerRNA *properties, const int mval[2])
std::string drop_named_material_tooltip(bContext *C, StringRef name, const int mval[2])
T midpoint(const T &a, const T &b)
void get_color_4ubv(int colorid, unsigned char col[4])
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
ScrArea * CTX_wm_area(const bContext *C)
wmDropBox * WM_dropbox_add(ListBaseT< wmDropBox > *lb, const char *idname, bool(*poll)(bContext *C, wmDrag *drag, const wmEvent *event), void(*copy)(bContext *C, wmDrag *drag, wmDropBox *drop), void(*cancel)(Main *bmain, wmDrag *drag, wmDropBox *drop), WMDropboxTooltipFunc tooltip)
static bool view3d_object_data_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static bool view3d_ob_drop_poll_external_asset(bContext *C, wmDrag *drag, const wmEvent *event)
void BKE_view_layer_base_select_and_set_active(ViewLayer *view_layer, Base *selbase)
V3DSnapCursorState * ED_view3d_cursor_snap_state_create()
wmDragAsset * WM_drag_get_asset_data(const wmDrag *drag, int idcode)
void WM_drag_free_imported_drag_ID(Main *bmain, wmDrag *drag, wmDropBox *drop)
Free asset ID imported for canceled drop.
MINLINE void copy_v3_v3(float r[3], const float a[3])
static bool view3d_ima_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static void view3d_id_path_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
V3DSnapCursorState * ED_view3d_cursor_snap_state_active_get()
ID * BKE_libblock_find_session_uid(Main *bmain, short type, uint32_t session_uid)
Definition lib_id.cc:1826
const std::string WM_drag_get_item_name(wmDrag *drag)
@ BASE_ENABLED_VIEWPORT
static void view3d_ob_drop_on_enter(wmDropBox *drop, wmDrag *drag)
void copy_m4_m3(float m1[4][4], const float m2[3][3])
static void view3d_ob_drop_matrix_from_snap(V3DSnapCursorState *snap_state, Object *ob, float obmat_final[4][4])
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
static void view3d_id_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
@ WM_DRAG_ASSET
Definition WM_types.hh:1294
static bool view3d_ob_drop_poll_local_id(bContext *C, wmDrag *drag, const wmEvent *event)
void RNA_struct_property_unset(PointerRNA *ptr, const char *identifier)
int RNA_int_get(PointerRNA *ptr, const char *name)
ID * WM_drag_get_local_ID_or_import_from_asset(const bContext *C, const wmDrag *drag, int idcode)
static bool view3d_collection_drop_poll_local_id(bContext *C, wmDrag *drag, const wmEvent *event)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
@ ID_REMAP_SKIP_INDIRECT_USAGE
static std::string view3d_geometry_nodes_drop_tooltip(bContext *C, wmDrag *, const int xy[2], wmDropBox *drop)
static bool view3d_drop_in_main_region_poll(bContext *C, const wmEvent *event)
void mat3_normalized_to_eul(float eul[3], const float mat[3][3])
bool WM_drag_is_ID_type(const wmDrag *drag, int idcode)
static bool view3d_ima_bg_is_camera_view(bContext *C)
static void view3d_id_drop_copy_with_type(bContext *C, wmDrag *drag, wmDropBox *drop)
void view3d_dropboxes()
ViewLayer * CTX_data_view_layer(const bContext *C)
void ED_outliner_select_sync_from_object_tag(bContext *C)
static void view3d_geometry_nodes_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
static void view3d_collection_drop_on_enter(wmDropBox *drop, wmDrag *drag)
static void view3d_collection_drop_copy_local_id(bContext *, wmDrag *drag, wmDropBox *drop)
bool BKE_collection_has_object(Collection *collection, const Object *ob)
MINLINE void sub_v3_v3(float r[3], const float a[3])
V3DSnapCursorData * ED_view3d_cursor_snap_data_get()
bool ED_region_overlap_isect_any_xy(const ScrArea *area, const int event_xy[2])
Definition area_query.cc:58
static bool view3d_mat_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
unsigned int uint32_t
Definition BKE_text.h:81
static void view3d_ob_drop_copy_external_asset(bContext *C, wmDrag *drag, wmDropBox *drop)
bool WM_drag_asset_will_import_packed(const wmDrag *drag)
static bool view3d_geometry_nodes_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static std::string view3d_object_data_drop_tooltip(bContext *, wmDrag *, const int[2], wmDropBox *)
void ED_view3d_cursor_snap_state_free(V3DSnapCursorState *state)
static void view3d_drop_snap_exit(wmDropBox *drop, wmDrag *)
static V3DSnapCursorState * view3d_drop_snap_init(wmDropBox *drop)
void DEG_id_tag_update(ID *id, unsigned int flags)
static bool view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static std::string view3d_mat_drop_tooltip(bContext *C, wmDrag *drag, const int xy[2], wmDropBox *)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
Definition ed_undo.cc:103
void WM_operator_properties_id_lookup_set_from_id(PointerRNA *ptr, const ID *id)
static void view3d_collection_drop_copy_external_asset(bContext *C, wmDrag *drag, wmDropBox *drop)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void BKE_libblock_remap_multiple(Main *bmain, bke::id::IDRemapper &mappings, const int remap_flags)
Definition lib_remap.cc:710
IDProperty * BKE_asset_metadata_idprop_find(const AssetMetaData *asset_data, const char *name) ATTR_WARN_UNUSED_RESULT
Definition asset.cc:183
void WM_drag_draw_item_name_fn(bContext *, wmWindow *win, wmDrag *drag, const int xy[2])
RegionView3D * CTX_wm_region_view3d(const bContext *C)
static bool view3d_collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static bool view3d_collection_drop_poll_external_asset(bContext *C, wmDrag *drag, const wmEvent *event)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
bool WM_drag_asset_will_import_linked(const wmDrag *drag)
void BKE_view_layer_base_deselect_all(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
static void view3d_ob_drop_copy_local_id(bContext *, wmDrag *drag, wmDropBox *drop)
void mat4_to_size(float size[3], const float M[4][4])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
static bool view3d_drop_id_in_main_region_poll(bContext *C, wmDrag *drag, const wmEvent *event, ID_Type id_type)
static bool view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
Main * CTX_data_main(const bContext *C)
AssetMetaData * WM_drag_get_asset_meta_data(const wmDrag *drag, int idcode)
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
ID_Type GS(const char *name)
Definition DNA_ID.h:410
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
void rescale_m4(float mat[4][4], const float scale[3])
static bool view3d_ob_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
Object * ED_view3d_give_object_under_cursor(bContext *C, const int mval[2])
static ID_Type view3d_drop_id_in_main_region_poll_get_id_type(bContext *C, wmDrag *drag, const wmEvent *event)
static void make_selected_objects_local(Main &bmain, Scene &scene, ViewLayer &view_layer, View3D &v3d, const bool localize_parent_collections)
void DEG_relations_tag_update(Main *bmain)
Scene * CTX_data_scene(const bContext *C)
std::optional< Bounds< float3 > > BKE_object_boundbox_get(const Object *ob)
Definition object.cc:3726
@ LIB_ID_MAKELOCAL_LIBOVERRIDE_CLEAR
@ LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR
ID * WM_drag_get_local_ID(const wmDrag *drag, short idcode)
static bool view3d_world_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
VecBase< float, 3 > float3
bool BKE_lib_id_make_local(Main *bmain, ID *id, int flags)
Definition lib_id.cc:672
ListBaseT< wmDropBox > * WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
static void view3d_collection_drop_matrix_from_snap(V3DSnapCursorState *snap_state, float r_loc[3], float r_rot[3])
void BKE_object_dimensions_eval_cached_get(const Object *ob, float r_vec[3])
Definition object.cc:3804
ARegion * CTX_wm_region(const bContext *C)
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
View3D * CTX_wm_view3d(const bContext *C)
bool BKE_view_layer_has_collection(const ViewLayer *view_layer, const Collection *collection)
ID * WM_drag_asset_id_import(const bContext *C, wmDragAsset *asset_drag, const int flag_extra)
bool ED_view3d_is_object_under_cursor(bContext *C, const int mval[2])
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
ListBaseT< CollectionObject > gobject
char name[258]
Definition DNA_ID.h:433
ListBaseT< Collection > collections
Definition BKE_main.hh:406
eObject_EmptyDrawType empty_drawtype
eRegionView3D_Persp persp
struct Object * camera
eNodeTree_Type type
const asset_system::AssetRepresentation * asset
Definition WM_types.hh:1337
AssetImportSettings import_settings
Definition WM_types.hh:1338
wmDragActiveDropState drop_state
Definition WM_types.hh:1433
eWM_DragDataType type
Definition WM_types.hh:1424
void(*) draw_droptip(bContext *C, wmWindow *win, wmDrag *drag, const int xy[2])
Definition WM_types.hh:1488
PointerRNA * ptr
Definition WM_types.hh:1524
void(*) on_enter(wmDropBox *drop, wmDrag *drag)
Definition WM_types.hh:1466
void(*) on_exit(wmDropBox *drop, wmDrag *drag)
Definition WM_types.hh:1472