minor edit - weight_to_rgb() and ramp_blend() now take a float vector rather than...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 26 Nov 2011 03:13:54 +0000 (03:13 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 26 Nov 2011 03:13:54 +0000 (03:13 +0000)
also make particle draw use a float vec.

18 files changed:
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_material.h
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/particle.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/nodes/composite/nodes/node_composite_mixrgb.c
source/blender/nodes/shader/nodes/node_shader_mixRgb.c
source/blender/nodes/texture/nodes/node_texture_bricks.c
source/blender/nodes/texture/nodes/node_texture_mixRgb.c
source/blender/nodes/texture/nodes/node_texture_proc.c
source/blender/nodes/texture/nodes/node_texture_texture.c
source/blender/render/intern/source/pixelshading.c
source/blender/render/intern/source/render_texture.c
source/blender/render/intern/source/shadeoutput.c

index 15fdc2f..84f1bf7 100644 (file)
@@ -526,7 +526,7 @@ int editmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct E
 int sculpt_get_deform_matrices(struct Scene *scene, struct Object *ob,
                                                                float (**deformmats)[3][3], float (**deformcos)[3]);
 
-void weight_to_rgb(float input, float *fr, float *fg, float *fb);
+void weight_to_rgb(float r_rgb[3], const float weight);
 
 /* convert layers requested by a GLSL material to actually available layers in
  * the DerivedMesh, with both a pointer for arrays and an offset for editmesh */
index 8e7645d..316bc2d 100644 (file)
@@ -91,7 +91,7 @@ void end_render_materials(struct Main *);
 
 int material_in_material(struct Material *parmat, struct Material *mat);
 
-void ramp_blend(int type, float *r, float *g, float *b, float fac, const float col[3]);
+void ramp_blend(int type, float r_col[3], const float fac, const float col[3]);
 
 /* copy/paste */
 void clear_matcopybuf(void);
index c66e49f..f491761 100644 (file)
@@ -217,7 +217,7 @@ typedef struct ParticleDrawData {
        float *ndata, *nd;              /* normal data */
        float *cdata, *cd;              /* color data */
        float *vedata, *ved;    /* velocity data */
-       float *ma_r, *ma_g, *ma_b;
+       float *ma_col;
        int tot_vec_size, flag;
        int totpoint, totve;
 } ParticleDrawData;
index d03e01f..4e26078 100644 (file)
@@ -1775,31 +1775,29 @@ static void add_orco_dm(Object *ob, EditMesh *em, DerivedMesh *dm, DerivedMesh *
  * happens on enter/exit wpaint.
  */
 
-void weight_to_rgb(float input, float *fr, float *fg, float *fb)
+void weight_to_rgb(float r_rgb[3], const float weight)
 {
-       float blend;
-       
-       blend= ((input/2.0f)+0.5f);
-       
-       if (input<=0.25f){      // blue->cyan
-               *fr= 0.0f;
-               *fg= blend*input*4.0f;
-               *fb= blend;
+       const float blend= ((weight/2.0f)+0.5f);
+
+       if (weight<=0.25f){     // blue->cyan
+               r_rgb[0]= 0.0f;
+               r_rgb[1]= blend*weight*4.0f;
+               r_rgb[2]= blend;
        }
-       else if (input<=0.50f){ // cyan->green
-               *fr= 0.0f;
-               *fg= blend;
-               *fb= blend*(1.0f-((input-0.25f)*4.0f)); 
+       else if (weight<=0.50f){        // cyan->green
+               r_rgb[0]= 0.0f;
+               r_rgb[1]= blend;
+               r_rgb[2]= blend*(1.0f-((weight-0.25f)*4.0f));
        }
-       else if (input <= 0.75f){       // green->yellow
-               *fr= blend * ((input-0.50f)*4.0f);
-               *fg= blend;
-               *fb= 0.0f;
+       else if (weight <= 0.75f){      // green->yellow
+               r_rgb[0]= blend * ((weight-0.50f)*4.0f);
+               r_rgb[1]= blend;
+               r_rgb[2]= 0.0f;
        }
-       else if (input <= 1.0f){ // yellow->red
-               *fr= blend;
-               *fg= blend * (1.0f-((input-0.75f)*4.0f)); 
-               *fb= 0.0f;
+       else if (weight <= 1.0f){ // yellow->red
+               r_rgb[0]= blend;
+               r_rgb[1]= blend * (1.0f-((weight-0.75f)*4.0f));
+               r_rgb[2]= 0.0f;
        }
 }
 
@@ -1864,7 +1862,7 @@ static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, u
        if(coba)
                do_colorband(coba, input, colf);
        else
-               weight_to_rgb(input, colf, colf+1, colf+2);
+               weight_to_rgb(colf, input);
        
        col[3] = (unsigned char)(colf[0] * 255.0f);
        col[2] = (unsigned char)(colf[1] * 255.0f);
index b5b345c..519ac1c 100644 (file)
@@ -1681,7 +1681,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                                        for (; j<((mface[i].v4)?4:3); j++) {
                                                                                int index = (j==0)?mface[i].v1: (j==1)?mface[i].v2: (j==2)?mface[i].v3: mface[i].v4;
 
-                                                                               weight_to_rgb(weight[index], temp_color, temp_color+1, temp_color+2);
+                                                                               weight_to_rgb(temp_color, weight[index]);
                                                                                col[i*4+j].r = FTOCHAR(temp_color[2]);
                                                                                col[i*4+j].g = FTOCHAR(temp_color[1]);
                                                                                col[i*4+j].b = FTOCHAR(temp_color[0]);
index 48c6d6b..fa0e886 100644 (file)
@@ -1180,129 +1180,129 @@ int object_remove_material_slot(Object *ob)
 
 /* r g b = current value, col = new value, fac==0 is no change */
 /* if g==NULL, it only does r channel */
-void ramp_blend(int type, float *r, float *g, float *b, float fac, const float col[3])
+void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
 {
        float tmp, facm= 1.0f-fac;
        
        switch (type) {
                case MA_RAMP_BLEND:
-                       *r = facm*(*r) + fac*col[0];
-                       if(g) {
-                               *g = facm*(*g) + fac*col[1];
-                               *b = facm*(*b) + fac*col[2];
+                       r_col[0] = facm*(r_col[0]) + fac*col[0];
+                       if(r_col[1]) {
+                               r_col[1] = facm*(r_col[1]) + fac*col[1];
+                               r_col[2] = facm*(r_col[2]) + fac*col[2];
                        }
                                break;
                case MA_RAMP_ADD:
-                       *r += fac*col[0];
-                       if(g) {
-                               *g += fac*col[1];
-                               *b += fac*col[2];
+                       r_col[0] += fac*col[0];
+                       if(r_col[1]) {
+                               r_col[1] += fac*col[1];
+                               r_col[2] += fac*col[2];
                        }
                                break;
                case MA_RAMP_MULT:
-                       *r *= (facm + fac*col[0]);
-                       if(g) {
-                               *g *= (facm + fac*col[1]);
-                               *b *= (facm + fac*col[2]);
+                       r_col[0] *= (facm + fac*col[0]);
+                       if(r_col[1]) {
+                               r_col[1] *= (facm + fac*col[1]);
+                               r_col[2] *= (facm + fac*col[2]);
                        }
                                break;
                case MA_RAMP_SCREEN:
-                       *r = 1.0f - (facm + fac*(1.0f - col[0])) * (1.0f - *r);
-                       if(g) {
-                               *g = 1.0f - (facm + fac*(1.0f - col[1])) * (1.0f - *g);
-                               *b = 1.0f - (facm + fac*(1.0f - col[2])) * (1.0f - *b);
+                       r_col[0] = 1.0f - (facm + fac*(1.0f - col[0])) * (1.0f - r_col[0]);
+                       if(r_col[1]) {
+                               r_col[1] = 1.0f - (facm + fac*(1.0f - col[1])) * (1.0f - r_col[1]);
+                               r_col[2] = 1.0f - (facm + fac*(1.0f - col[2])) * (1.0f - r_col[2]);
                        }
                                break;
                case MA_RAMP_OVERLAY:
-                       if(*r < 0.5f)
-                               *r *= (facm + 2.0f*fac*col[0]);
+                       if(r_col[0] < 0.5f)
+                               r_col[0] *= (facm + 2.0f*fac*col[0]);
                        else
-                               *r = 1.0f - (facm + 2.0f*fac*(1.0f - col[0])) * (1.0f - *r);
-                       if(g) {
-                               if(*g < 0.5f)
-                                       *g *= (facm + 2.0f*fac*col[1]);
+                               r_col[0] = 1.0f - (facm + 2.0f*fac*(1.0f - col[0])) * (1.0f - r_col[0]);
+                       if(r_col[1]) {
+                               if(r_col[1] < 0.5f)
+                                       r_col[1] *= (facm + 2.0f*fac*col[1]);
                                else
-                                       *g = 1.0f - (facm + 2.0f*fac*(1.0f - col[1])) * (1.0f - *g);
-                               if(*b < 0.5f)
-                                       *b *= (facm + 2.0f*fac*col[2]);
+                                       r_col[1] = 1.0f - (facm + 2.0f*fac*(1.0f - col[1])) * (1.0f - r_col[1]);
+                               if(r_col[2] < 0.5f)
+                                       r_col[2] *= (facm + 2.0f*fac*col[2]);
                                else
-                                       *b = 1.0f - (facm + 2.0f*fac*(1.0f - col[2])) * (1.0f - *b);
+                                       r_col[2] = 1.0f - (facm + 2.0f*fac*(1.0f - col[2])) * (1.0f - r_col[2]);
                        }
                                break;
                case MA_RAMP_SUB:
-                       *r -= fac*col[0];
-                       if(g) {
-                               *g -= fac*col[1];
-                               *b -= fac*col[2];
+                       r_col[0] -= fac*col[0];
+                       if(r_col[1]) {
+                               r_col[1] -= fac*col[1];
+                               r_col[2] -= fac*col[2];
                        }
                                break;
                case MA_RAMP_DIV:
                        if(col[0]!=0.0f)
-                               *r = facm*(*r) + fac*(*r)/col[0];
-                       if(g) {
+                               r_col[0] = facm*(r_col[0]) + fac*(r_col[0])/col[0];
+                       if(r_col[1]) {
                                if(col[1]!=0.0f)
-                                       *g = facm*(*g) + fac*(*g)/col[1];
+                                       r_col[1] = facm*(r_col[1]) + fac*(r_col[1])/col[1];
                                if(col[2]!=0.0f)
-                                       *b = facm*(*b) + fac*(*b)/col[2];
+                                       r_col[2] = facm*(r_col[2]) + fac*(r_col[2])/col[2];
                        }
                                break;
                case MA_RAMP_DIFF:
-                       *r = facm*(*r) + fac*fabsf(*r-col[0]);
-                       if(g) {
-                               *g = facm*(*g) + fac*fabsf(*g-col[1]);
-                               *b = facm*(*b) + fac*fabsf(*b-col[2]);
+                       r_col[0] = facm*(r_col[0]) + fac*fabsf(r_col[0]-col[0]);
+                       if(r_col[1]) {
+                               r_col[1] = facm*(r_col[1]) + fac*fabsf(r_col[1]-col[1]);
+                               r_col[2] = facm*(r_col[2]) + fac*fabsf(r_col[2]-col[2]);
                        }
                                break;
                case MA_RAMP_DARK:
                        tmp=col[0]+((1-col[0])*facm); 
-                       if(tmp < *r) *r= tmp; 
-                       if(g) { 
+                       if(tmp < r_col[0]) r_col[0]= tmp;
+                       if(r_col[1]) {
                                tmp=col[1]+((1-col[1])*facm); 
-                               if(tmp < *g) *g= tmp; 
+                               if(tmp < r_col[1]) r_col[1]= tmp;
                                tmp=col[2]+((1-col[2])*facm); 
-                               if(tmp < *b) *b= tmp; 
+                               if(tmp < r_col[2]) r_col[2]= tmp;
                        } 
                                break; 
                case MA_RAMP_LIGHT:
                        tmp= fac*col[0];
-                       if(tmp > *r) *r= tmp; 
-                               if(g) {
+                       if(tmp > r_col[0]) r_col[0]= tmp;
+                               if(r_col[1]) {
                                        tmp= fac*col[1];
-                                       if(tmp > *g) *g= tmp; 
+                                       if(tmp > r_col[1]) r_col[1]= tmp;
                                        tmp= fac*col[2];
-                                       if(tmp > *b) *b= tmp; 
+                                       if(tmp > r_col[2]) r_col[2]= tmp;
                                }
                                        break;  
                case MA_RAMP_DODGE:                     
                        
                                
-                       if(*r !=0.0f){
+                       if(r_col[0] !=0.0f){
                                tmp = 1.0f - fac*col[0];
                                if(tmp <= 0.0f)
-                                       *r = 1.0f;
-                               else if ((tmp = (*r) / tmp)> 1.0f)
-                                       *r = 1.0f;
+                                       r_col[0] = 1.0f;
+                               else if ((tmp = (r_col[0]) / tmp)> 1.0f)
+                                       r_col[0] = 1.0f;
                                else 
-                                       *r = tmp;
+                                       r_col[0] = tmp;
                        }
-                       if(g) {
-                               if(*g !=0.0f){
+                       if(r_col[1]) {
+                               if(r_col[1] !=0.0f){
                                        tmp = 1.0f - fac*col[1];
                                        if(tmp <= 0.0f )
-                                               *g = 1.0f;
-                                       else if ((tmp = (*g) / tmp) > 1.0f )
-                                               *g = 1.0f;
+                                               r_col[1] = 1.0f;
+                                       else if ((tmp = (r_col[1]) / tmp) > 1.0f )
+                                               r_col[1] = 1.0f;
                                        else
-                                               *g = tmp;
+                                               r_col[1] = tmp;
                                }
-                               if(*b !=0.0f){
+                               if(r_col[2] !=0.0f){
                                        tmp = 1.0f - fac*col[2];
                                        if(tmp <= 0.0f)
-                                               *b = 1.0f;
-                                       else if ((tmp = (*b) / tmp) > 1.0f )
-                                               *b = 1.0f;
+                                               r_col[2] = 1.0f;
+                                       else if ((tmp = (r_col[2]) / tmp) > 1.0f )
+                                               r_col[2] = 1.0f;
                                        else
-                                               *b = tmp;
+                                               r_col[2] = tmp;
                                }
 
                        }
@@ -1312,114 +1312,114 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, const float c
                        tmp = facm + fac*col[0];
                        
                        if(tmp <= 0.0f)
-                               *r = 0.0f;
-                       else if (( tmp = (1.0f - (1.0f - (*r)) / tmp )) < 0.0f)
-                                       *r = 0.0f;
+                               r_col[0] = 0.0f;
+                       else if (( tmp = (1.0f - (1.0f - (r_col[0])) / tmp )) < 0.0f)
+                                       r_col[0] = 0.0f;
                        else if (tmp > 1.0f)
-                               *r=1.0f;
+                               r_col[0]=1.0f;
                        else 
-                               *r = tmp; 
+                               r_col[0] = tmp;
 
-                       if(g) {
+                       if(r_col[1]) {
                                tmp = facm + fac*col[1];
                                if(tmp <= 0.0f)
-                                       *g = 0.0f;
-                               else if (( tmp = (1.0f - (1.0f - (*g)) / tmp )) < 0.0f )
-                                               *g = 0.0f;
+                                       r_col[1] = 0.0f;
+                               else if (( tmp = (1.0f - (1.0f - (r_col[1])) / tmp )) < 0.0f )
+                                               r_col[1] = 0.0f;
                                else if(tmp >1.0f)
-                                       *g=1.0f;
+                                       r_col[1]=1.0f;
                                else
-                                       *g = tmp;
+                                       r_col[1] = tmp;
 
                                        tmp = facm + fac*col[2];
                                        if(tmp <= 0.0f)
-                                       *b = 0.0f;
-                               else if (( tmp = (1.0f - (1.0f - (*b)) / tmp )) < 0.0f  )
-                                               *b = 0.0f;
+                                       r_col[2] = 0.0f;
+                               else if (( tmp = (1.0f - (1.0f - (r_col[2])) / tmp )) < 0.0f  )
+                                               r_col[2] = 0.0f;
                                else if(tmp >1.0f)
-                                       *b= 1.0f;
+                                       r_col[2]= 1.0f;
                                else
-                                       *b = tmp;
+                                       r_col[2] = tmp;
                        }
                                break;
                case MA_RAMP_HUE:               
-                       if(g){
+                       if(r_col[1]){
                                float rH,rS,rV;
                                float colH,colS,colV; 
                                float tmpr,tmpg,tmpb;
                                rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
                                if(colS!=0 ){
-                                       rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV);
+                                       rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV);
                                        hsv_to_rgb( colH , rS, rV, &tmpr, &tmpg, &tmpb);
-                                       *r = facm*(*r) + fac*tmpr;  
-                                       *g = facm*(*g) + fac*tmpg; 
-                                       *b = facm*(*b) + fac*tmpb;
+                                       r_col[0] = facm*(r_col[0]) + fac*tmpr;
+                                       r_col[1] = facm*(r_col[1]) + fac*tmpg;
+                                       r_col[2] = facm*(r_col[2]) + fac*tmpb;
                                }
                        }
                                break;
                case MA_RAMP_SAT:               
-                       if(g){
+                       if(r_col[1]){
                                float rH,rS,rV;
                                float colH,colS,colV;
-                               rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV);
+                               rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV);
                                if(rS!=0){
                                        rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
-                                       hsv_to_rgb( rH, (facm*rS +fac*colS), rV, r, g, b);
+                                       hsv_to_rgb( rH, (facm*rS +fac*colS), rV, r_col+0, r_col+1, r_col+2);
                                }
                        }
                                break;
                case MA_RAMP_VAL:               
-                       if(g){
+                       if(r_col[1]){
                                float rH,rS,rV;
                                float colH,colS,colV;
-                               rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV);
+                               rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV);
                                rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
-                               hsv_to_rgb( rH, rS, (facm*rV +fac*colV), r, g, b);
+                               hsv_to_rgb( rH, rS, (facm*rV +fac*colV), r_col+0, r_col+1, r_col+2);
                        }
                                break;
                case MA_RAMP_COLOR:             
-                       if(g){
+                       if(r_col[1]){
                                float rH,rS,rV;
                                float colH,colS,colV;
                                float tmpr,tmpg,tmpb;
                                rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV);
                                if(colS!=0){
-                                       rgb_to_hsv(*r,*g,*b,&rH,&rS,&rV);
+                                       rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV);
                                        hsv_to_rgb( colH, colS, rV, &tmpr, &tmpg, &tmpb);
-                                       *r = facm*(*r) + fac*tmpr;
-                                       *g = facm*(*g) + fac*tmpg;
-                                       *b = facm*(*b) + fac*tmpb;
+                                       r_col[0] = facm*(r_col[0]) + fac*tmpr;
+                                       r_col[1] = facm*(r_col[1]) + fac*tmpg;
+                                       r_col[2] = facm*(r_col[2]) + fac*tmpb;
                                }
                        }
                                break;
                case MA_RAMP_SOFT: 
-                       if (g){ 
+                       if (r_col[1]){
                                float scr, scg, scb; 
 
                                /* first calculate non-fac based Screen mix */ 
-                               scr = 1.0f - (1.0f - col[0]) * (1.0f - *r); 
-                               scg = 1.0f - (1.0f - col[1]) * (1.0f - *g); 
-                               scb = 1.0f - (1.0f - col[2]) * (1.0f - *b); 
+                               scr = 1.0f - (1.0f - col[0]) * (1.0f - r_col[0]);
+                               scg = 1.0f - (1.0f - col[1]) * (1.0f - r_col[1]);
+                               scb = 1.0f - (1.0f - col[2]) * (1.0f - r_col[2]);
 
-                               *r = facm*(*r) + fac*(((1.0f - *r) * col[0] * (*r)) + (*r * scr)); 
-                               *g = facm*(*g) + fac*(((1.0f - *g) * col[1] * (*g)) + (*g * scg)); 
-                               *b = facm*(*b) + fac*(((1.0f - *b) * col[2] * (*b)) + (*b * scb)); 
+                               r_col[0] = facm*(r_col[0]) + fac*(((1.0f - r_col[0]) * col[0] * (r_col[0])) + (r_col[0] * scr));
+                               r_col[1] = facm*(r_col[1]) + fac*(((1.0f - r_col[1]) * col[1] * (r_col[1])) + (r_col[1] * scg));
+                               r_col[2] = facm*(r_col[2]) + fac*(((1.0f - r_col[2]) * col[2] * (r_col[2])) + (r_col[2] * scb));
                        } 
                                break; 
                case MA_RAMP_LINEAR: 
                        if (col[0] > 0.5f)  
-                               *r = *r + fac*(2.0f*(col[0]-0.5f)); 
+                               r_col[0] = r_col[0] + fac*(2.0f*(col[0]-0.5f));
                        else  
-                               *r = *r + fac*(2.0f*(col[0]) - 1.0f); 
-                       if (g){ 
+                               r_col[0] = r_col[0] + fac*(2.0f*(col[0]) - 1.0f);
+                       if (r_col[1]){
                                if (col[1] > 0.5f)  
-                                       *g = *g + fac*(2.0f*(col[1]-0.5f)); 
+                                       r_col[1] = r_col[1] + fac*(2.0f*(col[1]-0.5f));
                                else  
-                                       *g = *g + fac*(2.0f*(col[1]) -1.0f); 
+                                       r_col[1] = r_col[1] + fac*(2.0f*(col[1]) -1.0f);
                                if (col[2] > 0.5f)  
-                                       *b = *b + fac*(2.0f*(col[2]-0.5f)); 
+                                       r_col[2] = r_col[2] + fac*(2.0f*(col[2]-0.5f));
                                else  
-                                       *b = *b + fac*(2.0f*(col[2]) - 1.0f); 
+                                       r_col[2] = r_col[2] + fac*(2.0f*(col[2]) - 1.0f);
                        } 
                                break; 
        }       
index 2200687..7c71df9 100644 (file)
@@ -3170,13 +3170,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
                                float t2;
 
                                if(k==0) {
-                                       weight_to_rgb(pind.hkey[1]->weight, ca->col, ca->col+1, ca->col+2);
+                                       weight_to_rgb(ca->col, pind.hkey[1]->weight);
                                } else {
                                        float w1[3], w2[3];
                                        keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time));
 
-                                       weight_to_rgb(pind.hkey[0]->weight, w1, w1+1, w1+2);
-                                       weight_to_rgb(pind.hkey[1]->weight, w2, w2+1, w2+2);
+                                       weight_to_rgb(w1, pind.hkey[0]->weight);
+                                       weight_to_rgb(w2, pind.hkey[1]->weight);
 
                                        interp_v3_v3v3(ca->col, w1, w2, keytime);
                                }
index 7b53530..1570c7e 100644 (file)
@@ -1817,7 +1817,7 @@ static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, i
                float col[3];
                MDeformWeight *mdw= defvert_find_index (lt->dvert+index, use_wcol-1);
                
-               weight_to_rgb(mdw?mdw->weight:0.0f, col, col+1, col+2);
+               weight_to_rgb(col, mdw?mdw->weight:0.0f);
                glColor3fv(col);
 
        }
@@ -3721,19 +3721,15 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
        float vec[3], vec2[3];
        float *vd = NULL;
        float *cd = NULL;
-       float ma_r=0.0f;
-       float ma_g=0.0f;
-       float ma_b=0.0f;
+       float ma_col[3]= {0.0f, 0.0f, 0.0f};
 
        /* null only for PART_DRAW_CIRC */
        if(pdd) {
                vd = pdd->vd;
                cd = pdd->cd;
 
-               if(pdd->ma_r) {
-                       ma_r = *pdd->ma_r;
-                       ma_g = *pdd->ma_g;
-                       ma_b = *pdd->ma_b;
+               if(pdd->ma_col) {
+                       copy_v3_v3(ma_col, pdd->ma_col);
                }
        }
 
@@ -3744,9 +3740,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
                                copy_v3_v3(vd,state->co); pdd->vd+=3;
                        }
                        if(cd) {
-                               cd[0]=ma_r;
-                               cd[1]=ma_g;
-                               cd[2]=ma_b;
+                               copy_v3_v3(cd, pdd->ma_col);
                                pdd->cd+=3;
                        }
                        break;
@@ -3772,9 +3766,9 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
                        }
                        else {
                                if(cd) {
-                                       cd[0]=cd[3]=cd[6]=cd[9]=cd[12]=cd[15]=ma_r;
-                                       cd[1]=cd[4]=cd[7]=cd[10]=cd[13]=cd[16]=ma_g;
-                                       cd[2]=cd[5]=cd[8]=cd[11]=cd[14]=cd[17]=ma_b;
+                                       cd[0]=cd[3]=cd[6]=cd[ 9]=cd[12]=cd[15]= ma_col[0];
+                                       cd[1]=cd[4]=cd[7]=cd[10]=cd[13]=cd[16]= ma_col[1];
+                                       cd[2]=cd[5]=cd[8]=cd[11]=cd[14]=cd[17]= ma_col[2];
                                        pdd->cd+=18;
                                }
                                sub_v3_v3v3(vec2, state->co, vec);
@@ -3819,9 +3813,9 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
                        madd_v3_v3v3fl(pdd->vd, state->co, vec, -draw_line[0]); pdd->vd+=3;
                        madd_v3_v3v3fl(pdd->vd, state->co, vec,  draw_line[1]); pdd->vd+=3;
                        if(cd) {
-                               cd[0]=cd[3]=ma_r;
-                               cd[1]=cd[4]=ma_g;
-                               cd[2]=cd[5]=ma_b;
+                               cd[0]=cd[3]= ma_col[0];
+                               cd[1]=cd[4]= ma_col[1];
+                               cd[2]=cd[5]= ma_col[2];
                                pdd->cd+=6;
                        }
                        break;
@@ -3835,9 +3829,9 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
                {
                        float xvec[3], yvec[3], zvec[3], bb_center[3];
                        if(cd) {
-                               cd[0]=cd[3]=cd[6]=cd[9]=ma_r;
-                               cd[1]=cd[4]=cd[7]=cd[10]=ma_g;
-                               cd[2]=cd[5]=cd[8]=cd[11]=ma_b;
+                               cd[0]=cd[3]=cd[6]=cd[ 9]= ma_col[0];
+                               cd[1]=cd[4]=cd[7]=cd[10]= ma_col[1];
+                               cd[2]=cd[5]=cd[8]=cd[11]= ma_col[2];
                                pdd->cd+=12;
                        }
 
@@ -3892,7 +3886,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
        float timestep, pixsize=1.0, pa_size, r_tilt, r_length;
        float pa_time, pa_birthtime, pa_dietime, pa_health, intensity;
        float cfra;
-       float ma_r=0.0f, ma_g=0.0f, ma_b=0.0f;
+       float ma_col[3]= {0.0f, 0.0f, 0.0f};
        int a, totpart, totpoint=0, totve=0, drawn, draw_as, totchild=0;
        int select=ob->flag&SELECT, create_cdata=0, need_v=0;
        GLint polygonmode[2];
@@ -3956,10 +3950,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
        if((ma) && (part->draw_col == PART_DRAW_COL_MAT)) {
                rgb_float_to_byte(&(ma->r), tcol);
-
-               ma_r = ma->r;
-               ma_g = ma->g;
-               ma_b = ma->b;
+               copy_v3_v3(ma_col, &ma->r);
        }
 
        glColor3ubv(tcol);
@@ -4125,9 +4116,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
        }
 
        if(pdd) {
-               pdd->ma_r = &ma_r;
-               pdd->ma_g = &ma_g;
-               pdd->ma_b = &ma_b;
+               pdd->ma_col= ma_col;
        }
 
        psys->lattice= psys_get_lattice(&sim);
@@ -4169,7 +4158,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                                                        intensity= 1.0f; /* should never happen */
                                        }
                                        CLAMP(intensity, 0.f, 1.f);
-                                       weight_to_rgb(intensity, &ma_r, &ma_g, &ma_b);
+                                       weight_to_rgb(ma_col, intensity);
                                }
                        }
                        else{
@@ -4430,7 +4419,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                }
 
                /* restore from select */
-               glColor3f(ma_r,ma_g,ma_b);
+               glColor3fv(ma_col);
                glPointSize(part->draw_size ? part->draw_size : 2.0);
                glLineWidth(1.0);
 
@@ -4495,7 +4484,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
        if(pdd) {
                /* drop references to stack memory */
-               pdd->ma_r= pdd->ma_g= pdd->ma_b= NULL;
+               pdd->ma_col= NULL;
        }
 
        if( (base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP) ) {
index 0f21aa3..0da3f66 100644 (file)
@@ -219,7 +219,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac
                                                else
                                                        areadiff = 1.0f-(area/uvarea);
                                                
-                                               weight_to_rgb(areadiff, col, col+1, col+2);
+                                               weight_to_rgb(col, areadiff);
                                                glColor3fv(col);
                                                
                                                glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
@@ -298,19 +298,19 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac
                                                 * 1.0-powf((1.0-a), 2) */
                                                
                                                a = fabsf(uvang1-ang1)/(float)M_PI;
-                                               weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2);
+                                               weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f));
                                                glColor3fv(col);
                                                glVertex2fv(tf->uv[0]);
                                                a = fabsf(uvang2-ang2)/(float)M_PI;
-                                               weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2);
+                                               weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f));
                                                glColor3fv(col);
                                                glVertex2fv(tf->uv[1]);
                                                a = fabsf(uvang3-ang3)/(float)M_PI;
-                                               weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2);
+                                               weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f));
                                                glColor3fv(col);
                                                glVertex2fv(tf->uv[2]);
                                                a = fabsf(uvang4-ang4)/(float)M_PI;
-                                               weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2);
+                                               weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f));
                                                glColor3fv(col);
                                                glVertex2fv(tf->uv[3]);
                                                
@@ -353,15 +353,15 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac
                                                
                                                glBegin(GL_TRIANGLES);
                                                a = fabsf(uvang1-ang1)/(float)M_PI;
-                                               weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2);
+                                               weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f));
                                                glColor3fv(col);
                                                glVertex2fv(tf->uv[0]);
                                                a = fabsf(uvang2-ang2)/(float)M_PI;
-                                               weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2);
+                                               weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f));
                                                glColor3fv(col);
                                                glVertex2fv(tf->uv[1]);
                                                a = fabsf(uvang3-ang3)/(float)M_PI;
