Blender V5.3
node_fn_matrix_determinant.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
5#include "BLI_math_matrix.hh"
6
7#include "GPU_material.hh"
8
10
12
14{
15 b.is_function_node();
16 b.add_input<decl::Matrix>("Matrix"_ustr);
17 b.add_output<decl::Float>("Determinant"_ustr);
18}
19
21{
22 static auto fn = mf::build::SI1_SO<float4x4, float>(
23 "Matrix Determinant", [](const float4x4 &matrix) { return math::determinant(matrix); });
24 builder.set_matching_fn(fn);
25}
26
27static int node_gpu_material(GPUMaterial *material,
28 bNode *node,
29 bNodeExecData * /*execdata*/,
30 GPUNodeStack *inputs,
31 GPUNodeStack *outputs)
32{
33 return GPU_stack_link(material, node, "node_function_matrix_determinant", inputs, outputs);
34}
35
36static void node_register()
37{
38 static bke::bNodeType ntype;
39 fn_cmp_node_type_base(&ntype, "FunctionNodeMatrixDeterminant"_ustr, FN_NODE_MATRIX_DETERMINANT);
40 ntype.ui_name = "Matrix Determinant";
41 ntype.ui_description = "Compute the determinant of the given matrix";
42 ntype.enum_name_legacy = "MATRIX_DETERMINANT";
44 ntype.declare = node_declare;
48}
50
51} // namespace blender::nodes::node_fn_matrix_determinant_cc
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:484
#define FN_NODE_MATRIX_DETERMINANT
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void set_matching_fn(const mf::MultiFunction *fn)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
T determinant(const MatBase< T, Size, Size > &mat)
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
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