Blender V5.3
node_texture_distance.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10#include "node_texture_util.hh"
11
12namespace blender {
13
15 {SOCK_VECTOR, N_("Coordinate 1"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE},
16 {SOCK_VECTOR, N_("Coordinate 2"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE},
17 {-1, ""},
18};
19
21 {SOCK_FLOAT, N_("Value")},
22 {-1, ""},
23};
24
25static void valuefn(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
26{
27 float co1[3], co2[3];
28
29 tex_input_vec(co1, in[0], p, thread);
30 tex_input_vec(co2, in[1], p, thread);
31
32 *out = len_v3v3(co2, co1);
33}
34
35static void exec(void *data,
36 int /*thread*/,
37 bNode *node,
38 bNodeExecData *execdata,
39 bNodeStack **in,
41{
42 tex_output(node, execdata, in, out[0], &valuefn, static_cast<TexCallData *>(data));
43}
44
46{
47 static bke::bNodeType ntype;
48
49 tex_node_type_base(&ntype, "TextureNodeDistance"_ustr, TEX_NODE_DISTANCE);
50 ntype.ui_name = "Distance";
51 ntype.enum_name_legacy = "DISTANCE";
54 ntype.exec_fn = exec;
55
57}
58
59} // namespace blender
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:484
#define TEX_NODE_DISTANCE
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs)
Definition node.cc:6134
BMesh Iterators.
void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread)
void register_node_type_tex_distance()
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
BMesh const char void * data
void tex_output(bNode *node, bNodeExecData *, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
static bke::bNodeSocketTemplate inputs[]
void tex_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
static void valuefn(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
static bke::bNodeSocketTemplate outputs[]
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
Compact definition of a node socket.
Definition BKE_node.hh:102
Defines a node type.
Definition BKE_node.hh:265
NodeExecFunction exec_fn
Definition BKE_node.hh:371
const char * enum_name_legacy
Definition BKE_node.hh:274
#define N_(msgid)