-                                               weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2);
+                                               weight_to_rgb(col, 1.0f-powf((1.0f-a), 2.0f));
                                                glColor3fv(col);
                                                glVertex2fv(tf->uv[2]);
                                        }
index 4a303e9..0296fa4 100644 (file)
@@ -49,9 +49,9 @@ static void do_mix_rgb(bNode *node, float *out, float *in1, float *in2, float *f
        
        copy_v3_v3(col, in1);
        if(node->custom2)
-               ramp_blend(node->custom1, col, col+1, col+2, in2[3]*fac[0], in2);
+               ramp_blend(node->custom1, col, in2[3]*fac[0], in2);
        else
-               ramp_blend(node->custom1, col, col+1, col+2, fac[0], in2);
+               ramp_blend(node->custom1, col, fac[0], in2);
        copy_v3_v3(out, col);
        out[3]= in1[3];
 }
index e735061..4a740a2 100644 (file)
@@ -58,7 +58,7 @@ static void node_shader_exec_mix_rgb(void *UNUSED(data), bNode *node, bNodeStack
        nodestack_get_vec(col, SOCK_VECTOR, in[1]);
        nodestack_get_vec(vec, SOCK_VECTOR, in[2]);
 
-       ramp_blend(node->custom1, col, col+1, col+2, fac, vec);
+       ramp_blend(node->custom1, col, fac, vec);
        copy_v3_v3(out[0]->vec, col);
 }
 
