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:
authorCampbell Barton <ideasman42@gmail.com>2011-11-26 07:13:54 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-26 07:13:54 +0400
commitaf7288c407fbb4bb462f509d5782b660a29c4883 (patch)
tree9c56d26ed78e2d93284d250c5b270518c329376f /source/blender/blenkernel
parent491526e5ed31bdba3e0a16e0ad6b8b59afb2f8d3 (diff)
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.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h2
-rw-r--r--source/blender/blenkernel/BKE_material.h2
-rw-r--r--source/blender/blenkernel/BKE_particle.h2
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c42
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c2
-rw-r--r--source/blender/blenkernel/intern/material.c218
-rw-r--r--source/blender/blenkernel/intern/particle.c6
7 files changed, 136 insertions, 138 deletions
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);
}