Blender V5.0
node_geo_tool_3d_cursor.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BLI_math_matrix.hh"
6
8
10
12{
13 b.add_output<decl::Vector>("Location")
14 .subtype(PROP_TRANSLATION)
16 "The location of the scene's 3D cursor, in the local space of the modified object");
17 b.add_output<decl::Rotation>("Rotation")
18 .description(
19 "The rotation of the scene's 3D cursor, in the local space of the modified object");
20}
21
23{
25 return;
26 }
27 const GeoNodesOperatorData &data = *params.user_data()->call_data->operator_data;
28 const float4x4 &world_to_object = params.self_object()->world_to_object();
29
30 const float3 location_global = data.cursor_position;
31 params.set_output("Location", math::transform_point(world_to_object, location_global));
32
33 math::Quaternion rotation_global = data.cursor_rotation;
34 params.set_output("Rotation", math::to_quaternion(world_to_object) * rotation_global);
35}
36
37static void node_register()
38{
39 static blender::bke::bNodeType ntype;
40 geo_node_type_base(&ntype, "GeometryNodeTool3DCursor", GEO_NODE_TOOL_3D_CURSOR);
41 ntype.ui_name = "3D Cursor";
42 ntype.ui_description = "The scene's 3D cursor location and rotation";
43 ntype.enum_name_legacy = "TOOL_3D_CURSOR";
45 ntype.declare = node_declare;
49}
51
52} // namespace blender::nodes::node_geo_tool_3d_cursor_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define GEO_NODE_TOOL_3D_CURSOR
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ PROP_TRANSLATION
Definition RNA_types.hh:261
BMesh const char void * data
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
QuaternionBase< float > Quaternion
QuaternionBase< T > to_quaternion(const AxisAngleBase< T, AngleT > &axis_angle)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
void search_link_ops_for_tool_node(GatherLinkSearchOpParams &params)
bool check_tool_context_and_error(GeoNodeExecParams &params)
MatBase< float, 4, 4 > float4x4
VecBase< float, 3 > float3
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