Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2011-02-07 12:33:36 +0300
committerLukas Toenne <lukas.toenne@googlemail.com>2011-02-07 12:33:36 +0300
commit2070356a329969be2287e6f8f7575a7e45d13543 (patch)
tree47ddc31594db82fb9e888b4ffbd71abadd21460b /source/blender/nodes/intern
parentd272b70ee09be8c949247404c9324cfffc833976 (diff)
A simplified way of defining bNodeType structs. Instead of doing full struct member initialization for each node, this uses a couple of helper functions now. This will make it easier to change and extend the bNodeSocket interface in the future. Two examples (normal and mapping shader nodes) included, the rest should be converted too.
Diffstat (limited to 'source/blender/nodes/intern')
-rw-r--r--source/blender/nodes/intern/SHD_nodes/SHD_mapping.c30
-rw-r--r--source/blender/nodes/intern/SHD_nodes/SHD_normal.c29
-rw-r--r--source/blender/nodes/intern/SHD_util.h1
3 files changed, 24 insertions, 36 deletions
diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_mapping.c b/source/blender/nodes/intern/SHD_nodes/SHD_mapping.c
index f01ed3d7ab8..dce8d1962c7 100644
--- a/source/blender/nodes/intern/SHD_nodes/SHD_mapping.c
+++ b/source/blender/nodes/intern/SHD_nodes/SHD_mapping.c
@@ -83,22 +83,16 @@ static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, G
return GPU_stack_link(mat, "mapping", in, out, tmat, tmin, tmax, tdomin, tdomax);
}
-bNodeType sh_node_mapping= {
- /* *next,*prev */ NULL, NULL,
- /* type code */ SH_NODE_MAPPING,
- /* name */ "Mapping",
- /* width+range */ 240, 160, 320,
- /* class+opts */ NODE_CLASS_OP_VECTOR, NODE_OPTIONS,
- /* input sock */ sh_node_mapping_in,
- /* output sock */ sh_node_mapping_out,
- /* storage */ "TexMapping",
- /* execfunc */ node_shader_exec_mapping,
- /* butfunc */ NULL,
- /* initfunc */ node_shader_init_mapping,
- /* freestoragefunc */ node_free_standard_storage,
- /* copystoragefunc */ node_copy_standard_storage,
- /* id */ NULL, NULL, NULL,
- /* gpufunc */ gpu_shader_mapping
+void register_node_type_sh_mapping(ListBase *lb)
+{
+ static bNodeType ntype;
-};
-
+ node_type_init(&ntype, SH_NODE_MAPPING, "Mapping", NODE_CLASS_OP_VECTOR, NODE_OPTIONS,
+ sh_node_mapping_in, sh_node_mapping_out);
+ node_type_size(&ntype, 240, 160, 320);
+ node_type_storage(&ntype, "TexMapping", node_shader_init_mapping, node_free_standard_storage, node_copy_standard_storage);
+ node_type_exec(&ntype, node_shader_exec_mapping);
+ node_type_gpu(&ntype, gpu_shader_mapping);
+
+ nodeRegisterType(lb, &ntype);
+}
diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_normal.c b/source/blender/nodes/intern/SHD_nodes/SHD_normal.c
index 8054f184cea..35c8f44c706 100644
--- a/source/blender/nodes/intern/SHD_nodes/SHD_normal.c
+++ b/source/blender/nodes/intern/SHD_nodes/SHD_normal.c
@@ -65,21 +65,14 @@ static int gpu_shader_normal(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GP
return GPU_stack_link(mat, "normal", in, out, vec);
}
-bNodeType sh_node_normal= {
- /* *next,*prev */ NULL, NULL,
- /* type code */ SH_NODE_NORMAL,
- /* name */ "Normal",
- /* width+range */ 100, 60, 200,
- /* class+opts */ NODE_CLASS_OP_VECTOR, NODE_OPTIONS,
- /* input sock */ sh_node_normal_in,
- /* output sock */ sh_node_normal_out,
- /* storage */ "",
- /* execfunc */ node_shader_exec_normal,
- /* butfunc */ NULL,
- /* initfunc */ NULL,
- /* freestoragefunc */ NULL,
- /* copystoragefunc */ NULL,
- /* id */ NULL, NULL, NULL,
- /* gpufunc */ gpu_shader_normal
-};
-
+void register_node_type_sh_normal(ListBase *lb)
+{
+ static bNodeType ntype;
+
+ node_type_init(&ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR, NODE_OPTIONS,
+ sh_node_normal_in, sh_node_normal_out);
+ node_type_exec(&ntype, node_shader_exec_normal);
+ node_type_gpu(&ntype, gpu_shader_normal);
+
+ nodeRegisterType(lb, &ntype);
+}
diff --git a/source/blender/nodes/intern/SHD_util.h b/source/blender/nodes/intern/SHD_util.h
index 147291e380a..4134c160f16 100644
--- a/source/blender/nodes/intern/SHD_util.h
+++ b/source/blender/nodes/intern/SHD_util.h
@@ -51,6 +51,7 @@
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_material.h"
+#include "BKE_node.h"
#include "BKE_texture.h"
#include "BKE_library.h"