[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19857] trunk/blender/source/blender/nodes /intern/CMP_nodes/CMP_normalize.c: Old "divide by zero" bug and remove debug printf.
gsr b3d
gsr.b3d at infernal-iceberg.com
Tue Apr 21 19:40:39 CEST 2009
Revision: 19857
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19857
Author: gsrb3d
Date: 2009-04-21 19:40:39 +0200 (Tue, 21 Apr 2009)
Log Message:
-----------
Old "divide by zero" bug and remove debug printf.
Modified Paths:
--------------
trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c
Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c 2009-04-21 17:37:07 UTC (rev 19856)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c 2009-04-21 17:40:39 UTC (rev 19857)
@@ -55,6 +55,7 @@
}
}
+/* The code below assumes all data is inside range +- this, and that input buffer is single channel */
#define BLENDER_ZMAX 10000.0f
static void node_composit_exec_normalize(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
@@ -63,7 +64,7 @@
/* stack order out: valbuf */
if(out[0]->hasoutput==0) return;
- /* input no image? then only value operation */
+ /* Input has no image buffer? Then pass the value */
if(in[0]->data==NULL) {
QUATCOPY(out[0]->vec, in[0]->vec);
}
@@ -78,19 +79,21 @@
CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); /* allocs */
for (val = cbuf->rect; tot; tot--, val++) {
- if ((*val > max) && (*val < BLENDER_ZMAX)) {
+ if ((*val > max) && (*val <= BLENDER_ZMAX)) {
max = *val;
}
- if (*val < min) {
+ if ((*val < min) && (*val >= -BLENDER_ZMAX)) {
min = *val;
}
}
- mult = 1.0f/(max-min);
+ /* In the rare case of flat buffer, which would cause a divide by 0, just pass the input to the output */
+ if ((max-min) != 0.0f) {
+ mult = 1.0f/(max-min);
+ composit3_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, NULL, &min, NULL, &mult, do_normalize, CB_VAL, CB_VAL, CB_VAL);
+ } else {
+ memcpy(stackbuf->rect, cbuf->rect, sizeof(float) * cbuf->x * cbuf->y);
+ }
- printf("min %f max %f\n", min, max);
-
- composit3_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, NULL, &min, NULL, &mult, do_normalize, CB_VAL, CB_VAL, CB_VAL);
-
out[0]->data= stackbuf;
}
}
More information about the Bf-blender-cvs
mailing list