index b4b25a1..9e76309 100644 (file)
@@ -110,7 +110,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
                copy_v4_v4( out, mortar );
        } else {
                copy_v4_v4( out, bricks1 );
-               ramp_blend( MA_RAMP_BLEND, out, out+1, out+2, tint, bricks2 );
+               ramp_blend( MA_RAMP_BLEND, out, tint, bricks2 );
        }
 }
 
index 1381608..4111507 100644 (file)
@@ -56,7 +56,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
        CLAMP(fac, 0.0f, 1.0f);
        
        copy_v4_v4(out, col1);
-       ramp_blend(node->custom1, out, out+1, out+2, fac, col2);
+       ramp_blend(node->custom1, out, fac, col2);
 }
 
 static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
index fac8b02..efc8228 100644 (file)
@@ -79,7 +79,7 @@ static void do_proc(float *result, TexParams *p, float *col1, float *col2, char
        }
        else {
                copy_v4_v4(result, col1);
-               ramp_blend(MA_RAMP_BLEND, result, result+1, result+2, texres.tin, col2);
+               ramp_blend(MA_RAMP_BLEND, result, texres.tin, col2);
        }
 }
 
index 3a0f11d..d408b87 100644 (file)
@@ -85,7 +85,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
                }
                else {
                        copy_v4_v4(out, col1);
-                       ramp_blend(MA_RAMP_BLEND, out, out+1, out+2, texres.tin, col2);
+                       ramp_blend(MA_RAMP_BLEND, out, texres.tin, col2);
                }
        }
 }
