diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index 419f74353ca..cfd33ddad45 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -6,6 +6,9 @@ * \ingroup spnode */ + +#include "AS_asset_representation.hh" + #include "BLI_string.h" #include "DNA_ID.h" @@ -17,8 +20,10 @@ #include "MEM_guardedalloc.h" +#include "BKE_asset.h" #include "BKE_context.h" #include "BKE_gpencil_legacy.h" +#include "BKE_idprop.h" #include "BKE_lib_id.h" #include "BKE_lib_query.h" #include "BKE_lib_remap.h" @@ -674,9 +679,36 @@ static void node_main_region_draw(const bContext *C, ARegion *region) /* ************* dropboxes ************* */ -static bool node_group_drop_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/) +static bool node_group_drop_poll(bContext *C, wmDrag *drag, const wmEvent * /*event*/) { - return WM_drag_is_ID_type(drag, ID_NT); + SpaceNode *snode = CTX_wm_space_node(C); + + if (!WM_drag_is_ID_type(drag, ID_NT)) { + return false; + } + + if (drag->type == WM_DRAG_ID) { + const bNodeTree *node_tree = reinterpret_cast( + WM_drag_get_local_ID(drag, ID_NT)); + if (!node_tree) { + return false; + } + return node_tree->type == snode->edittree->type; + } + + if (drag->type == WM_DRAG_ASSET) { + const wmDragAsset *asset_data = WM_drag_get_asset_data(drag, ID_NT); + if (!asset_data) { + return false; + } + const AssetMetaData *metadata = &asset_data->asset->get_metadata(); + const IDProperty *tree_type = BKE_asset_metadata_idprop_find(metadata, "type"); + if (!tree_type || IDP_Int(tree_type) != snode->edittree->type) { + return false; + } + } + + return true; } static bool node_object_drop_poll(bContext *C, wmDrag *drag, const wmEvent * /*event*/)