Blender V5.3
node_fn_transform_point.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
7#include "GPU_material.hh"
8
10
12
14{
15 b.use_custom_socket_order();
16 b.allow_any_socket_order();
17 b.is_function_node();
18 b.add_input<decl::Vector>("Vector"_ustr).subtype(PROP_XYZ).is_default_link_socket();
19 b.add_output<decl::Vector>("Vector"_ustr).subtype(PROP_XYZ).align_with_previous();
20 b.add_input<decl::Matrix>("Transform"_ustr);
21}
22
24{
25 static auto fn = mf::build::SI2_SO<float3, float4x4, float3>(
26 "Transform Point",
27 [](float3 point, float4x4 matrix) { return math::transform_point(matrix, point); });
28 builder.set_matching_fn(fn);
29}
30
31static int node_gpu_material(GPUMaterial *material,
32 bNode *node,
33 bNodeExecData * /*execdata*/,
34 GPUNodeStack *inputs,
35 GPUNodeStack *outputs)
36{
37 return GPU_stack_link(material, node, "node_function_transform_point", inputs, outputs);
38}
39
40static void node_register()
41{
42 static bke::bNodeType ntype;
43 fn_cmp_node_type_base(&ntype, "FunctionNodeTransformPoint"_ustr, FN_NODE_TRANSFORM_POINT);
44 ntype.ui_name = "Transform Point";
45 ntype.ui_description = "Apply a transformation matrix to the given vector";
46 ntype.enum_name_legacy = "TRANSFORM_POINT";
48 ntype.declare = node_declare;
52}
54
55} // namespace blender::nodes::node_fn_transform_point_cc
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:484
#define FN_NODE_TRANSFORM_POINT
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void set_matching_fn(const mf::MultiFunction *fn)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
static void node_declare(NodeDeclarationBuilder &b)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void fn_cmp_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
MatBase< float, 4, 4 > float4x4
VecBase< float, 3 > float3
Defines a node type.
Definition BKE_node.hh:265
std::string ui_description
Definition BKE_node.hh:271
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:373
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:382
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393