rename rgb_float_to_byte, rgb_byte_to_float to rgb_float_to_uchar, rgb_uchar_to_float...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 19 Jan 2012 09:09:00 +0000 (09:09 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 19 Jan 2012 09:09:00 +0000 (09:09 +0000)
source/blender/blenkernel/intern/sequencer.c
source/blender/blenlib/BLI_math_color.h
source/blender/blenlib/intern/math_color.c
source/blender/blenlib/intern/math_color_inline.c
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_view3d/drawarmature.c
source/blender/editors/space_view3d/drawobject.c
source/tests/bl_mesh_modifiers.py

index 71377799651b2c8b483c99e3e001cb3b36ca73db..08b531159193b8baf4a0ca3b4c1638aa4e9aab84 100644 (file)
@@ -1690,10 +1690,10 @@ static ImBuf * input_preprocess(
                if(rct) {
                        float rgb[3];
                        for (i = ibuf->x * ibuf->y; i > 0; i--, rct+=4) {
-                               rgb_byte_to_float(rct, rgb);
+                               rgb_uchar_to_float(rgb, rct);
                                rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
                                hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rgb, rgb+1, rgb+2);
-                               rgb_float_to_byte(rgb, rct);
+                               rgb_float_to_uchar(rct, rgb);
                        }
                }
 
index 6d37aabd6abc191425303b441c4561287b6561c3..1b8cc08abf7ea0ba4dc3e552b6a32180f9e4a870 100644 (file)
@@ -101,8 +101,8 @@ void minmax_rgb(short c[3]);
 void rgb_float_set_hue_float_offset(float * rgb, float hue_offset);
 void rgb_byte_set_hue_float_offset(unsigned char * rgb, float hue_offset);
 
-void rgb_byte_to_float(const unsigned char in[3], float out[3]);
-void rgb_float_to_byte(const float in[3], unsigned char out[3]);
+void rgb_uchar_to_float(float col_r[3], const unsigned char col_ub[3]);
+void rgb_float_to_uchar(unsigned char col_r[3], const float col_f[3]);
 
 /***************** lift/gamma/gain / ASC-CDL conversion *****************/
 
index 20df893015da4e4ce5fa88e3e50588aebe734d8c..31d69ba68b43294f4598189182de20e12744672d 100644 (file)
@@ -337,24 +337,24 @@ void cpack_to_rgb(unsigned int col, float *r, float *g, float *b)
        *b /= 255.0f;
 }
 
-void rgb_byte_to_float(const unsigned char in[3], float out[3])
+void rgb_uchar_to_float(float col_r[3], const unsigned char col_ub[3])
 {
-       out[0]= ((float)in[0]) / 255.0f;
-       out[1]= ((float)in[1]) / 255.0f;
-       out[2]= ((float)in[2]) / 255.0f;
+       col_r[0]= ((float)col_ub[0]) / 255.0f;
+       col_r[1]= ((float)col_ub[1]) / 255.0f;
+       col_r[2]= ((float)col_ub[2]) / 255.0f;
 }
 
-void rgb_float_to_byte(const float in[3], unsigned char out[3])
+void rgb_float_to_uchar(unsigned char col_r[3], const float col_f[3])
 {
        int r, g, b;
        
-       r= (int)(in[0] * 255.0f);
-       g= (int)(in[1] * 255.0f);
-       b= (int)(in[2] * 255.0f);
+       r= (int)(col_f[0] * 255.0f);
+       g= (int)(col_f[1] * 255.0f);
+       b= (int)(col_f[2] * 255.0f);
        
-       out[0]= (char)((r <= 0)? 0 : (r >= 255)? 255 : r);
-       out[1]= (char)((g <= 0)? 0 : (g >= 255)? 255 : g);
-       out[2]= (char)((b <= 0)? 0 : (b >= 255)? 255 : b);
+       col_r[0]= (char)((r <= 0)? 0 : (r >= 255)? 255 : r);
+       col_r[1]= (char)((g <= 0)? 0 : (g >= 255)? 255 : g);
+       col_r[2]= (char)((b <= 0)? 0 : (b >= 255)? 255 : b);
 }
 
 /* ********************************* color transforms ********************************* */
@@ -490,9 +490,9 @@ void rgb_byte_set_hue_float_offset(unsigned char rgb[3], float hue_offset)
 {
        float rgb_float[3];
        
-       rgb_byte_to_float(rgb, rgb_float);
+       rgb_uchar_to_float(rgb_float, rgb);
        rgb_float_set_hue_float_offset(rgb_float, hue_offset);
-       rgb_float_to_byte(rgb_float, rgb);
+       rgb_float_to_uchar(rgb, rgb_float);
 }
 
 
