Blender V5.0
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.h"
21#include "BLI_math_matrix.h"
22#include "BLI_math_rotation.h"
23#include "BLI_math_vector.h"
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
50{
51 ScrArea *area = CTX_wm_area(C);
52 return ED_region_overlap_isect_any_xy(area, event->xy) == false;
53}
54
56 wmDrag *drag,
57 const wmEvent *event)
58{
59 const ScrArea *area = CTX_wm_area(C);
60
61 if (ED_region_overlap_isect_any_xy(area, event->xy)) {
62 return ID_Type(0);
63 }
65 return ID_Type(0);
66 }
67
68 ID *local_id = WM_drag_get_local_ID(drag, 0);
69 if (local_id) {
70 return GS(local_id->name);
71 }
72
73 wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
74 if (asset_drag) {
75 return asset_drag->asset->get_id_type();
76 }
77
78 return ID_Type(0);
79}
80
82 wmDrag *drag,
83 const wmEvent *event,
84 ID_Type id_type)
85{
87 return false;
88 }
89
90 return WM_drag_is_ID_type(drag, id_type);
91}
92
94{
96 if (state) {
97 return state;
98 }
99
101 drop->draw_data = state;
102 state->draw_plane = true;
103 return state;
104}
105
106static void view3d_drop_snap_exit(wmDropBox *drop, wmDrag * /*drag*/)
107{
108 V3DSnapCursorState *state = static_cast<V3DSnapCursorState *>(drop->draw_data);
109 if (state) {
111 drop->draw_data = nullptr;
112 }
113}
114
115static void view3d_ob_drop_on_enter(wmDropBox *drop, wmDrag *drag)
116{
117 /* Don't use the snap cursor when linking the object. Object transform isn't editable then and
118 * would be reset on reload. */
120 return;
121 }
122
124
125 float dimensions[3] = {0.0f};
126 if (drag->type == WM_DRAG_ID) {
127 Object *ob = (Object *)WM_drag_get_local_ID(drag, ID_OB);
129 }
130 else {
132 IDProperty *dimensions_prop = BKE_asset_metadata_idprop_find(meta_data, "dimensions");
133 if (dimensions_prop) {
134 copy_v3_v3(dimensions, IDP_array_float_get(dimensions_prop));
135 }
136 }
137
138 if (!is_zero_v3(dimensions)) {
139 mul_v3_v3fl(state->box_dimensions, dimensions, 0.5f);
141 state->draw_box = true;
142 }
143}
144
145static bool view3d_ob_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
146{
147 return view3d_drop_id_in_main_region_poll(C, drag, event, ID_OB);
148}
150{
151 if (!view3d_ob_drop_poll(C, drag, event) || (drag->type != WM_DRAG_ASSET)) {
152 return false;
153 }
154 return true;
155}
156
161static bool view3d_ob_drop_poll_local_id(bContext *C, wmDrag *drag, const wmEvent *event)
162{
163 if (!view3d_ob_drop_poll(C, drag, event) || (drag->type != WM_DRAG_ID)) {
164 return false;
165 }
166 return true;
167}
168
169static bool view3d_collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
170{
171 return view3d_drop_id_in_main_region_poll(C, drag, event, ID_GR);
172}
173
175{
176 if (!view3d_collection_drop_poll(C, drag, event) || (drag->type != WM_DRAG_ID)) {
177 return false;
178 }
179 return true;
180}
181
183 wmDrag *drag,
184 const wmEvent *event)
185{
186 if (!view3d_collection_drop_poll(C, drag, event) || (drag->type != WM_DRAG_ASSET)) {
187 return false;
188 }
189 return true;
190}
191
192static bool view3d_mat_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
193{
194 if (!view3d_drop_id_in_main_region_poll(C, drag, event, ID_MA)) {
195 return false;
196 }
197
199
200 return (ob && ID_IS_EDITABLE(&ob->id) && !ID_IS_OVERRIDE_LIBRARY(&ob->id));
201}
202
204 wmDrag *drag,
205 const int xy[2],
206 wmDropBox * /*drop*/)
207{
208 const char *name = WM_drag_get_item_name(drag);
209 ARegion *region = CTX_wm_region(C);
210 const int mval[2] = {
211 xy[0] - region->winrct.xmin,
212 xy[1] - region->winrct.ymin,
213 };
215}
216
217static bool view3d_world_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
218{
219 return view3d_drop_id_in_main_region_poll(C, drag, event, ID_WO);
220}
221
222static bool view3d_object_data_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
223{
225 if (id_type && OB_DATA_SUPPORT_ID(id_type)) {
226 return true;
227 }
228 return false;
229}
230
231static std::string view3d_object_data_drop_tooltip(bContext * /*C*/,
232 wmDrag * /*drag*/,
233 const int /*xy*/[2],
234 wmDropBox * /*drop*/)
235{
236 return TIP_("Create object instance from object-data");
237}
238
239static bool view3d_ima_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
240{
242 return false;
243 }
244 return WM_drag_is_ID_type(drag, ID_IM);
245}
246
248{
250 if (rv3d && (rv3d->persp == RV3D_CAMOB)) {
251 View3D *v3d = CTX_wm_view3d(C);
252 if (v3d && v3d->camera && v3d->camera->type == OB_CAMERA) {
253 return true;
254 }
255 }
256 return false;
257}
258
259static bool view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
260{
261 if (!view3d_ima_drop_poll(C, drag, event)) {
262 return false;
263 }
264
266 return false;
267 }
268
270}
271
272static bool view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
273{
274 if (!view3d_ima_drop_poll(C, drag, event)) {
275 return false;
276 }
277
279
280 if (ob == nullptr) {
281 return true;
282 }
283
284 if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
285 return true;
286 }
287
288 return false;
289}
290
291static bool view3d_geometry_nodes_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
292{
293 if (!view3d_drop_id_in_main_region_poll(C, drag, event, ID_NT)) {
294 return false;
295 }
296
297 if (drag->type == WM_DRAG_ID) {
298 const bNodeTree *node_tree = reinterpret_cast<const bNodeTree *>(
300 if (!node_tree) {
301 return false;
302 }
303 return node_tree->type == NTREE_GEOMETRY;
304 }
305
306 if (drag->type == WM_DRAG_ASSET) {
307 const wmDragAsset *asset_data = WM_drag_get_asset_data(drag, ID_NT);
308 if (!asset_data) {
309 return false;
310 }
311 const AssetMetaData *metadata = &asset_data->asset->get_metadata();
312 const IDProperty *tree_type = BKE_asset_metadata_idprop_find(metadata, "type");
313 if (!tree_type || IDP_int_get(tree_type) != NTREE_GEOMETRY) {
314 return false;
315 }
316 if (wmDropBox *drop_box = drag->drop_state.active_dropbox) {
317 const uint32_t uid = RNA_int_get(drop_box->ptr, "session_uid");
318 const bNodeTree *node_tree = reinterpret_cast<const bNodeTree *>(
320 if (node_tree) {
321 return node_tree->type == NTREE_GEOMETRY;
322 }
323 }
324 }
325 return true;
326}
327
329 wmDrag * /*drag*/,
330 const int xy[2],
331 wmDropBox *drop)
332{
333 ARegion *region = CTX_wm_region(C);
334 int mval[2] = {xy[0] - region->winrct.xmin, xy[1] - region->winrct.ymin};
336}
337
339 Object *ob,
340 float obmat_final[4][4])
341{
342 using namespace blender;
344 BLI_assert(snap_state->draw_box || snap_state->draw_plane);
345 UNUSED_VARS_NDEBUG(snap_state);
346 copy_m4_m3(obmat_final, snap_data->plane_omat);
347 copy_v3_v3(obmat_final[3], snap_data->loc);
348
349 float scale[3];
350 mat4_to_size(scale, ob->object_to_world().ptr());
351 rescale_m4(obmat_final, scale);
352
353 if (const std::optional<Bounds<float3>> bb = BKE_object_boundbox_get(ob)) {
354 float3 offset = math::midpoint(bb->min, bb->max);
355 offset[2] = bb->min[2];
356 mul_mat3_m4_v3(obmat_final, offset);
357 sub_v3_v3(obmat_final[3], offset);
358 }
359}
360
361static void view3d_ob_drop_copy_local_id(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
362{
363 ID *id = WM_drag_get_local_ID(drag, ID_OB);
364
365 RNA_int_set(drop->ptr, "session_uid", id->session_uid);
366 /* Don't duplicate ID's which were just imported. Only do that for existing, local IDs. */
367 BLI_assert(drag->type != WM_DRAG_ASSET);
368
370 float obmat_final[4][4];
371
372 view3d_ob_drop_matrix_from_snap(snap_state, (Object *)id, obmat_final);
373
374 RNA_float_set_array(drop->ptr, "matrix", &obmat_final[0][0]);
375}
376
385 Scene &scene,
386 ViewLayer &view_layer,
387 View3D &v3d,
388 const bool localize_parent_collections)
389{
390 blender::Set<Collection *> collections_to_localize;
391
392 if (localize_parent_collections) {
393 /* Collect the collections containing the selected objects. */
394 LISTBASE_FOREACH (Collection *, collection, &bmain.collections) {
395 if (ID_IS_LINKED(collection) &&
396 /* This #BKE_view_layer_has_collection() check requires the view layer to be synced.
397 * That's why we first collect the collections before doing any changes. Otherwise we'd
398 * have to sync the view layer after every "make local" operation. */
399 BKE_view_layer_has_collection(&view_layer, collection))
400 {
401 FOREACH_SELECTED_OBJECT_BEGIN (&view_layer, &v3d, ob_selected) {
402 if (BKE_collection_has_object(collection, ob_selected)) {
403 collections_to_localize.add(collection);
404 break;
405 }
406 }
408 }
409 }
410 }
411
412 blender::Vector<ID *> localized_ids;
413
414 /* Make IDs local. When an ID gets made local, pointers to it will be remapped to the new local
415 * version. However, this doesn't work if the pointer is owned by linked data too.
416 *
417 * E.g. when multiple objects are linked/packed together, they may point to each other. An object
418 * that is being made local may be pointed to by another object that hasn't been made local yet.
419 * So this pointer cannot be remapped yet either.
420 *
421 * That's why we do another remapping pass below, over all IDs that were made local. This catches
422 * remaining old pointers.
423 */
424 {
425 const auto make_id_local = [&bmain, &localized_ids](ID *id) {
428 if (id->newid) {
430 BLI_assert(!ID_IS_LINKED(id->newid));
431
432 localized_ids.append(id);
433 }
434 };
435
436 for (Collection *collection : collections_to_localize) {
437 make_id_local(&collection->id);
438 }
439 BKE_view_layer_synced_ensure(&scene, &view_layer);
440
441 FOREACH_SELECTED_OBJECT_BEGIN (&view_layer, &v3d, ob_selected) {
442 make_id_local(&ob_selected->id);
443 }
445 }
446
447 /* Make sure all remaining pointers from the linked IDs are replaced by the new one. */
448 {
450 for (ID *id : localized_ids) {
451 remapper.add(id, id->newid);
452 }
454 }
455}
456
457/* Mostly the same logic as #view3d_collection_drop_copy_external_asset(), just different enough to
458 * make sharing code a bit difficult. */
460{
461 /* NOTE(@ideasman42): Selection is handled here, de-selecting objects before append,
462 * using auto-select to ensure the new objects are selected.
463 * This is done so #OBJECT_OT_transform_to_mouse (which runs after this drop handler)
464 * can use the context setup here to place the objects. */
465 BLI_assert(drag->type == WM_DRAG_ASSET);
466
467 wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
468 Main *bmain = CTX_data_main(C);
469 Scene *scene = CTX_data_scene(C);
470 ViewLayer *view_layer = CTX_data_view_layer(C);
471
472 BKE_view_layer_base_deselect_all(scene, view_layer);
473
474 ID *id = WM_drag_asset_id_import(C, asset_drag, FILE_AUTOSELECT);
475
476 /* TODO(sergey): Only update relations for the current scene. */
479
480 BKE_view_layer_synced_ensure(scene, view_layer);
481 Base *base = BKE_view_layer_base_find(view_layer, (Object *)id);
482 if (base != nullptr) {
485 }
487
488 /* Make objects local so they can be transformed. */
490 make_selected_objects_local(*bmain, *scene, *view_layer, *CTX_wm_view3d(C), false);
491
492 /* Making the IDs local might result in a new, copied ID. */
493 if (id->newid) {
494 id = id->newid;
495 }
496 }
497
499
500 /* Do after making local, since that changes the session UID. */
501 RNA_int_set(drop->ptr, "session_uid", id->session_uid);
502
503 /* Make sure the depsgraph is evaluated so the new object's transforms are up-to-date.
504 * The evaluated #Object::object_to_world() will be copied back to the original object
505 * and used below. */
507
508 V3DSnapCursorState *snap_state = static_cast<V3DSnapCursorState *>(drop->draw_data);
509 if (snap_state) {
510 float obmat_final[4][4];
511
512 view3d_ob_drop_matrix_from_snap(snap_state, (Object *)id, obmat_final);
513
514 RNA_float_set_array(drop->ptr, "matrix", &obmat_final[0][0]);
515 }
516}
517
519{
521 const wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
522 /* Linked collections cannot be transformed except when using instancing. Don't enable
523 * snapping. */
524 if (!asset_drag->import_settings.use_instance_collections) {
525 return;
526 }
527 }
528
530}
531
533 float r_loc[3],
534 float r_rot[3])
535{
536 using namespace blender;
538 BLI_assert(snap_state->draw_box || snap_state->draw_plane);
539 UNUSED_VARS_NDEBUG(snap_state);
540
541 mat3_normalized_to_eul(r_rot, snap_data->plane_omat);
542 copy_v3_v3(r_loc, snap_data->loc);
543}
544
546{
547 ID *id = WM_drag_get_local_ID(drag, ID_GR);
548 RNA_int_set(drop->ptr, "session_uid", int(id->session_uid));
549
551
552 float loc[3], rot[3];
554 RNA_float_set_array(drop->ptr, "location", loc);
555 RNA_float_set_array(drop->ptr, "rotation", rot);
556}
557
558/* Mostly the same logic as #view3d_ob_drop_copy_external_asset(), just different enough to make
559 * sharing code a bit difficult. */
561{
562 BLI_assert(drag->type == WM_DRAG_ASSET);
563
564 wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
565 Main *bmain = CTX_data_main(C);
566 Scene *scene = CTX_data_scene(C);
567 ViewLayer *view_layer = CTX_data_view_layer(C);
568
569 BKE_view_layer_base_deselect_all(scene, view_layer);
570
571 const bool use_instance_collections = asset_drag->import_settings.use_instance_collections;
572 /* Temporarily disable instancing for the import, the drop operator handles that. */
573 asset_drag->import_settings.use_instance_collections = false;
574
575 ID *id = WM_drag_asset_id_import(C, asset_drag, FILE_AUTOSELECT);
576 Collection *collection = (Collection *)id;
577
578 /* Reset temporary override. */
579 asset_drag->import_settings.use_instance_collections = use_instance_collections;
580
581 /* TODO(sergey): Only update relations for the current scene. */
584
585 /* Make an object active, just use the first one in the collection. */
586 CollectionObject *cobject = static_cast<CollectionObject *>(collection->gobject.first);
587 BKE_view_layer_synced_ensure(scene, view_layer);
588 Base *base = cobject ? BKE_view_layer_base_find(view_layer, cobject->ob) : nullptr;
589 if (base) {
593 }
595
596 /* Make objects local so they can be transformed. */
597 if (WM_drag_asset_will_import_packed(drag) && !use_instance_collections) {
598 make_selected_objects_local(*bmain, *scene, *view_layer, *CTX_wm_view3d(C), true);
599
600 /* Making the IDs local might result in a new, copied ID. */
601 collection = blender::id_cast<Collection *>(id->newid ? id->newid : id);
602 id = &collection->id;
603 }
604
606
607 /* Do after making local, since that changes the session UID. */
608 RNA_int_set(drop->ptr, "session_uid", int(id->session_uid));
609 RNA_boolean_set(drop->ptr, "use_instance", asset_drag->import_settings.use_instance_collections);
610
611 V3DSnapCursorState *snap_state = static_cast<V3DSnapCursorState *>(drop->draw_data);
612 if (snap_state) {
613 float loc[3], rot[3];
615 RNA_float_set_array(drop->ptr, "location", loc);
616 RNA_float_set_array(drop->ptr, "rotation", rot);
617 }
618
619 /* XXX Without an undo push here, there will be a crash when the user modifies operator
620 * properties. The stuff we do in these drop callbacks just isn't safe over undo/redo. */
621 ED_undo_push(C, "Drop Collection");
622}
623
630
632{
633 view3d_id_drop_copy(C, drag, drop);
634 RNA_boolean_set(drop->ptr, "show_datablock_in_modifier", (drag->type != WM_DRAG_ASSET));
635}
636
638{
640
641 RNA_enum_set(drop->ptr, "type", GS(id->name));
643}
644
646{
648
649 if (id) {
651 RNA_struct_property_unset(drop->ptr, "filepath");
652 return;
653 }
654}
655
657{
659
660 wmDropBox *drop;
661 drop = WM_dropbox_add(lb,
662 "OBJECT_OT_add_named",
666 nullptr);
667
671
672 drop = WM_dropbox_add(lb,
673 "OBJECT_OT_transform_to_mouse",
677 nullptr);
678
682
683 drop = WM_dropbox_add(lb,
684 "OBJECT_OT_collection_external_asset_drop",
688 nullptr);
692 drop = WM_dropbox_add(lb,
693 "OBJECT_OT_collection_instance_add",
697 nullptr);
701
703 "OBJECT_OT_drop_named_material",
709 "OBJECT_OT_drop_geometry_nodes",
715 "VIEW3D_OT_camera_background_image_add",
719 nullptr);
721 "OBJECT_OT_empty_image_add",
725 nullptr);
727 "OBJECT_OT_data_instance_add",
733 "VIEW3D_OT_drop_world",
737 nullptr);
738}
Main runtime representation of an asset.
IDProperty * BKE_asset_metadata_idprop_find(const AssetMetaData *asset_data, const char *name) ATTR_WARN_UNUSED_RESULT
Definition asset.cc:179
bool BKE_collection_has_object(Collection *collection, const Object *ob)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
#define IDP_int_get(prop)
#define IDP_array_float_get(prop)
bool BKE_view_layer_has_collection(const ViewLayer *view_layer, const Collection *collection)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
#define FOREACH_SELECTED_OBJECT_BEGIN(_view_layer, _v3d, _instance)
Definition BKE_layer.hh:298
void BKE_view_layer_base_deselect_all(const Scene *scene, ViewLayer *view_layer)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
#define FOREACH_SELECTED_OBJECT_END
Definition BKE_layer.hh:310
void BKE_view_layer_base_select_and_set_active(ViewLayer *view_layer, Base *selbase)
ID * BKE_libblock_find_session_uid(Main *bmain, short type, uint32_t session_uid)
Definition lib_id.cc:1728
@ LIB_ID_MAKELOCAL_LIBOVERRIDE_CLEAR
@ LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR
bool BKE_lib_id_make_local(Main *bmain, ID *id, int flags)
Definition lib_id.cc:598
void BKE_libblock_remap_multiple(Main *bmain, blender::bke::id::IDRemapper &mappings, const int remap_flags)
Definition lib_remap.cc:711
@ ID_REMAP_SKIP_INDIRECT_USAGE
General operations, lookup, etc. for blender objects.
void BKE_object_dimensions_eval_cached_get(const Object *ob, float r_vec[3])
std::optional< blender::Bounds< blender::float3 > > BKE_object_boundbox_get(const Object *ob)
#define BLI_assert(a)
Definition BLI_assert.h:46
#define LISTBASE_FOREACH(type, var, list)
void copy_m4_m3(float m1[4][4], const float m2[3][3])
void rescale_m4(float mat[4][4], const float scale[3])
void mat4_to_size(float size[3], const float M[4][4])
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
void mat3_normalized_to_eul(float eul[3], const float mat[3][3])
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
#define UNUSED_VARS_NDEBUG(...)
#define TIP_(msgid)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
ID and Library types, which are fundamental for SDNA.
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:694
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:705
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:730
ID_Type
@ ID_IM
@ ID_NT
@ ID_WO
@ ID_MA
@ ID_GR
@ ID_OB
Object groups, one object can be in many groups at once.
@ BASE_ENABLED_VIEWPORT
@ NTREE_GEOMETRY
#define OB_DATA_SUPPORT_ID(_id_type)
@ OB_EMPTY_IMAGE
@ OB_EMPTY
@ OB_CAMERA
#define BASE_SELECTABLE(v3d, base)
@ RGN_TYPE_WINDOW
@ SPACE_VIEW3D
@ FILE_AUTOSELECT
@ RV3D_CAMOB
void ED_outliner_select_sync_from_object_tag(bContext *C)
bool ED_region_overlap_isect_any_xy(const ScrArea *area, const int event_xy[2])
Definition area_query.cc:56
void ED_undo_push(bContext *C, const char *str)
Definition ed_undo.cc:98
V3DSnapCursorState * ED_view3d_cursor_snap_state_create()
V3DSnapCursorState * ED_view3d_cursor_snap_state_active_get()
Object * ED_view3d_give_object_under_cursor(bContext *C, const int mval[2])
bool ED_view3d_is_object_under_cursor(bContext *C, const int mval[2])
void ED_view3d_cursor_snap_state_free(V3DSnapCursorState *state)
V3DSnapCursorData * ED_view3d_cursor_snap_data_get()
#define C
Definition RandGen.cpp:29
@ TH_GIZMO_PRIMARY
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
#define ND_OB_ACTIVE
Definition WM_types.hh:440
@ WM_DRAG_ASSET
Definition WM_types.hh:1202
@ WM_DRAG_ID
Definition WM_types.hh:1201
#define NC_SCENE
Definition WM_types.hh:378
#define ND_LAYER_CONTENT
Definition WM_types.hh:453
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)
#define GS(x)
static ulong state[N]
std::string drop_named_material_tooltip(bContext *C, const char *name, const int mval[2])
std::string drop_geometry_nodes_tooltip(bContext *C, PointerRNA *properties, const int mval[2])
T midpoint(const T &a, const T &b)
const char * name
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
int RNA_int_get(PointerRNA *ptr, const char *name)
void RNA_struct_property_unset(PointerRNA *ptr, const char *identifier)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
short flag
Definition DNA_ID.h:414
char name[258]
Definition DNA_ID.h:432
struct ID * newid
Definition DNA_ID.h:418
unsigned int session_uid
Definition DNA_ID.h:462
void * first
ListBase collections
Definition BKE_main.hh:298
char empty_drawtype
float plane_omat[3][3]
Definition ED_view3d.hh:345
struct Object * camera
int ymin
int xmin
wmDropBox * active_dropbox
Definition WM_types.hh:1297
const AssetRepresentationHandle * asset
Definition WM_types.hh:1243
AssetImportSettings import_settings
Definition WM_types.hh:1244
eWM_DragDataType type
Definition WM_types.hh:1331
wmDragActiveDropState drop_state
Definition WM_types.hh:1340
void * draw_data
Definition WM_types.hh:1402
PointerRNA * ptr
Definition WM_types.hh:1420
void(* on_exit)(wmDropBox *drop, wmDrag *drag)
Definition WM_types.hh:1375
void(* on_enter)(wmDropBox *drop, wmDrag *drag)
Definition WM_types.hh:1371
void(* draw_droptip)(bContext *C, wmWindow *win, wmDrag *drag, const int xy[2])
Definition WM_types.hh:1391
int xy[2]
Definition WM_types.hh:761
int mval[2]
Definition WM_types.hh:763
static void view3d_ob_drop_copy_external_asset(bContext *C, wmDrag *drag, wmDropBox *drop)
static bool view3d_world_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static bool view3d_ob_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static bool view3d_collection_drop_poll_local_id(bContext *C, wmDrag *drag, const wmEvent *event)
static bool view3d_object_data_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static void view3d_id_path_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
static void view3d_collection_drop_copy_local_id(bContext *, wmDrag *drag, wmDropBox *drop)
static bool view3d_ima_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static bool view3d_ima_bg_is_camera_view(bContext *C)
static void make_selected_objects_local(Main &bmain, Scene &scene, ViewLayer &view_layer, View3D &v3d, const bool localize_parent_collections)
static bool view3d_collection_drop_poll_external_asset(bContext *C, wmDrag *drag, const wmEvent *event)
static void view3d_drop_snap_exit(wmDropBox *drop, wmDrag *)
static void view3d_ob_drop_matrix_from_snap(V3DSnapCursorState *snap_state, Object *ob, float obmat_final[4][4])
static std::string view3d_object_data_drop_tooltip(bContext *, wmDrag *, const int[2], wmDropBox *)
static bool view3d_ima_empty_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static bool view3d_ob_drop_poll_local_id(bContext *C, wmDrag *drag, const wmEvent *event)
static bool view3d_ima_bg_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
void view3d_dropboxes()
static void view3d_geometry_nodes_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
static bool view3d_ob_drop_poll_external_asset(bContext *C, wmDrag *drag, const wmEvent *event)
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)
static void view3d_id_drop_copy_with_type(bContext *C, wmDrag *drag, wmDropBox *drop)
static void view3d_collection_drop_copy_external_asset(bContext *C, wmDrag *drag, wmDropBox *drop)
static bool view3d_drop_id_in_main_region_poll(bContext *C, wmDrag *drag, const wmEvent *event, ID_Type id_type)
static V3DSnapCursorState * view3d_drop_snap_init(wmDropBox *drop)
static std::string view3d_mat_drop_tooltip(bContext *C, wmDrag *drag, const int xy[2], wmDropBox *)
static void view3d_ob_drop_copy_local_id(bContext *, wmDrag *drag, wmDropBox *drop)
static bool view3d_geometry_nodes_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static bool view3d_mat_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static void view3d_collection_drop_on_enter(wmDropBox *drop, wmDrag *drag)
static void view3d_collection_drop_matrix_from_snap(V3DSnapCursorState *snap_state, float r_loc[3], float r_rot[3])
static bool view3d_collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static void view3d_ob_drop_on_enter(wmDropBox *drop, wmDrag *drag)
static void view3d_id_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
static ID_Type view3d_drop_id_in_main_region_poll_get_id_type(bContext *C, wmDrag *drag, const wmEvent *event)
AssetMetaData * WM_drag_get_asset_meta_data(const wmDrag *drag, int idcode)
wmDropBox * WM_dropbox_add(ListBase *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)
void WM_drag_draw_item_name_fn(bContext *, wmWindow *win, wmDrag *drag, const int xy[2])
void WM_drag_free_imported_drag_ID(Main *bmain, wmDrag *drag, wmDropBox *drop)
bool WM_drag_asset_will_import_linked(const wmDrag *drag)
ID * WM_drag_asset_id_import(const bContext *C, wmDragAsset *asset_drag, const int flag_extra)
const char * WM_drag_get_item_name(wmDrag *drag)
bool WM_drag_is_ID_type(const wmDrag *drag, int idcode)
ID * WM_drag_get_local_ID_or_import_from_asset(const bContext *C, const wmDrag *drag, int idcode)
bool WM_drag_asset_will_import_packed(const wmDrag *drag)
ListBase * WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
wmDragAsset * WM_drag_get_asset_data(const wmDrag *drag, int idcode)
ID * WM_drag_get_local_ID(const wmDrag *drag, short idcode)
int xy[2]
Definition wm_draw.cc:178
void WM_main_add_notifier(uint type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_operator_properties_id_lookup_set_from_id(PointerRNA *ptr, const ID *id)