[Bf-blender-cvs] [e9e555f] texture_nodes_refactor: Port several more nodes to the new system
Sergey Sharybin
noreply at git.blender.org
Sat Oct 11 17:51:09 CEST 2014
Commit: e9e555fb85edd38769cda17eb1b79d50e3b15a90
Author: Sergey Sharybin
Date: Sat Oct 11 21:50:15 2014 +0600
Branches: texture_nodes_refactor
https://developer.blender.org/rBe9e555fb85edd38769cda17eb1b79d50e3b15a90
Port several more nodes to the new system
Need to switch to some other work now, maybe someone will want to play
around with the code meanwhile.
===================================================================
M source/blender/nodes/texture/nodes/node_texture_bricks.c
M source/blender/nodes/texture/nodes/node_texture_checker.c
M source/blender/nodes/texture/nodes/node_texture_common.c
M source/blender/nodes/texture/nodes/node_texture_compose.c
M source/blender/nodes/texture/nodes/node_texture_coord.c
M source/blender/nodes/texture/nodes/node_texture_curves.c
M source/blender/nodes/texture/nodes/node_texture_decompose.c
M source/blender/nodes/texture/nodes/node_texture_distance.c
M source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
M source/blender/nodes/texture/nodes/node_texture_image.c
M source/blender/nodes/texture/nodes/node_texture_invert.c
M source/blender/nodes/texture/nodes/node_texture_viewer.c
===================================================================
diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c
index 25cb7c6..91ca1f2 100644
--- a/source/blender/nodes/texture/nodes/node_texture_bricks.c
+++ b/source/blender/nodes/texture/nodes/node_texture_bricks.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
@@ -64,72 +64,75 @@ static float noise(int n) /* fast integer noise */
return 0.5f * ((float)nn / 1073741824.0f);
}
-static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short UNUSED(thread))
+static void exec(void *data,
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **out)
{
- const float *co = p->co;
-
+ TexCallData *cdata = (TexCallData *)data;
+ const float *co = cdata->co;
+
float x = co[0];
float y = co[1];
-
+
int bricknum, rownum;
float offset = 0;
float ins_x, ins_y;
float tint;
-
+
float bricks1[4];
float bricks2[4];
float mortar[4];
-
+
float mortar_thickness = tex_input_value(in[3]);
float bias = tex_input_value(in[4]);
float brick_width = tex_input_value(in[5]);
float row_height = tex_input_value(in[6]);
-
+
tex_input_rgba(bricks1, in[0]);
tex_input_rgba(bricks2, in[1]);
tex_input_rgba(mortar, in[2]);
-
- rownum = (int)floor(y / row_height);
-
+
+ rownum = (int)floorf(y / row_height);
+
if (node->custom1 && node->custom2) {
brick_width *= ((int)(rownum) % node->custom2) ? 1.0f : node->custom4; /* squash */
offset = ((int)(rownum) % node->custom1) ? 0 : (brick_width * node->custom3); /* offset */
}
-
- bricknum = (int)floor((x + offset) / brick_width);
-
+
+ bricknum = (int)floorf((x + offset) / brick_width);
+
ins_x = (x + offset) - brick_width * bricknum;
ins_y = y - row_height * rownum;
-
+
tint = noise((rownum << 16) + (bricknum & 0xFFFF)) + bias;
CLAMP(tint, 0.0f, 1.0f);
-
+
if (ins_x < mortar_thickness || ins_y < mortar_thickness ||
ins_x > (brick_width - mortar_thickness) ||
ins_y > (row_height - mortar_thickness))
{
- copy_v4_v4(out, mortar);
+ copy_v4_v4(out[0]->vec, mortar);
}
else {
- copy_v4_v4(out, bricks1);
- ramp_blend(MA_RAMP_BLEND, out, tint, bricks2);
+ copy_v4_v4(out[0]->vec, bricks1);
+ ramp_blend(MA_RAMP_BLEND, out[0]->vec, tint, bricks2);
}
-}
-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_bricks(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_BRICKS, "Bricks", NODE_CLASS_PATTERN, NODE_PREVIEW);
node_type_socket_templates(&ntype, inputs, outputs);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, init);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_checker.c b/source/blender/nodes/texture/nodes/node_texture_checker.c
index e57bd63..c37bafc 100644
--- a/source/blender/nodes/texture/nodes/node_texture_checker.c
+++ b/source/blender/nodes/texture/nodes/node_texture_checker.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
@@ -53,15 +53,12 @@ static void exec(void *data,
bNodeStack **out)
{
TexCallData *cdata = (TexCallData *)data;
- TexParams p;
float x, y, z, sz;
int xi, yi, zi;
- params_from_cdata(&p, cdata);
-
- x = p.co[0];
- y = p.co[1];
- z = p.co[2];
+ x = cdata->co[0];
+ y = cdata->co[1];
+ z = cdata->co[2];
sz = tex_input_value(in[2]);
/* 0.00001 because of unit sized stuff */
@@ -76,16 +73,16 @@ static void exec(void *data,
tex_input_rgba(out[0]->vec, in[1]);
}
- tex_do_preview(execdata->preview, p.co, out[0]->vec, cdata->do_manage);
+ tex_do_preview(execdata->preview, cdata->co, out[0]->vec, cdata->do_manage);
}
void register_node_type_tex_checker(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_CHECKER, "Checker", NODE_CLASS_PATTERN, 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_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c
index 914f1ef..e278057 100644
--- a/source/blender/nodes/texture/nodes/node_texture_common.c
+++ b/source/blender/nodes/texture/nodes/node_texture_common.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
diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c
index 495377b..2ce9090 100644
--- a/source/blender/nodes/texture/nodes/node_texture_compose.c
+++ b/source/blender/nodes/texture/nodes/node_texture_compose.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
@@ -30,7 +30,7 @@
*/
-#include "node_texture_util.h"
+#include "node_texture_util.h"
#include "NOD_texture.h"
static bNodeSocketTemplate inputs[] = {
@@ -45,25 +45,26 @@ static bNodeSocketTemplate outputs[] = {
{ -1, 0, "" }
};
-static void colorfn(float *out, TexParams *UNUSED(p), bNode *UNUSED(node), bNodeStack **in, short UNUSED(thread))
+static void exec(void *UNUSED(data),
+ int UNUSED(thread),
+ bNode *UNUSED(node),
+ bNodeExecData *UNUSED(execdata),
+ bNodeStack **in,
+ bNodeStack **out)
{
int i;
- for (i = 0; i < 4; i++)
- out[i] = tex_input_value(in[i]);
-}
-
-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);
+ for (i = 0; i < 4; i++) {
+ out[0]->vec[i] = tex_input_value(in[i]);
+ }
}
void register_node_type_tex_compose(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_COMPOSE, "Combine RGBA", NODE_CLASS_OP_COLOR, 0);
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_coord.c b/source/blender/nodes/texture/nodes/node_texture_coord.c
index 5221d45..2f86c13 100644
--- a/source/blender/nodes/texture/nodes/node_texture_coord.c
+++ b/source/blender/nodes/texture/nodes/node_texture_coord.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
@@ -38,24 +38,25 @@ static bNodeSocketTemplate outputs[] = {
{ -1, 0, "" }
};
-static void vectorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **UNUSED(in), short UNUSED(thread))
+static void exec(void *data,
+ int UNUSED(thread),
+ bNode *UNUSED(node),
+ bNodeExecData *UNUSED(execdata),
+ bNodeStack **UNUSED(in),
+ bNodeStack **out)
{
- copy_v3_v3(out, p->co);
-}
-
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
-{
- tex_output(node, execdata, in, out[0], &vectorfn, data);
+ TexCallData *cdata = (TexCallData *)data;
+ copy_v3_v3(out[0]->vec, cdata->co);
}
void register_node_type_tex_coord(void)
{
static bNodeType ntype;
-
+
tex_node_type_base(&ntype, TEX_NODE_COORD, "Coordinates", NODE_CLASS_INPUT, 0);
node_type_socket_templates(&ntype, NULL, outputs);
node_type_storage(&ntype, "", NULL, NULL);
node_type_exec(&ntype, NULL, NULL, exec);
-
+
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c
index 06ec5c0..af82b78 100644
--- a/source/blender/nodes/texture/nodes/node_texture_curves.c
+++ b/source/blender/nodes/texture/nodes/node_texture_curves.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
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list