Blender  V2.93
node_shader_tex_pointdensity.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2015 Blender Foundation.
17  * All rights reserved.
18  */
19 
20 #include "../node_shader_util.h"
21 
22 #include "RE_texture.h"
23 
24 /* **************** OUTPUT ******************** */
25 
27  {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
28  {-1, ""},
29 };
30 
32  {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
33  {SOCK_FLOAT, N_("Density"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
34  {-1, ""},
35 };
36 
38 {
40  "new pd node");
41  point_density->resolution = 100;
42  point_density->radius = 0.3f;
43  point_density->space = SHD_POINTDENSITY_SPACE_OBJECT;
45  node->storage = point_density;
46 }
47 
49 {
50  NodeShaderTexPointDensity *point_density = node->storage;
51  PointDensity *pd = &point_density->pd;
54  memset(pd, 0, sizeof(*pd));
55  MEM_freeN(point_density);
56 }
57 
59  bNode *dest_node,
60  const bNode *src_node)
61 {
62  dest_node->storage = MEM_dupallocN(src_node->storage);
63  NodeShaderTexPointDensity *point_density = dest_node->storage;
64  PointDensity *pd = &point_density->pd;
65  memset(pd, 0, sizeof(*pd));
66 }
67 
68 /* node type definition */
70 {
71  static bNodeType ntype;
72 
76  node_type_storage(&ntype,
77  "NodeShaderTexPointDensity",
80 
81  nodeRegisterType(&ntype);
82 }
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
Definition: node.cc:4527
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4559
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
Definition: node.cc:4599
#define SH_NODE_TEX_POINTDENSITY
Definition: BKE_node.h:1057
#define NODE_CLASS_TEXTURE
Definition: BKE_node.h:346
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1298
void BKE_texture_pointdensity_free_data(struct PointDensity *pd)
Definition: texture.c:657
#define UNUSED(x)
#define N_(msgid)
@ SHD_POINTDENSITY_SPACE_OBJECT
@ SOCK_HIDE_VALUE
@ SOCK_VECTOR
@ SOCK_FLOAT
@ SOCK_RGBA
@ SHD_POINTDENSITY_COLOR_PARTAGE
@ PROP_NONE
Definition: RNA_types.h:113
OperationNode * node
bNodeTree * ntree
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:42
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static void node_shader_copy_tex_pointdensity(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
static void node_shader_free_tex_pointdensity(bNode *node)
static bNodeSocketTemplate sh_node_tex_pointdensity_in[]
static bNodeSocketTemplate sh_node_tex_pointdensity_out[]
void register_node_type_sh_tex_pointdensity(void)
static void node_shader_init_tex_pointdensity(bNodeTree *UNUSED(ntree), bNode *node)
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag)
Compact definition of a node socket.
Definition: BKE_node.h:95
Defines a node type.
Definition: BKE_node.h:221
void * storage
void RE_point_density_free(struct PointDensity *pd)