[Bf-blender-cvs] [a4ba733] texture_nodes_refactor: Port some more nodes
Sergey Sharybin
noreply at git.blender.org
Mon Oct 13 20:51:51 CEST 2014
Commit: a4ba73311b4c2d862145f86ca078216b7ecbb56f
Author: Sergey Sharybin
Date: Tue Oct 14 00:50:26 2014 +0600
Branches: texture_nodes_refactor
https://developer.blender.org/rBa4ba73311b4c2d862145f86ca078216b7ecbb56f
Port some more nodes
Now only node group remained to be ported, all the rest of the nodes
cant' be actually supported and will be removed.
As a replacement for them we'll bring some more control by adding
some mapping sockets to the input nodes.
===================================================================
M source/blender/nodes/texture/nodes/node_texture_curves.c
M source/blender/nodes/texture/nodes/node_texture_texture.c
M source/blender/nodes/texture/nodes/node_texture_valToRgb.c
===================================================================
diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c
index af82b78..6efd463 100644
--- a/source/blender/nodes/texture/nodes/node_texture_curves.c
+++ b/source/blender/nodes/texture/nodes/node_texture_curves.c
@@ -41,22 +41,23 @@ static bNodeSocketTemplate time_outputs[] = {
{ -1, 0, "" }
};
-static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(in), short UNUSED(thread))
+static void time_exec(void *data,
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *UNUSED(execdata),
+ bNodeStack **UNUSED(in),
+ bNodeStack **out)
{
+ TexCallData *cdata = (TexCallData *)data;
/* stack order output: fac */
float fac = 0.0f;
-
+
if (node->custom1 < node->custom2)
- fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1);
-
+ fac = (cdata->cfra - node->custom1) / (float)(node->custom2 - node->custom1);
+
curvemapping_initialize(node->storage);
fac = curvemapping_evaluateF(node->storage, 0, fac);
- out[0] = CLAMPIS(fac, 0.0f, 1.0f);
-}
-
-static void time_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
-{
- tex_output(node, execdata, in, out[0], &time_colorfn, data);
+ out[0]->vec[0] = CLAMPIS(fac, 0.0f, 1.0f);
}
@@ -70,14 +71,14 @@ static void time_init(bNodeTree *UNUSED(ntree), bNode *node)
void register_node_type_tex_curve_time(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_CURVE_TIME, "Time", NODE_CLASS_INPUT, 0);
node_type_socket_templates(&ntype, NULL, time_outputs);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_init(&ntype, time_init);
node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
node_type_exec(&ntype, node_initexec_curves, NULL, time_exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c
index 0ee4bcd..9b87ba1 100644
--- a/source/blender/nodes/texture/nodes/node_texture_texture.c
+++ b/source/blender/nodes/texture/nodes/node_texture_texture.c
@@ -46,62 +46,64 @@ static bNodeSocketTemplate outputs[] = {
{ -1, 0, "" }
};
-static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
+static void exec(void *data,
+ int thread,
+ bNode *node,
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **out)
{
Tex *nodetex = (Tex *)node->id;
- static float red[] = {1, 0, 0, 1};
- static float white[] = {1, 1, 1, 1};
+ TexCallData *cdata = (TexCallData *)data;
+ static float red[] = {1.0f, 0.0f, 0.0f, 1.0f};
+ static float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
float co[3], dxt[3], dyt[3];
-
- copy_v3_v3(co, p->co);
- if (p->osatex) {
- copy_v3_v3(dxt, p->dxt);
- copy_v3_v3(dyt, p->dyt);
+
+ copy_v3_v3(co, cdata->co);
+ if (cdata->osatex) {
+ copy_v3_v3(dxt, cdata->dxt);
+ copy_v3_v3(dyt, cdata->dyt);
}
else {
zero_v3(dxt);
zero_v3(dyt);
}
-
+
if (node->custom2 || node->need_exec == 0) {
/* this node refers to its own texture tree! */
- copy_v4_v4(out, (fabsf(co[0] - co[1]) < 0.01f) ? white : red);
+ copy_v4_v4(out[0]->vec, (fabsf(co[0] - co[1]) < 0.01f) ? white : red);
}
else if (nodetex) {
TexResult texres;
int textype;
float nor[] = {0, 0, 0};
float col1[4], col2[4];
-
+
tex_input_rgba(col1, in[0]);
tex_input_rgba(col2, in[1]);
-
+
texres.nor = nor;
- textype = multitex_nodes(nodetex, co, dxt, dyt, p->osatex,
- &texres, thread, 0, p->shi, p->mtex, NULL);
-
+ textype = multitex_nodes(nodetex, co, dxt, dyt, cdata->osatex,
+ &texres, thread, 0, cdata->shi, cdata->mtex, NULL);
+
if (textype & TEX_RGB) {
- copy_v4_v4(out, &texres.tr);
+ copy_v4_v4(out[0]->vec, &texres.tr);
}
else {
- copy_v4_v4(out, col1);
- ramp_blend(MA_RAMP_BLEND, out, texres.tin, col2);
+ copy_v4_v4(out[0]->vec, col1);
+ ramp_blend(MA_RAMP_BLEND, out[0]->vec, texres.tin, col2);
}
}
-}
-
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
-{
- tex_output(node, execdata, in, out[0], &colorfn, data);
+ tex_do_preview(execdata->preview, cdata->co, out[0]->vec, cdata->do_manage);
}
void register_node_type_tex_texture(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_PREVIEW);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
index 6bd87b7..ed54789 100644
--- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
+++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
@@ -4,7 +4,7 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -86,26 +86,25 @@ static bNodeSocketTemplate rgbtobw_out[] = {
{ -1, 0, "" }
};
-
-static void rgbtobw_valuefn(float *out, TexParams *UNUSED(p), bNode *UNUSED(node), bNodeStack **in, short UNUSED(thread))
+static void rgbtobw_exec(void *UNUSED(data),
+ int UNUSED(thread),
+ bNode *UNUSED(node),
+ bNodeExecData *UNUSED(execdata),
+ bNodeStack **in,
+ bNodeStack **out)
{
float cin[4];
tex_input_rgba(cin, in[0]);
- *out = rgb_to_bw(cin);
-}
-
-static void rgbtobw_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
-{
- tex_output(node, execdata, in, out[0], &rgbtobw_valuefn, data);
+ out[0]->vec[0] = rgb_to_bw(cin);
}
void register_node_type_tex_rgbtobw(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, rgbtobw_in, rgbtobw_out);
node_type_exec(&ntype, NULL, NULL, rgbtobw_exec);
-
+
nodeRegisterType(&ntype);
}
More information about the Bf-blender-cvs
mailing list