Blender  V3.3
node_texture_distance.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2005 Blender Foundation. All rights reserved. */
3 
8 #include "NOD_texture.h"
9 #include "node_texture_util.h"
10 #include <math.h>
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 
23 static void valuefn(float *out, TexParams *p, bNode *UNUSED(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 
33 static void exec(void *data,
34  int UNUSED(thread),
35  bNode *node,
36  bNodeExecData *execdata,
37  bNodeStack **in,
38  bNodeStack **out)
39 {
40  tex_output(node, execdata, in, out[0], &valuefn, data);
41 }
42 
44 {
45  static bNodeType ntype;
46 
49  node_type_exec(&ntype, NULL, NULL, exec);
50 
51  nodeRegisterType(&ntype);
52 }
#define TEX_NODE_DISTANCE
Definition: BKE_node.h:1364
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
Definition: node.cc:4358
#define NODE_CLASS_CONVERTER
Definition: BKE_node.h:351
void node_type_exec(struct bNodeType *ntype, NodeInitExecFunction init_exec_fn, NodeFreeExecFunction free_exec_fn, NodeExecFunction exec_fn)
Definition: node.cc:4455
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
#define UNUSED(x)
@ SOCK_VECTOR
@ SOCK_FLOAT
@ PROP_NONE
Definition: RNA_types.h:126
Definition: thread.h:34
OperationNode * node
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static bNodeSocketTemplate outputs[]
static bNodeSocketTemplate inputs[]
static void valuefn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
void register_node_type_tex_distance(void)
void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass)
void tex_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
Compact definition of a node socket.
Definition: BKE_node.h:84
Defines a node type.
Definition: BKE_node.h:226
#define N_(msgid)