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>2010-09-25 15:30:46 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-09-25 15:30:46 +0400
commit0d3f0ff08e2066de33165fa3153fd081fc394aaa (patch)
tree7e2a35a4d78b811c464a0df6e48a75963595f1b1 /source/blender/nodes/intern/CMP_nodes
parentd305a64b69a6181dfde1f7cc14c6b9d579140da0 (diff)
Fix #23901: displace node not working with negative values.
Diffstat (limited to 'source/blender/nodes/intern/CMP_nodes')
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_displace.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_displace.c b/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
index 7d64d4e719c..aa7fac81c2c 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
@@ -83,7 +83,7 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float
p_dy = vec[1] * ys;
/* if no displacement, then just copy this pixel */
- if (p_dx < DISPLACE_EPSILON && p_dy < DISPLACE_EPSILON) {
+ if (fabsf(p_dx) < DISPLACE_EPSILON && fabsf(p_dy) < DISPLACE_EPSILON) {
qd_getPixel(cbuf, x-cbuf->xof, y-cbuf->yof, col);
qd_setPixel(stackbuf, x, y, col);
continue;
@@ -99,10 +99,13 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float
qd_getPixel(vecbuf, x-vecbuf->xof, y-vecbuf->yof+1, vecdy);
d_dx = vecdx[0] * xs;
d_dy = vecdy[0] * ys;
-
+
/* clamp derivatives to minimum displacement distance in UV space */
- dxt = MAX2(p_dx - d_dx, DISPLACE_EPSILON)/(float)stackbuf->x;
- dyt = MAX2(p_dy - d_dy, DISPLACE_EPSILON)/(float)stackbuf->y;
+ dxt = p_dx - d_dx;
+ dyt = p_dy - d_dy;
+
+ dxt = signf(dxt)*maxf(fabsf(dxt), DISPLACE_EPSILON)/(float)stackbuf->x;
+ dyt = signf(dyt)*maxf(fabsf(dyt), DISPLACE_EPSILON)/(float)stackbuf->y;
ibuf_sample(ibuf, u, v, dxt, dyt, col);
qd_setPixel(stackbuf, x, y, col);