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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-10-07 18:48:29 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-10-07 18:48:29 +0400
commitcf4f00b2fa6dfecc400519a635c41798bf45ca88 (patch)
tree342967b2b2a1254a23aca3c8e0ae22a7009e86f2 /source/blender/nodes
parent17c083a38f3a5269a3224b632f0bc129d831dc5d (diff)
Preview Render:
* Fixes for texture and material nodes. * Texture node previews now work more like materials.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_at.c2
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_bricks.c4
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_checker.c4
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_compose.c2
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_coord.c4
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_curves.c4
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_decompose.c8
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_distance.c4
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c2
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_image.c4
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_invert.c4
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_math.c4
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c4
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_output.c44
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_proc.c5
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_rotate.c2
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_scale.c2
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_texture.c4
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_translate.c2
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c4
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c6
-rw-r--r--source/blender/nodes/intern/TEX_nodes/TEX_viewer.c11
-rw-r--r--source/blender/nodes/intern/TEX_util.c75
-rw-r--r--source/blender/nodes/intern/TEX_util.h5
24 files changed, 77 insertions, 133 deletions
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_at.c b/source/blender/nodes/intern/TEX_nodes/TEX_at.c
index 4d714d91130..7e6cce9f35a 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_at.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_at.c
@@ -50,7 +50,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &colorfn);
+ tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_at = {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c
index f1f3b0919ae..2093679e39d 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c
@@ -109,9 +109,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &colorfn);
-
- tex_do_preview(node, out[0], data);
+ tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_bricks= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c
index b889f1e2164..7b736206c51 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c
@@ -61,9 +61,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &colorfn);
-
- tex_do_preview(node, out[0], data);
+ tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_checker= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c
index 9fc4b2ff7c2..dac6ca7c3ef 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c
@@ -49,7 +49,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &colorfn);
+ tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_compose= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c
index e5c2b309fb3..a33a2608af0 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c
@@ -42,9 +42,7 @@ static void vectorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, sho
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &vectorfn);
-
- tex_do_preview(node, out[0], data);
+ tex_output(node, in, out[0], &vectorfn, data);
}
bNodeType tex_node_coord= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c
index 61ebcea7360..a1b20370687 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c
@@ -50,7 +50,7 @@ static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in,
static void time_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &time_colorfn);
+ tex_output(node, in, out[0], &time_colorfn, data);
}
@@ -100,7 +100,7 @@ static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in,
static void rgb_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &rgb_colorfn);
+ tex_output(node, in, out[0], &rgb_colorfn, data);
}
static void rgb_init(bNode *node)
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c
index f7a409f0230..d5eeba2253c 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c
@@ -67,10 +67,10 @@ static void valuefn_a(float *out, TexParams *p, bNode *node, bNodeStack **in, sh
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &valuefn_r);
- tex_output(node, in, out[1], &valuefn_g);
- tex_output(node, in, out[2], &valuefn_b);
- tex_output(node, in, out[3], &valuefn_a);
+ tex_output(node, in, out[0], &valuefn_r, data);
+ tex_output(node, in, out[1], &valuefn_g, data);
+ tex_output(node, in, out[2], &valuefn_b, data);
+ tex_output(node, in, out[3], &valuefn_a, data);
}
bNodeType tex_node_decompose= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c
index 4e145e26b72..297fc02939d 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c
@@ -53,9 +53,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &valuefn);
-
- tex_do_preview(node, out[0], data);
+ tex_output(node, in, out[0], &valuefn, data);
}
bNodeType tex_node_distance= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c
index 192c7a39ee8..b267dc7acbb 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c
@@ -84,7 +84,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &colorfn);
+ tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_hue_sat= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_image.c b/source/blender/nodes/intern/TEX_nodes/TEX_image.c
index 0a55af70b52..123063a7900 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_image.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_image.c
@@ -73,9 +73,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &colorfn);
-
- tex_do_preview(node, out[0], data);
+ tex_output(node, in, out[0], &colorfn, data);
}
static void init(bNode* node)
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c
index 5663f897ff5..f2fcbfbf9eb 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c
@@ -55,9 +55,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &colorfn);
-
- tex_do_preview(node, out[0], data);
+ tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_invert= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_math.c b/source/blender/nodes/intern/TEX_nodes/TEX_math.c
index 4ee04140fca..8c400a44832 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_math.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_math.c
@@ -171,9 +171,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &valuefn);
-
- tex_do_preview(node, out[0], data);
+ tex_output(node, in, out[0], &valuefn, data);
}
bNodeType tex_node_math= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c
index 24bdde70127..f6955b47376 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c
@@ -57,9 +57,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &colorfn);
-
- tex_do_preview(node, out[0], data);
+ tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_mix_rgb= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_output.c b/source/blender/nodes/intern/TEX_nodes/TEX_output.c
index 7ce5ec88c48..140c31a7986 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_output.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_output.c
@@ -83,28 +83,30 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
TexCallData *cdata = (TexCallData *)data;
TexResult *target = cdata->target;
- if(in[1]->hasinput && !in[0]->hasinput)
- tex_do_preview(node, in[1], data);
- else
- tex_do_preview(node, in[0], data);
-
- if(!cdata->do_preview) {
- if(cdata->which_output == node->custom1)
- {
- TexParams params;
- params_from_cdata(&params, cdata);
-
- osa(tex_input_rgba, &target->tr, in[0], &params, cdata->thread);
-
- target->tin = (target->tr + target->tg + target->tb) / 3.0f;
- target->talpha = 1.0f;
+ if(cdata->do_preview) {
+ TexParams params;
+ params_from_cdata(&params, cdata);
+
+ if(in[1]->hasinput && !in[0]->hasinput)
+ tex_input_rgba(&target->tr, in[1], &params, cdata->thread);
+ else
+ tex_input_rgba(&target->tr, in[0], &params, cdata->thread);
+ tex_do_preview(node, params.coord, &target->tr);
+ }
+ else if(cdata->which_output == node->custom1) {
+ TexParams params;
+ params_from_cdata(&params, cdata);
- if(target->nor) {
- if(in[1]->hasinput)
- osa(tex_input_vec, target->nor, in[1], &params, cdata->thread);
- else
- target->nor = 0;
- }
+ osa(tex_input_rgba, &target->tr, in[0], &params, cdata->thread);
+
+ target->tin = (target->tr + target->tg + target->tb) / 3.0f;
+ target->talpha = 1.0f;
+
+ if(target->nor) {
+ if(in[1]->hasinput)
+ osa(tex_input_vec, target->nor, in[1], &params, cdata->thread);
+ else
+ target->nor = 0;
}
}
}
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c
index ce7324e2085..9f355e6d8f0 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c
@@ -125,9 +125,8 @@ static int count_outputs(bNode *node)
static void name##_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) \
{ \
int outs = count_outputs(node); \
- if(outs >= 1) tex_output(node, in, out[0], &name##_colorfn); \
- if(outs >= 2) tex_output(node, in, out[1], &name##_normalfn); \
- if(outs >= 1) tex_do_preview(node, out[0], data); \
+ if(outs >= 1) tex_output(node, in, out[0], &name##_colorfn, data); \
+ if(outs >= 2) tex_output(node, in, out[1], &name##_normalfn, data); \
}
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c
index bdf5a1ce079..2184d32fcf2 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c
@@ -95,7 +95,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &colorfn);
+ tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_rotate= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_scale.c b/source/blender/nodes/intern/TEX_nodes/TEX_scale.c
index 3d4415365aa..205549c97d9 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_scale.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_scale.c
@@ -56,7 +56,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &colorfn);
+ tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_scale = {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c
index 0ca80a82271..d0536a8fda8 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c
@@ -79,9 +79,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &colorfn);
-
- tex_do_preview(node, out[0], data);
+ tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_texture= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c
index ba3dcfa27a2..c2f7377da3b 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c
@@ -56,7 +56,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &colorfn);
+ tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_translate = {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c
index 75b88c3a460..6b8349e90af 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c
@@ -72,9 +72,7 @@ static void normalfn(float *out, TexParams *p, bNode *node, bNodeStack **in, sho
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &normalfn);
-
- tex_do_preview(node, out[0], data);
+ tex_output(node, in, out[0], &normalfn, data);
}
bNodeType tex_node_valtonor = {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c
index 90a444bcff0..669f45ec89a 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c
@@ -50,7 +50,7 @@ static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack *
static void valtorgb_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &valtorgb_colorfn);
+ tex_output(node, in, out[0], &valtorgb_colorfn, data);
}
static void valtorgb_init(bNode *node)
@@ -97,9 +97,7 @@ static void rgbtobw_valuefn(float *out, TexParams *p, bNode *node, bNodeStack **
static void rgbtobw_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_output(node, in, out[0], &rgbtobw_valuefn);
-
- tex_do_preview(node, out[0], data);
+ tex_output(node, in, out[0], &rgbtobw_valuefn, data);
}
bNodeType tex_node_rgbtobw= {
diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c
index 2d29b03b38c..5ebd971d9fb 100644
--- a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c
+++ b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c
@@ -39,7 +39,16 @@ static bNodeSocketType outputs[]= {
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- tex_do_preview(node, in[0], data);
+ TexCallData *cdata = (TexCallData *)data;
+
+ if(cdata->do_preview) {
+ TexParams params;
+ float col[4];
+ params_from_cdata(&params, cdata);
+
+ tex_input_rgba(col, in[0], &params, cdata->thread);
+ tex_do_preview(node, params.coord, col);
+ }
}
bNodeType tex_node_viewer = {
diff --git a/source/blender/nodes/intern/TEX_util.c b/source/blender/nodes/intern/TEX_util.c
index f2333ffcf2e..867bbd8c14e 100644
--- a/source/blender/nodes/intern/TEX_util.c
+++ b/source/blender/nodes/intern/TEX_util.c
@@ -49,8 +49,12 @@
void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, short thread)
{
- if(dg->node->need_exec)
+ if(dg->node->need_exec) {
dg->fn(out, params, dg->node, dg->in, thread);
+
+ if(dg->cdata->do_preview)
+ tex_do_preview(dg->node, params->coord, out);
+ }
}
void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, short thread)
@@ -95,26 +99,6 @@ float tex_input_value(bNodeStack *in, TexParams *params, short thread)
return out[0];
}
-static void init_preview(bNode *node)
-{
- int xsize = (int)(node->prvr.xmax - node->prvr.xmin);
- int ysize = (int)(node->prvr.ymax - node->prvr.ymin);
-
- if(xsize == 0) {
- xsize = PREV_RES;
- ysize = PREV_RES;
- }
-
- if(node->preview==NULL)
- node->preview= MEM_callocN(sizeof(bNodePreview), "node preview");
-
- if(node->preview->rect==NULL) {
- node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(float)*4, "node preview rect");
- node->preview->xsize= xsize;
- node->preview->ysize= ysize;
- }
-}
-
void params_from_cdata(TexParams *out, TexCallData *in)
{
out->coord = in->coord;
@@ -123,48 +107,19 @@ void params_from_cdata(TexParams *out, TexCallData *in)
out->cfra = in->cfra;
}
-void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata)
+void tex_do_preview(bNode *node, float *coord, float *col)
{
- int x, y;
- float *result;
- bNodePreview *preview;
- float coord[3] = {0, 0, 0};
- TexParams params;
- int resolution;
- int xsize, ysize;
-
- if(!cdata->do_preview)
- return;
-
- if(!(node->typeinfo->flag & NODE_PREVIEW))
- return;
-
- init_preview(node);
-
- preview = node->preview;
- xsize = preview->xsize;
- ysize = preview->ysize;
-
- params.dxt = 0;
- params.dyt = 0;
- params.cfra = cdata->cfra;
- params.coord = coord;
-
- resolution = (xsize < ysize) ? xsize : ysize;
-
- for(x=0; x<xsize; x++)
- for(y=0; y<ysize; y++)
- {
- params.coord[0] = ((float) x / resolution) * 2 - 1;
- params.coord[1] = ((float) y / resolution) * 2 - 1;
-
- result = preview->rect + 4 * (xsize*y + x);
-
- tex_input_rgba(result, ns, &params, cdata->thread);
+ bNodePreview *preview= node->preview;
+
+ if(preview) {
+ int xs= ((coord[0] + 1.0f)*0.5f)*preview->xsize;
+ int ys= ((coord[1] + 1.0f)*0.5f)*preview->ysize;
+
+ nodeAddToPreview(node, col, xs, ys);
}
}
-void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn)
+void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
{
TexDelegate *dg;
if(!out->data)
@@ -173,7 +128,7 @@ void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn)
else
dg = out->data;
-
+ dg->cdata= cdata;
dg->fn = texfn;
dg->node = node;
memcpy(dg->in, in, MAX_SOCKET * sizeof(bNodeStack*));
diff --git a/source/blender/nodes/intern/TEX_util.h b/source/blender/nodes/intern/TEX_util.h
index fd3d47f4729..14e2773414a 100644
--- a/source/blender/nodes/intern/TEX_util.h
+++ b/source/blender/nodes/intern/TEX_util.h
@@ -87,6 +87,7 @@ typedef struct TexParams {
typedef void(*TexFn) (float *out, TexParams *params, bNode *node, bNodeStack **in, short thread);
typedef struct TexDelegate {
+ TexCallData *cdata;
TexFn fn;
bNode *node;
bNodeStack *in[MAX_SOCKET];
@@ -99,8 +100,8 @@ void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread);
float tex_input_value(bNodeStack *in, TexParams *params, short thread);
-void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn);
-void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata);
+void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *data);
+void tex_do_preview(bNode *node, float *coord, float *col);
void params_from_cdata(TexParams *out, TexCallData *in);