Blender V5.3
node_fn_transform_direction.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>("Direction"_ustr).subtype(PROP_XYZ);
19 b.add_output<decl::Vector>("Direction"_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 Direction", [](float3 direction, float4x4 matrix) {
27 return math::transform_direction(matrix, direction);
28 });
29 builder.set_matching_fn(fn);
30}
31
32static int node_gpu_material(GPUMaterial *material,
33 bNode *node,
34 bNodeExecData * /*execdata*/,
35 GPUNodeStack *inputs,
36 GPUNodeStack *outputs)
37{
38 return GPU_stack_link(material, node, "node_function_transform_direction", inputs, outputs);
39}
40
41static void node_register()
42{
43 static bke::bNodeType ntype;
45 &ntype, "FunctionNodeTransformDirection"_ustr, FN_NODE_TRANSFORM_DIRECTION);
46 ntype.ui_name = "Transform Direction";
47 ntype.ui_description =
48 "Apply a transformation matrix (excluding translation) to the given vector";
49 ntype.enum_name_legacy = "TRANSFORM_DIRECTION";
51 ntype.declare = node_declare;
55}
57
58} // namespace blender::nodes::node_fn_transform_direction_cc
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:484
#define FN_NODE_TRANSFORM_DIRECTION
#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_direction(const MatBase< T, 3, 3 > &mat, const VecBase< T, 3 > &direction)
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
static void node_declare(NodeDeclarationBuilder &b)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
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