From af7288c407fbb4bb462f509d5782b660a29c4883 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Nov 2011 03:13:54 +0000 Subject: minor edit - weight_to_rgb() and ramp_blend() now take a float vector rather than 3 float pointers. also make particle draw use a float vec. --- source/blender/blenkernel/BKE_DerivedMesh.h | 2 +- source/blender/blenkernel/BKE_material.h | 2 +- source/blender/blenkernel/BKE_particle.h | 2 +- source/blender/blenkernel/intern/DerivedMesh.c | 42 ++-- source/blender/blenkernel/intern/dynamicpaint.c | 2 +- source/blender/blenkernel/intern/material.c | 218 ++++++++++----------- source/blender/blenkernel/intern/particle.c | 6 +- source/blender/editors/space_view3d/drawobject.c | 51 ++--- source/blender/editors/uvedit/uvedit_draw.c | 16 +- .../nodes/composite/nodes/node_composite_mixrgb.c | 4 +- .../nodes/shader/nodes/node_shader_mixRgb.c | 2 +- .../nodes/texture/nodes/node_texture_bricks.c | 2 +- .../nodes/texture/nodes/node_texture_mixRgb.c | 2 +- .../nodes/texture/nodes/node_texture_proc.c | 2 +- .../nodes/texture/nodes/node_texture_texture.c | 2 +- source/blender/render/intern/source/pixelshading.c | 2 +- .../blender/render/intern/source/render_texture.c | 12 +- source/blender/render/intern/source/shadeoutput.c | 14 +- 18 files changed, 185 insertions(+), 198 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 15fdc2fe307..84f1bf75a3f 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -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 */ diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 8e7645d721e..316bc2da170 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -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); diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index c66e49f2906..f491761f3f2 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -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; diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index d03e01ffca7..4e26078a2c5 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -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); diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index b5b345c04a1..519ac1cf534 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -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]); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 48c6d6b2a19..fa0e886b784 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -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; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 220068780a7..7c71df9fece 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -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); } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 7b535309312..1570c7e471c 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -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) ) { diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 0f21aa3759c..0da3f66fc6f 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -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]); } diff --git a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c index 4a303e911e2..0296fa417d6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c @@ -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]; } diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c index e7350612b5b..4a740a2cfdd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c @@ -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); } diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c index b4b25a10537..9e76309bce9 100644 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.c +++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c @@ -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 ); } } diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c index 13816088ea7..41115076ec1 100644 --- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c @@ -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) diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c index fac8b02fb85..efc8228c01c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.c +++ b/source/blender/nodes/texture/nodes/node_texture_proc.c @@ -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); } } diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c index 3a0f11d5417..d408b874b84 100644 --- a/source/blender/nodes/texture/nodes/node_texture_texture.c +++ b/source/blender/nodes/texture/nodes/node_texture_texture.c @@ -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); } } } diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index a78cc3e2288..b62484a6995 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -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); } } } diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 277ef90b9ab..9459745cdbc 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -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; } } diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index b58a6695fd6..4d654beb287 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -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) { -- cgit v1.2.3