Blender V5.3
node_fn_transpose_matrix.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::Matrix>("Matrix"_ustr);
19 b.add_output<decl::Matrix>("Matrix"_ustr).align_with_previous();
20}
21
23{
24 static auto fn = mf::build::SI1_SO<float4x4, float4x4>(
25 "Transpose Matrix", [](float4x4 matrix) { return math::transpose(matrix); });
26 builder.set_matching_fn(fn);
27}
28
29static int node_gpu_material(GPUMaterial *material,
30 bNode *node,
31 bNodeExecData * /*execdata*/,
32 GPUNodeStack *inputs,
33 GPUNodeStack *outputs)
34{
35 return GPU_stack_link(material, node, "node_function_transpose_matrix", inputs, outputs);
36}
37
38static void node_register()
39{
40 static bke::bNodeType ntype;
41 fn_cmp_node_type_base(&ntype, "FunctionNodeTransposeMatrix"_ustr, FN_NODE_TRANSPOSE_MATRIX);
42 ntype.ui_name = "Transpose Matrix";
43 ntype.ui_description =
44 "Flip a matrix over its diagonal, turning columns into rows and vice-versa";
45 ntype.enum_name_legacy = "TRANSPOSE_MATRIX";
47 ntype.declare = node_declare;
51}
53
54} // namespace blender::nodes::node_fn_transpose_matrix_cc
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:484
#define FN_NODE_TRANSPOSE_MATRIX
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void set_matching_fn(const mf::MultiFunction *fn)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
MatBase< T, NumCol, NumRow > transpose(const MatBase< T, NumRow, NumCol > &mat)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
static void node_declare(NodeDeclarationBuilder &b)
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
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