diff options
author | Ton Roosendaal <ton@blender.org> | 2005-11-17 23:31:18 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-11-17 23:31:18 +0300 |
commit | e700e0c4f9cac8f9172dd1dba51845dd9b795319 (patch) | |
tree | 3333bda3cec44b22cebbaebb864f8c13131d4193 /source/blender/blenkernel/intern/texture.c | |
parent | 824ed2e04100332f9c68b4a1ebed077d6cc80972 (diff) |
Fix in Colorband: the "B-Spline" interpolation didn't extend well, when a
marker wasn't on the first or last possible position. Caused by clipping.
As bonus; added Cardinal interpolation option too, which is just that
little bit different! (Cardinal goes through the controlpoints, bspline not)
Diffstat (limited to 'source/blender/blenkernel/intern/texture.c')
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 9fba11fd625..8988b301f7e 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -248,20 +248,32 @@ int do_colorband(ColorBand *coba, float in, float out[4]) out[3]= cbd1->a; } else { - if(in < cbd1->pos) { + if(in < cbd1->pos && coba->ipotype<2) { out[0]= cbd1->r; out[1]= cbd1->g; out[2]= cbd1->b; out[3]= cbd1->a; } else { - + CBData left, right; + /* we're looking for first pos > in */ for(a=0; a<coba->tot; a++, cbd1++) if(cbd1->pos > in) break; - if(a==coba->tot) cbd1--; + if(a==coba->tot) { + cbd2= cbd1-1; + right= *cbd2; + right.pos= 1.0f; + cbd1= &right; + } + else if(a==0) { + left= *cbd1; + left.pos= 0.0f; + cbd2= &left; + } + else cbd2= cbd1-1; - if(in > cbd1->pos) { + if(in > cbd1->pos && coba->ipotype<2) { out[0]= cbd1->r; out[1]= cbd1->g; out[2]= cbd1->b; @@ -269,10 +281,9 @@ int do_colorband(ColorBand *coba, float in, float out[4]) } else { - cbd2= cbd1-1; fac= (in-cbd1->pos)/(cbd2->pos-cbd1->pos); - if(coba->ipotype==2) { + if(coba->ipotype>=2) { /* ipo from right to left: 3 2 1 0 */ if(a>=coba->tot-1) cbd0= cbd1; @@ -280,7 +291,10 @@ int do_colorband(ColorBand *coba, float in, float out[4]) if(a<2) cbd3= cbd2; else cbd3= cbd2-1; - set_four_ipo(fac, t, KEY_BSPLINE); + if(coba->ipotype==3) + set_four_ipo(fac, t, KEY_CARDINAL); + else + set_four_ipo(fac, t, KEY_BSPLINE); out[0]= t[3]*cbd3->r +t[2]*cbd2->r +t[1]*cbd1->r +t[0]*cbd0->r; out[1]= t[3]*cbd3->g +t[2]*cbd2->g +t[1]*cbd1->g +t[0]*cbd0->g; |