index a78cc3e..b62484a 100644 (file)
@@ -587,7 +587,7 @@ void shadeSunView(float col_r[3], const float view[3])
                        xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &sun_collector[0], &sun_collector[1], &sun_collector[2], 
                                           lar->sunsky->sky_colorspace);
                        
-                       ramp_blend(lar->sunsky->skyblendtype, col_r, col_r+1, col_r+2, lar->sunsky->skyblendfac, sun_collector);
+                       ramp_blend(lar->sunsky->skyblendtype, col_r, lar->sunsky->skyblendfac, sun_collector);
                }
        }
 }
index 277ef90..9459745 100644 (file)
@@ -1484,32 +1484,32 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa
        case MTEX_BLEND_HUE:
                fact*= facg;
                copy_v3_v3(in, out);
-               ramp_blend(MA_RAMP_HUE, in, in+1, in+2, fact, tex);
+               ramp_blend(MA_RAMP_HUE, in, fact, tex);
                break;
        case MTEX_BLEND_SAT:
                fact*= facg;
                copy_v3_v3(in, out);
-               ramp_blend(MA_RAMP_SAT, in, in+1, in+2, fact, tex);
+               ramp_blend(MA_RAMP_SAT, in, fact, tex);
                break;
        case MTEX_BLEND_VAL:
                fact*= facg;
                copy_v3_v3(in, out);
