Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/space_view3d.c
| Show All 33 Lines | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_asset.h" | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_icons.h" | #include "BKE_icons.h" | ||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_lattice.h" | #include "BKE_lattice.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_mball.h" | #include "BKE_mball.h" | ||||
| ▲ Show 20 Lines • Show All 461 Lines • ▼ Show 20 Lines | if (!view3d_drop_in_main_region_poll(C, event)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return WM_drag_is_ID_type(drag, id_type); | return WM_drag_is_ID_type(drag, id_type); | ||||
| } | } | ||||
| 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) | ||||
| { | { | ||||
| return view3d_drop_id_in_main_region_poll(C, drag, event, ID_OB); | if (view3d_drop_id_in_main_region_poll(C, drag, event, ID_OB)) { | ||||
| drag->no_preview = true; | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | } | ||||
| static bool view3d_collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | static bool view3d_collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | ||||
| { | { | ||||
| return view3d_drop_id_in_main_region_poll(C, drag, event, ID_GR); | return view3d_drop_id_in_main_region_poll(C, drag, event, ID_GR); | ||||
| } | } | ||||
| static bool view3d_mat_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | static bool view3d_mat_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | ||||
| ▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | |||||
| static void view3d_ob_drop_copy(wmDrag *drag, wmDropBox *drop) | static void view3d_ob_drop_copy(wmDrag *drag, wmDropBox *drop) | ||||
| { | { | ||||
| ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, ID_OB); | ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, ID_OB); | ||||
| RNA_string_set(drop->ptr, "name", id->name + 2); | RNA_string_set(drop->ptr, "name", id->name + 2); | ||||
| RNA_boolean_set(drop->ptr, "duplicate", false); | RNA_boolean_set(drop->ptr, "duplicate", false); | ||||
| } | } | ||||
| static void view3d_ob_drag_gizmo_copy_local(wmDropBox *drop, Object *ob) | |||||
| { | |||||
| BoundBox *boundbox = BKE_object_boundbox_get(ob); | |||||
| if (boundbox) { | |||||
| RNA_float_set_array(drop->gizmo_group_ptr, "bound_box", (float *)boundbox->vec); | |||||
| } | |||||
| float matrix_basis[4][4]; | |||||
| BKE_object_to_mat4(ob, matrix_basis); | |||||
| RNA_float_set_array(drop->gizmo_group_ptr, "matrix_basis", (float *)matrix_basis); | |||||
| } | |||||
| static void view3d_ob_drag_gizmo_copy_external(wmDrag *drag, wmDropBox *drop) | |||||
| { | |||||
| const struct AssetMetaData *meta_data = WM_drag_get_asset_meta_data(drag, ID_OB); | |||||
| const IDProperty *boundbox_prop = BKE_asset_metadata_idprop_find(meta_data, "boundbox_hint"); | |||||
| if (boundbox_prop) { | |||||
| BLI_assert(boundbox_prop->len == sizeof(((BoundBox *)NULL)->vec) / sizeof(float)); | |||||
| RNA_float_set_array(drop->gizmo_group_ptr, "bound_box", IDP_Array(boundbox_prop)); | |||||
| } | |||||
| const IDProperty *matrix_basis_prop = BKE_asset_metadata_idprop_find(meta_data, "matrix_basis"); | |||||
| if (matrix_basis_prop) { | |||||
| BLI_assert(matrix_basis_prop->len == sizeof(((Object *)NULL)->obmat) / sizeof(float)); | |||||
| RNA_float_set_array(drop->gizmo_group_ptr, "matrix_basis", IDP_Array(matrix_basis_prop)); | |||||
| } | |||||
| } | |||||
| static void view3d_ob_drag_gizmo_copy(wmDrag *drag, wmDropBox *drop) | |||||
| { | |||||
| ID *id = WM_drag_get_local_ID(drag, ID_OB); | |||||
| if (id) { | |||||
| view3d_ob_drag_gizmo_copy_local(drop, (Object *)id); | |||||
| } | |||||
| else { | |||||
| view3d_ob_drag_gizmo_copy_external(drag, drop); | |||||
| } | |||||
| } | |||||
| static void view3d_collection_drop_copy(wmDrag *drag, wmDropBox *drop) | static void view3d_collection_drop_copy(wmDrag *drag, wmDropBox *drop) | ||||
| { | { | ||||
| ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, ID_GR); | ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, ID_GR); | ||||
| RNA_string_set(drop->ptr, "name", id->name + 2); | RNA_string_set(drop->ptr, "name", id->name + 2); | ||||
| } | } | ||||
| static void view3d_id_drop_copy(wmDrag *drag, wmDropBox *drop) | static void view3d_id_drop_copy(wmDrag *drag, wmDropBox *drop) | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | static void view3d_lightcache_update(bContext *C) | ||||
| WM_operator_properties_free(&op_ptr); | WM_operator_properties_free(&op_ptr); | ||||
| } | } | ||||
| /* region dropbox definition */ | /* region dropbox definition */ | ||||
| static void view3d_dropboxes(void) | static void view3d_dropboxes(void) | ||||
| { | { | ||||
| ListBase *lb = WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW); | ListBase *lb = WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW); | ||||
| wmDropBox *dropbox; | |||||
| WM_dropbox_add(lb, | dropbox = WM_dropbox_add(lb, | ||||
| "OBJECT_OT_add_named", | "OBJECT_OT_add_named", | ||||
| view3d_ob_drop_poll, | view3d_ob_drop_poll, | ||||
| view3d_ob_drop_copy, | view3d_ob_drop_copy, | ||||
| WM_drag_free_imported_drag_ID, | WM_drag_free_imported_drag_ID, | ||||
| NULL); | NULL); | ||||
| WM_dropbox_gizmogroup_set(dropbox, "VIEW3D_GGT_placement", view3d_ob_drag_gizmo_copy); | |||||
| WM_dropbox_add(lb, | WM_dropbox_add(lb, | ||||
| "OBJECT_OT_drop_named_material", | "OBJECT_OT_drop_named_material", | ||||
| view3d_mat_drop_poll, | view3d_mat_drop_poll, | ||||
| view3d_id_drop_copy, | view3d_id_drop_copy, | ||||
| WM_drag_free_imported_drag_ID, | WM_drag_free_imported_drag_ID, | ||||
| view3d_mat_drop_tooltip); | view3d_mat_drop_tooltip); | ||||
| WM_dropbox_add(lb, | WM_dropbox_add(lb, | ||||
| "VIEW3D_OT_background_image_add", | "VIEW3D_OT_background_image_add", | ||||
| ▲ Show 20 Lines • Show All 1,091 Lines • Show Last 20 Lines | |||||