Blender V5.0
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
9#include "BLI_math_vector.h"
10#include "node_texture_util.hh"
11
13 {SOCK_VECTOR, N_("Coordinate 1"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE},
14 {SOCK_VECTOR, N_("Coordinate 2"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE},
15 {-1, ""},
16};
17
19 {SOCK_FLOAT, N_("Value")},
20 {-1, ""},
21};
22
23static void valuefn(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
24{
25 float co1[3], co2[3];
26
27 tex_input_vec(co1, in[0], p, thread);
28 tex_input_vec(co2, in[1], p, thread);
29
30 *out = len_v3v3(co2, co1);
31}
32
33static void exec(void *data,
34 int /*thread*/,
35 bNode *node,
36 bNodeExecData *execdata,
37 bNodeStack **in,
39{
40 tex_output(node, execdata, in, out[0], &valuefn, static_cast<TexCallData *>(data));
41}
42
44{
45 static blender::bke::bNodeType ntype;
46
47 tex_node_type_base(&ntype, "TextureNodeDistance", TEX_NODE_DISTANCE);
48 ntype.ui_name = "Distance";
49 ntype.enum_name_legacy = "DISTANCE";
52 ntype.exec_fn = exec;
53
55}
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:453
#define TEX_NODE_DISTANCE
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
@ SOCK_VECTOR
@ SOCK_FLOAT
@ PROP_NONE
Definition RNA_types.hh:233
BMesh const char void * data
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs)
Definition node.cc:5352
static blender::bke::bNodeSocketTemplate outputs[]
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
static blender::bke::bNodeSocketTemplate inputs[]
void register_node_type_tex_distance()
static void valuefn(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
void tex_output(bNode *node, bNodeExecData *, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
Compact definition of a node socket.
Definition BKE_node.hh:99
Defines a node type.
Definition BKE_node.hh:238
NodeExecFunction exec_fn
Definition BKE_node.hh:340
const char * enum_name_legacy
Definition BKE_node.hh:247
#define N_(msgid)