-               ramp_blend(MA_RAMP_VAL, in, in+1, in+2, fact, tex);
+               ramp_blend(MA_RAMP_VAL, in, fact, tex);
                break;
        case MTEX_BLEND_COLOR:
                fact*= facg;
                copy_v3_v3(in, out);
-               ramp_blend(MA_RAMP_COLOR, in, in+1, in+2, fact, tex);
+               ramp_blend(MA_RAMP_COLOR, in, fact, tex);
                break;
        case MTEX_SOFT_LIGHT: 
                fact*= facg; 
                copy_v3_v3(in, out);
-               ramp_blend(MA_RAMP_SOFT, in, in+1, in+2, fact, tex); 
+               ramp_blend(MA_RAMP_SOFT, in, fact, tex);
                break; 
        case MTEX_LIN_LIGHT: 
                fact*= facg; 
                copy_v3_v3(in, out);
-               ramp_blend(MA_RAMP_LINEAR, in, in+1, in+2, fact, tex); 
+               ramp_blend(MA_RAMP_LINEAR, in, fact, tex);
                break; 
        }
 }
index b58a669..4d654be 100644 (file)
@@ -908,7 +908,7 @@ static void ramp_diffuse_result(float *diff, ShadeInput *shi)
                        /* blending method */
                        fac= col[3]*ma->rampfac_col;
                        