index 18b0e9c6278360b7d34bb4c12356762648911b8c..2c7b13b86a2f08a0a20d519e33a1848c16cfe0be 100644 (file)
@@ -66,9 +66,9 @@ MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[4], const float linear[
 {
        int r, g, b;
 
-       r = 255 * linearrgb_to_srgb(linear[0]) * 255;
-       g = 255 * linearrgb_to_srgb(linear[1]) * 255;
-       b = 255 * linearrgb_to_srgb(linear[2]) * 255;
+       r = 255 * linearrgb_to_srgb(linear[0]);
+       g = 255 * linearrgb_to_srgb(linear[1]);
+       b = 255 * linearrgb_to_srgb(linear[2]);
 
        srgb[0] = FTOCHAR(r);
        srgb[1] = FTOCHAR(g);
@@ -79,9 +79,9 @@ MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[
 {
        int r, g, b, a;
 
-       r = 255 * linearrgb_to_srgb(linear[0]) * 255;
-       g = 255 * linearrgb_to_srgb(linear[1]) * 255;
-       b = 255 * linearrgb_to_srgb(linear[2]) * 255;
+       r = 255 * linearrgb_to_srgb(linear[0]);
+       g = 255 * linearrgb_to_srgb(linear[1]);
+       b = 255 * linearrgb_to_srgb(linear[2]);
        a = 255 * linear[3];
 
        srgb[0] = FTOCHAR(r);
index f0f3b8f4123e0db1cffce43df35a3b98711873f0..a0082b3258fc95bbbc8d2838190d77d18eaadead 100644 (file)
@@ -186,7 +186,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
                }
                
                /* copy the colors over, transforming from bytes to floats */
-               rgb_byte_to_float(cp, color);
+               rgb_uchar_to_float(color, cp);
        }
        else {
                // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)?
index 176ffd91e3b7060d0396190268748aefa3df1fc2..511f1524fae3a0662e26dd467316d405fd6a5828 100644 (file)
@@ -143,7 +143,7 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[
                
        case SEQ_COLOR:
                if (colvars->col) {
-                       rgb_float_to_byte(colvars->col, col);
+                       rgb_float_to_uchar(col, colvars->col);
                } else {
                        col[0] = col[1] = col[2] = 128;
                }
index 17cb1ce2995398017aee103fc7c76edce65403ef..2d77ab208081e39f4488942219a7ca85d7be14bf 100644 (file)
@@ -1966,7 +1966,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
                        unsigned char col[4];
                        float col_f[4];
                        glGetFloatv(GL_CURRENT_COLOR, col_f); /* incase this is not set below */
-                       rgb_float_to_byte(col_f, col);
+                       rgb_float_to_uchar(col, col_f);
                        col[3]= 255;
                        
                        if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
index 193f9b1f49f48a8be44c4f3acfcde8e4def3bc70..441665377c7dc968313169f30e20c088d93c3d57 100644 (file)
@@ -4100,7 +4100,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
        if(v3d->zbuf) glDepthMask(1);
 
        if((ma) && (part->draw_col == PART_DRAW_COL_MAT)) {
-               rgb_float_to_byte(&(ma->r), tcol);
+               rgb_float_to_uchar(tcol, &(ma->r));
                copy_v3_v3(ma_col, &ma->r);
        }
 
@@ -6152,7 +6152,7 @@ static void drawRBpivot(bRigidBodyJointConstraint *data)
        float curcol[4];
        unsigned char tcol[4];
        glGetFloatv(GL_CURRENT_COLOR, curcol);
-       rgb_float_to_byte(curcol, tcol);
+       rgb_float_to_uchar(tcol, curcol);
        tcol[3]= 255;
 
        eul_to_mat4(mat,&data->axX);
@@ -6775,7 +6775,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                                        float curcol[4];
                                        unsigned char tcol[4];
                                        glGetFloatv(GL_CURRENT_COLOR, curcol);
-                                       rgb_float_to_byte(curcol, tcol);
+                                       rgb_float_to_uchar(tcol, curcol);
                                        tcol[3]= 255;
                                        view3d_cached_text_draw_add(zero, ob->id.name+2, 10, 0, tcol);
                                }
index 789a403765953866006db407d377d231a8803a35..917ccbc0d24f826bdb15a66c859f3c7f11907f26 100644 (file)
@@ -301,7 +301,7 @@ def mesh_vcol_add(obj, mode=0):
             face_verts = mesh_bmesh_poly_vertices(poly)
             poly_cols = mesh_bmesh_poly_elems(poly, col_list)
             for i, c in enumerate(poly_cols):
-                c.color = colors[i % 4]
+                c.color = colors_get(face_verts[i])
     else:
         for i, col in enumerate(vcol_lay.data):
             face_verts = mesh.faces[i].vertices