Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c
- This file was moved from source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc.
| Show All 11 Lines | |||||
| * You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| * | * | ||||
| * The Original Code is Copyright (C) 2015 Blender Foundation. | * The Original Code is Copyright (C) 2015 Blender Foundation. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| */ | */ | ||||
| #include "node_shader_util.hh" | #include "../node_shader_util.h" | ||||
| #include "RE_texture.h" | #include "RE_texture.h" | ||||
| /* **************** OUTPUT ******************** */ | /* **************** OUTPUT ******************** */ | ||||
| namespace blender::nodes::node_shader_tex_pointdensity_cc { | |||||
| static bNodeSocketTemplate sh_node_tex_pointdensity_in[] = { | static bNodeSocketTemplate sh_node_tex_pointdensity_in[] = { | ||||
| {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, | {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, | ||||
| {-1, ""}, | {-1, ""}, | ||||
| }; | }; | ||||
| static bNodeSocketTemplate sh_node_tex_pointdensity_out[] = { | static bNodeSocketTemplate sh_node_tex_pointdensity_out[] = { | ||||
| {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, | {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, | ||||
| {SOCK_FLOAT, N_("Density"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f}, | {SOCK_FLOAT, N_("Density"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f}, | ||||
| {-1, ""}, | {-1, ""}, | ||||
| }; | }; | ||||
| static void node_shader_init_tex_pointdensity(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_tex_pointdensity(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| NodeShaderTexPointDensity *point_density = (NodeShaderTexPointDensity *)MEM_callocN( | NodeShaderTexPointDensity *point_density = MEM_callocN(sizeof(NodeShaderTexPointDensity), | ||||
| sizeof(NodeShaderTexPointDensity), "new pd node"); | "new pd node"); | ||||
| point_density->resolution = 100; | point_density->resolution = 100; | ||||
| point_density->radius = 0.3f; | point_density->radius = 0.3f; | ||||
| point_density->space = SHD_POINTDENSITY_SPACE_OBJECT; | point_density->space = SHD_POINTDENSITY_SPACE_OBJECT; | ||||
| point_density->color_source = SHD_POINTDENSITY_COLOR_PARTAGE; | point_density->color_source = SHD_POINTDENSITY_COLOR_PARTAGE; | ||||
| node->storage = point_density; | node->storage = point_density; | ||||
| } | } | ||||
| static void node_shader_free_tex_pointdensity(bNode *node) | static void node_shader_free_tex_pointdensity(bNode *node) | ||||
| { | { | ||||
| NodeShaderTexPointDensity *point_density = (NodeShaderTexPointDensity *)node->storage; | NodeShaderTexPointDensity *point_density = node->storage; | ||||
| PointDensity *pd = &point_density->pd; | PointDensity *pd = &point_density->pd; | ||||
| RE_point_density_free(pd); | RE_point_density_free(pd); | ||||
| BKE_texture_pointdensity_free_data(pd); | BKE_texture_pointdensity_free_data(pd); | ||||
| memset(pd, 0, sizeof(*pd)); | memset(pd, 0, sizeof(*pd)); | ||||
| MEM_freeN(point_density); | MEM_freeN(point_density); | ||||
| } | } | ||||
| static void node_shader_copy_tex_pointdensity(bNodeTree *UNUSED(dest_ntree), | static void node_shader_copy_tex_pointdensity(bNodeTree *UNUSED(dest_ntree), | ||||
| bNode *dest_node, | bNode *dest_node, | ||||
| const bNode *src_node) | const bNode *src_node) | ||||
| { | { | ||||
| dest_node->storage = MEM_dupallocN(src_node->storage); | dest_node->storage = MEM_dupallocN(src_node->storage); | ||||
| NodeShaderTexPointDensity *point_density = (NodeShaderTexPointDensity *)dest_node->storage; | NodeShaderTexPointDensity *point_density = dest_node->storage; | ||||
| PointDensity *pd = &point_density->pd; | PointDensity *pd = &point_density->pd; | ||||
| memset(pd, 0, sizeof(*pd)); | memset(pd, 0, sizeof(*pd)); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_tex_pointdensity_cc | |||||
| /* node type definition */ | /* node type definition */ | ||||
| void register_node_type_sh_tex_pointdensity() | void register_node_type_sh_tex_pointdensity(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_tex_pointdensity_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_node_type_base(&ntype, SH_NODE_TEX_POINTDENSITY, "Point Density", NODE_CLASS_TEXTURE, 0); | sh_node_type_base(&ntype, SH_NODE_TEX_POINTDENSITY, "Point Density", NODE_CLASS_TEXTURE, 0); | ||||
| node_type_socket_templates( | node_type_socket_templates(&ntype, sh_node_tex_pointdensity_in, sh_node_tex_pointdensity_out); | ||||
| &ntype, file_ns::sh_node_tex_pointdensity_in, file_ns::sh_node_tex_pointdensity_out); | node_type_init(&ntype, node_shader_init_tex_pointdensity); | ||||
| node_type_init(&ntype, file_ns::node_shader_init_tex_pointdensity); | |||||
| node_type_storage(&ntype, | node_type_storage(&ntype, | ||||
| "NodeShaderTexPointDensity", | "NodeShaderTexPointDensity", | ||||
| file_ns::node_shader_free_tex_pointdensity, | node_shader_free_tex_pointdensity, | ||||
| file_ns::node_shader_copy_tex_pointdensity); | node_shader_copy_tex_pointdensity); | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||