-                       ramp_blend(ma->rampblend_col, diff, diff+1, diff+2, fac, col);
+                       ramp_blend(ma->rampblend_col, diff, fac, col);
                }
        }
 }
@@ -955,7 +955,7 @@ static void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, floa
                        colt[1]= shi->g;
                        colt[2]= shi->b;
 
-                       ramp_blend(ma->rampblend_col, colt, colt+1, colt+2, fac, col);
+                       ramp_blend(ma->rampblend_col, colt, fac, col);
 
                        /* output to */
                        diff[0] += r * colt[0];
@@ -970,20 +970,20 @@ static void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, floa
        }
 }
 
-static void ramp_spec_result(float *specr, float *specg, float *specb, ShadeInput *shi)
+static void ramp_spec_result(float spec_col[3], ShadeInput *shi)
 {
        Material *ma= shi->mat;
 
        if(ma->ramp_spec && (ma->rampin_spec==MA_RAMP_IN_RESULT)) {
                float col[4];
-               float fac= 0.3f*(*specr) + 0.58f*(*specg) + 0.12f*(*specb);
+               float fac= 0.3f*spec_col[0] + 0.58f*spec_col[1] + 0.12f*spec_col[2];
 
                do_colorband(ma->ramp_spec, fac, col);
                
                /* blending method */
                fac= col[3]*ma->rampfac_spec;
                
-               ramp_blend(ma->rampblend_spec, specr, specg, specb, fac, col);
+               ramp_blend(ma->rampblend_spec, spec_col, fac, col);
                
        }
 }
@@ -1023,7 +1023,7 @@ static void do_specular_ramp(ShadeInput *shi, float is, float t, float spec[3])
                /* blending method */
                fac= col[3]*ma->rampfac_spec;
                
-               ramp_blend(ma->rampblend_spec, spec, spec+1, spec+2, fac, col);
+               ramp_blend(ma->rampblend_spec, spec, fac, col);
        }
 }
 
@@ -1873,7 +1873,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
                if(ma->mode & MA_RAMP_COL) ramp_diffuse_result(shr->combined, shi);
        }
 
-       if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(shr->spec, shr->spec+1, shr->spec+2, shi);
+       if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(shr->spec, shi);
        
        /* refcol is for envmap only */
        if(shi->refcol[0]!=0.0f) {