Blender V5.0
node_geo_mouse_position.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
8
10{
11 b.add_output<decl::Int>("Mouse X").description(
12 "The region-space mouse X location, in pixels, increasing from 0 at the left");
13 b.add_output<decl::Int>("Mouse Y").description(
14 "The region-space mouse Y location, in pixels, increasing from 0 at the bottom");
15 b.add_output<decl::Int>("Region Width").description("The total X size of the region in pixels");
16 b.add_output<decl::Int>("Region Height").description("The total Y size of the region in pixels");
17}
18
20{
22 return;
23 }
24 const int2 mouse = params.user_data()->call_data->operator_data->mouse_position;
25 const int2 size = params.user_data()->call_data->operator_data->region_size;
26 params.set_output("Mouse X", mouse.x);
27 params.set_output("Mouse Y", mouse.y);
28 params.set_output("Region Width", size.x);
29 params.set_output("Region Height", size.y);
30}
31
32static void node_register()
33{
34 static blender::bke::bNodeType ntype;
35 geo_node_type_base(&ntype, "GeometryNodeToolMousePosition", GEO_NODE_TOOL_MOUSE_POSITION);
36 ntype.ui_name = "Mouse Position";
37 ntype.ui_description = "Retrieve the position of the mouse cursor";
38 ntype.enum_name_legacy = "TOOL_MOUSE_POSITION";
40 ntype.declare = node_declare;
44}
46
47} // namespace blender::nodes::node_geo_mouse_position_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define GEO_NODE_TOOL_MOUSE_POSITION
#define NOD_REGISTER_NODE(REGISTER_FUNC)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static void node_declare(NodeDeclarationBuilder &b)
static void node_geo_exec(GeoNodeExecParams params)
void search_link_ops_for_tool_node(GatherLinkSearchOpParams &params)
bool check_tool_context_and_error(GeoNodeExecParams &params)
VecBase< int32_t, 2 > int2
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:354
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:378
NodeDeclareFunction declare
Definition BKE_node.hh:362