Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_viewer.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "ED_node.h" | #include "ED_node.h" | ||||
| #include "ED_spreadsheet.h" | #include "ED_viewer_path.hh" | ||||
| #include "NOD_socket_search_link.hh" | #include "NOD_socket_search_link.hh" | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_viewer_cc { | namespace blender::nodes::node_geo_viewer_cc { | ||||
| NODE_STORAGE_FUNCS(NodeGeometryViewer) | NODE_STORAGE_FUNCS(NodeGeometryViewer) | ||||
| static void node_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>(N_("Geometry")); | b.add_input<decl::Geometry>(N_("Geometry")); | ||||
| b.add_input<decl::Float>(N_("Value")).supports_field().hide_value(); | b.add_input<decl::Float>(N_("Value")).supports_field().hide_value(); | ||||
| b.add_input<decl::Vector>(N_("Value"), "Value_001").supports_field().hide_value(); | b.add_input<decl::Vector>(N_("Value"), "Value_001").supports_field().hide_value(); | ||||
| b.add_input<decl::Color>(N_("Value"), "Value_002").supports_field().hide_value(); | b.add_input<decl::Color>(N_("Value"), "Value_002").supports_field().hide_value(); | ||||
| b.add_input<decl::Int>(N_("Value"), "Value_003").supports_field().hide_value(); | b.add_input<decl::Int>(N_("Value"), "Value_003").supports_field().hide_value(); | ||||
| b.add_input<decl::Bool>(N_("Value"), "Value_004").supports_field().hide_value(); | b.add_input<decl::Bool>(N_("Value"), "Value_004").supports_field().hide_value(); | ||||
| } | } | ||||
| static void node_init(bNodeTree *UNUSED(tree), bNode *node) | static void node_init(bNodeTree *UNUSED(tree), bNode *node) | ||||
| { | { | ||||
| NodeGeometryViewer *data = MEM_cnew<NodeGeometryViewer>(__func__); | NodeGeometryViewer *data = MEM_cnew<NodeGeometryViewer>(__func__); | ||||
| data->data_type = CD_PROP_FLOAT; | data->data_type = CD_PROP_FLOAT; | ||||
| data->domain = ATTR_DOMAIN_AUTO; | |||||
| node->storage = data; | node->storage = data; | ||||
| } | } | ||||
| static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | ||||
| { | { | ||||
| uiItemR(layout, ptr, "domain", 0, "", ICON_NONE); | |||||
| } | |||||
| static void node_layout_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | |||||
| { | |||||
| uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE); | uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE); | ||||
| } | } | ||||
| static eNodeSocketDatatype custom_data_type_to_socket_type(const eCustomDataType type) | static eNodeSocketDatatype custom_data_type_to_socket_type(const eCustomDataType type) | ||||
| { | { | ||||
| switch (type) { | switch (type) { | ||||
| case CD_PROP_FLOAT: | case CD_PROP_FLOAT: | ||||
| return SOCK_FLOAT; | return SOCK_FLOAT; | ||||
| Show All 27 Lines | |||||
| static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) | static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) | ||||
| { | { | ||||
| auto set_active_fn = [](LinkSearchOpParams ¶ms, bNode &viewer_node) { | auto set_active_fn = [](LinkSearchOpParams ¶ms, bNode &viewer_node) { | ||||
| /* Set this new viewer node active in spreadsheet editors. */ | /* Set this new viewer node active in spreadsheet editors. */ | ||||
| SpaceNode *snode = CTX_wm_space_node(¶ms.C); | SpaceNode *snode = CTX_wm_space_node(¶ms.C); | ||||
| Main *bmain = CTX_data_main(¶ms.C); | Main *bmain = CTX_data_main(¶ms.C); | ||||
| ED_node_set_active(bmain, snode, ¶ms.node_tree, &viewer_node, nullptr); | ED_node_set_active(bmain, snode, ¶ms.node_tree, &viewer_node, nullptr); | ||||
| ED_spreadsheet_context_paths_set_geometry_node(bmain, snode, &viewer_node); | ed::viewer_path::activate_geometry_node(*bmain, *snode, viewer_node); | ||||
| }; | }; | ||||
| const std::optional<eCustomDataType> type = node_socket_to_custom_data_type( | const std::optional<eCustomDataType> type = node_socket_to_custom_data_type( | ||||
| params.other_socket()); | params.other_socket()); | ||||
| if (params.in_out() == SOCK_OUT) { | if (params.in_out() == SOCK_OUT) { | ||||
| /* The viewer node only has inputs. */ | /* The viewer node only has inputs. */ | ||||
| return; | return; | ||||
| } | } | ||||
| Show All 36 Lines | void register_node_type_geo_viewer() | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base(&ntype, GEO_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT); | geo_node_type_base(&ntype, GEO_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT); | ||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeGeometryViewer", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeGeometryViewer", node_free_standard_storage, node_copy_standard_storage); | ||||
| node_type_update(&ntype, file_ns::node_update); | node_type_update(&ntype, file_ns::node_update); | ||||
| node_type_init(&ntype, file_ns::node_init); | node_type_init(&ntype, file_ns::node_init); | ||||
| ntype.declare = file_ns::node_declare; | ntype.declare = file_ns::node_declare; | ||||
| ntype.draw_buttons_ex = file_ns::node_layout; | ntype.draw_buttons = file_ns::node_layout; | ||||
| ntype.draw_buttons_ex = file_ns::node_layout_ex; | |||||
| ntype.gather_link_search_ops = file_ns::node_gather_link_searches; | ntype.gather_link_search_ops = file_ns::node_gather_link_searches; | ||||
| ntype.no_muting = true; | |||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||