swap BMLoopCol r/b color, requires subversion bump.
authorCampbell Barton <ideasman42@gmail.com>
Sat, 17 Mar 2012 20:39:28 +0000 (20:39 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 17 Mar 2012 20:39:28 +0000 (20:39 +0000)
old mesh MCol 'r' was blue, 'b' was red, but theres no reason to keep this for bmesh with MLoopCol.

Loading old files works, saving legacy format works too.

What wont work is loading a file after this revision and loading it in an older revision since the bmesh merge.
(it wont crash but the blue and red will be swapped on vertex color layers).

12 files changed:
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/makesdna/DNA_meshdata_types.h
source/blender/makesrna/intern/rna_mesh.c
source/blender/python/bmesh/bmesh_py_types_meshdata.c

index 392642b53054f13e65e978be6a6a293ef030243c..7bc89a746f764737752b75e35bd72483893a4e82 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION                        262
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION                        262
-#define BLENDER_SUBVERSION             1
+#define BLENDER_SUBVERSION             2
 
 #define BLENDER_MINVERSION             250
 #define BLENDER_MINSUBVERSION  0
 
 #define BLENDER_MINVERSION             250
 #define BLENDER_MINSUBVERSION  0
index 674535d9fb352977d064ce54e12a350d3164e305..5eeccb7b450cb1abece00c67a37a5fafb56b9480 100644 (file)
@@ -1763,10 +1763,7 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
                for (j=0; j<3; j++) {
                        l = l3[j];
                        mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPCOL, i);
                for (j=0; j<3; j++) {
                        l = l3[j];
                        mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPCOL, i);
-                       mcol[j].r = mloopcol->r;
-                       mcol[j].g = mloopcol->g;
-                       mcol[j].b = mloopcol->b;
-                       mcol[j].a = mloopcol->a;
+                       MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]);
                }
        }
 
                }
        }
 
@@ -1776,10 +1773,7 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
                for (j=0; j<3; j++) {
                        l = l3[j];
                        mloopcol = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_WEIGHT_MLOOPCOL);
                for (j=0; j<3; j++) {
                        l = l3[j];
                        mloopcol = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_WEIGHT_MLOOPCOL);
-                       mcol[j].r = mloopcol->r;
-                       mcol[j].g = mloopcol->g;
-                       mcol[j].b = mloopcol->b;
-                       mcol[j].a = mloopcol->a;
+                       MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]);
                }
        }
 }
                }
        }
 }
index e7af73c5e0f00132d089186ebe6174f7e73dc0f5..1387b2be8840908de327c307f1af8acf94aa1aa1 100644 (file)
@@ -663,17 +663,17 @@ static void layerInterp_mloopcol(void **sources, float *weights,
                float weight = weights ? weights[i] : 1;
                MLoopCol *src = sources[i];
                if (sub_weights) {
                float weight = weights ? weights[i] : 1;
                MLoopCol *src = sources[i];
                if (sub_weights) {
-                       col.a += src->a * (*sub_weight) * weight;
                        col.r += src->r * (*sub_weight) * weight;
                        col.g += src->g * (*sub_weight) * weight;
                        col.b += src->b * (*sub_weight) * weight;
                        col.r += src->r * (*sub_weight) * weight;
                        col.g += src->g * (*sub_weight) * weight;
                        col.b += src->b * (*sub_weight) * weight;
+                       col.a += src->a * (*sub_weight) * weight;
                        sub_weight++;
                }
                else {
                        sub_weight++;
                }
                else {
-                       col.a += src->a * weight;
                        col.r += src->r * weight;
                        col.g += src->g * weight;
                        col.b += src->b * weight;
                        col.r += src->r * weight;
                        col.g += src->g * weight;
                        col.b += src->b * weight;
+                       col.a += src->a * weight;
                }
        }
        
                }
        }
        
@@ -684,10 +684,10 @@ static void layerInterp_mloopcol(void **sources, float *weights,
        CLAMP(col.g, 0.0f, 255.0f);
        CLAMP(col.b, 0.0f, 255.0f);
        
        CLAMP(col.g, 0.0f, 255.0f);
        CLAMP(col.b, 0.0f, 255.0f);
        
-       mc->a = (int)col.a;
        mc->r = (int)col.r;
        mc->g = (int)col.g;
        mc->b = (int)col.b;
        mc->r = (int)col.r;
        mc->g = (int)col.g;
        mc->b = (int)col.b;
+       mc->a = (int)col.a;
 }
 
 static void layerCopyValue_mloopuv(void *source, void *dest)
 }
 
 static void layerCopyValue_mloopuv(void *source, void *dest)
index 2c7814a6a4340f600310982f519e9bed2b7dd904..ea3e31de75c84cdde4df5cbf99359c65ccead5fd 100644 (file)
@@ -1653,15 +1653,13 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                                                        /* mix surface color */
                                                                                        interp_v3_v3v3(c, c, &fcolor[v_index], fcolor[v_index+3]);
 
                                                                                        /* mix surface color */
                                                                                        interp_v3_v3v3(c, c, &fcolor[v_index], fcolor[v_index+3]);
 
-                                                                                       col[l_index].r = FTOCHAR(c[2]);
-                                                                                       col[l_index].g = FTOCHAR(c[1]);
-                                                                                       col[l_index].b = FTOCHAR(c[0]);
+                                                                                       rgb_float_to_uchar((unsigned char *)&col[l_index].r, c);
                                                                                }
                                                                                else {
                                                                                }
                                                                                else {
-                                                                                       col[l_index].a = 255;
                                                                                        col[l_index].r =
                                                                                        col[l_index].g =
                                                                                        col[l_index].b = FTOCHAR(pPoint[v_index].wetness);
                                                                                        col[l_index].r =
                                                                                        col[l_index].g =
                                                                                        col[l_index].b = FTOCHAR(pPoint[v_index].wetness);
+                                                                                       col[l_index].a = 255;
                                                                                }
                                                                        }
                                                                }
                                                                                }
                                                                        }
                                                                }
@@ -1681,10 +1679,8 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                        #pragma omp parallel for schedule(static)
                                                        for (i=0; i<totloop; i++) {
                                                                int index = mloop[i].v*4;
                                                        #pragma omp parallel for schedule(static)
                                                        for (i=0; i<totloop; i++) {
                                                                int index = mloop[i].v*4;
-                                                               col[i].a = FTOCHAR(fcolor[index+3]);
-                                                               col[i].r = FTOCHAR(fcolor[index+2]);
-                                                               col[i].g = FTOCHAR(fcolor[index+1]);
-                                                               col[i].b = FTOCHAR(fcolor[index]);
+                                                               rgb_float_to_uchar((unsigned char *)&col[i].r, &fcolor[index]);
+                                                               col[i].a = FTOCHAR(fcolor[index+3]); /* IS THIS NEEDED? */
                                                        }
                                                }
                                                
                                                        }
                                                }
                                                
@@ -1700,10 +1696,10 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                        #pragma omp parallel for schedule(static)
                                                        for (i=0; i<totloop; i++) {
                                                                int index = mloop[i].v;
                                                        #pragma omp parallel for schedule(static)
                                                        for (i=0; i<totloop; i++) {
                                                                int index = mloop[i].v;
-                                                               col[i].a = 255;
                                                                col[i].r =
                                                                col[i].g =
                                                                col[i].b = FTOCHAR(pPoint[index].wetness);
                                                                col[i].r =
                                                                col[i].g =
                                                                col[i].b = FTOCHAR(pPoint[index].wetness);
+                                                               col[i].a = 255;
                                                        }
                                                }
                                        }
                                                        }
                                                }
                                        }
index 3f4ca1b00a23843133e907477af1f3879430c101..4c3e92027e864615386702c7b7ea1d548460e8b9 100644 (file)
@@ -803,7 +803,7 @@ static void emDM_drawFacesTex_common(
 
        luv[0] = luv[1] = luv[2] = &dummyluv;
 
 
        luv[0] = luv[1] = luv[2] = &dummyluv;
 
-       dummylcol.a = dummylcol.r = dummylcol.g = dummylcol.b = 255;
+       dummylcol.r = dummylcol.g = dummylcol.b = dummylcol.a = 255;
 
        /* always use smooth shading even for flat faces, else vertex colors wont interpolate */
        glShadeModel(GL_SMOOTH);
 
        /* always use smooth shading even for flat faces, else vertex colors wont interpolate */
        glShadeModel(GL_SMOOTH);
@@ -844,17 +844,17 @@ static void emDM_drawFacesTex_common(
 
                                        glTexCoord2fv(luv[0]->uv);
                                        if (lcol[0])
 
                                        glTexCoord2fv(luv[0]->uv);
                                        if (lcol[0])
-                                               glColor3ub(lcol[0]->b, lcol[0]->g, lcol[0]->r);
+                                               glColor3ubv((const GLubyte *)&(lcol[0]->r));
                                        glVertex3fv(vertexCos[BM_elem_index_get(ls[0]->v)]);
 
                                        glTexCoord2fv(luv[1]->uv);
                                        if (lcol[1])
                                        glVertex3fv(vertexCos[BM_elem_index_get(ls[0]->v)]);
 
                                        glTexCoord2fv(luv[1]->uv);
                                        if (lcol[1])
-                                               glColor3ub(lcol[1]->b, lcol[1]->g, lcol[1]->r);
+                                               glColor3ubv((const GLubyte *)&(lcol[1]->r));
                                        glVertex3fv(vertexCos[BM_elem_index_get(ls[1]->v)]);
 
                                        glTexCoord2fv(luv[2]->uv);
                                        if (lcol[2])
                                        glVertex3fv(vertexCos[BM_elem_index_get(ls[1]->v)]);
 
                                        glTexCoord2fv(luv[2]->uv);
                                        if (lcol[2])
-                                               glColor3ub(lcol[2]->b, lcol[2]->g, lcol[2]->r);
+                                               glColor3ubv((const GLubyte *)&(lcol[2]->r));
                                        glVertex3fv(vertexCos[BM_elem_index_get(ls[2]->v)]);
                                }
                                else {
                                        glVertex3fv(vertexCos[BM_elem_index_get(ls[2]->v)]);
                                }
                                else {
@@ -862,19 +862,19 @@ static void emDM_drawFacesTex_common(
 
                                        glTexCoord2fv(luv[0]->uv);
                                        if (lcol[0])
 
                                        glTexCoord2fv(luv[0]->uv);
                                        if (lcol[0])
-                                               glColor3ub(lcol[0]->b, lcol[0]->g, lcol[0]->r);
+                                               glColor3ubv((const GLubyte *)&(lcol[0]->r));
                                        glNormal3fv(vertexNos[BM_elem_index_get(ls[0]->v)]);
                                        glVertex3fv(vertexCos[BM_elem_index_get(ls[0]->v)]);
 
                                        glTexCoord2fv(luv[1]->uv);
                                        if (lcol[1])
                                        glNormal3fv(vertexNos[BM_elem_index_get(ls[0]->v)]);
                                        glVertex3fv(vertexCos[BM_elem_index_get(ls[0]->v)]);
 
                                        glTexCoord2fv(luv[1]->uv);
                                        if (lcol[1])
-                                               glColor3ub(lcol[1]->b, lcol[1]->g, lcol[1]->r);
+                                               glColor3ubv((const GLubyte *)&(lcol[1]->r));
                                        glNormal3fv(vertexNos[BM_elem_index_get(ls[1]->v)]);
                                        glVertex3fv(vertexCos[BM_elem_index_get(ls[1]->v)]);
 
                                        glTexCoord2fv(luv[2]->uv);
                                        if (lcol[2])
                                        glNormal3fv(vertexNos[BM_elem_index_get(ls[1]->v)]);
                                        glVertex3fv(vertexCos[BM_elem_index_get(ls[1]->v)]);
 
                                        glTexCoord2fv(luv[2]->uv);
                                        if (lcol[2])
-                                               glColor3ub(lcol[2]->b, lcol[2]->g, lcol[2]->r);
+                                               glColor3ubv((const GLubyte *)&(lcol[2]->r));
                                        glNormal3fv(vertexNos[BM_elem_index_get(ls[2]->v)]);
                                        glVertex3fv(vertexCos[BM_elem_index_get(ls[2]->v)]);
                                }
                                        glNormal3fv(vertexNos[BM_elem_index_get(ls[2]->v)]);
                                        glVertex3fv(vertexCos[BM_elem_index_get(ls[2]->v)]);
                                }
@@ -917,19 +917,19 @@ static void emDM_drawFacesTex_common(
                                        if (luv[0])
                                                glTexCoord2fv(luv[0]->uv);
                                        if (lcol[0])
                                        if (luv[0])
                                                glTexCoord2fv(luv[0]->uv);
                                        if (lcol[0])
-                                               glColor3ub(lcol[0]->b, lcol[0]->g, lcol[0]->r);
+                                               glColor3ubv((const GLubyte *)&(lcol[0]->r));
                                        glVertex3fv(ls[0]->v->co);
 
                                        if (luv[1])
                                                glTexCoord2fv(luv[1]->uv);
                                        if (lcol[1])
                                        glVertex3fv(ls[0]->v->co);
 
                                        if (luv[1])
                                                glTexCoord2fv(luv[1]->uv);
                                        if (lcol[1])
-                                               glColor3ub(lcol[1]->b, lcol[1]->g, lcol[1]->r);
+                                               glColor3ubv((const GLubyte *)&(lcol[1]->r));
                                        glVertex3fv(ls[1]->v->co);
 
                                        if (luv[2])
                                                glTexCoord2fv(luv[2]->uv);
                                        if (lcol[2])
                                        glVertex3fv(ls[1]->v->co);
 
                                        if (luv[2])
                                                glTexCoord2fv(luv[2]->uv);
                                        if (lcol[2])
-                                               glColor3ub(lcol[2]->b, lcol[2]->g, lcol[2]->r);
+                                               glColor3ubv((const GLubyte *)&(lcol[2]->r));
                                        glVertex3fv(ls[2]->v->co);
                                }
                                else {
                                        glVertex3fv(ls[2]->v->co);
                                }
                                else {
@@ -938,21 +938,21 @@ static void emDM_drawFacesTex_common(
                                        if (luv[0])
                                                glTexCoord2fv(luv[0]->uv);
                                        if (lcol[0])
                                        if (luv[0])
                                                glTexCoord2fv(luv[0]->uv);
                                        if (lcol[0])
-                                               glColor3ub(lcol[0]->b, lcol[0]->g, lcol[0]->r);
+                                               glColor3ubv((const GLubyte *)&(lcol[0]->r));
                                        glNormal3fv(ls[0]->v->no);
                                        glVertex3fv(ls[0]->v->co);
 
                                        if (luv[1])
                                                glTexCoord2fv(luv[1]->uv);
                                        if (lcol[1])
                                        glNormal3fv(ls[0]->v->no);
                                        glVertex3fv(ls[0]->v->co);
 
                                        if (luv[1])
                                                glTexCoord2fv(luv[1]->uv);
                                        if (lcol[1])
-                                               glColor3ub(lcol[1]->b, lcol[1]->g, lcol[1]->r);
+                                               glColor3ubv((const GLubyte *)&(lcol[1]->r));
                                        glNormal3fv(ls[1]->v->no);
                                        glVertex3fv(ls[1]->v->co);
 
                                        if (luv[2])
                                                glTexCoord2fv(luv[2]->uv);
                                        if (lcol[2])
                                        glNormal3fv(ls[1]->v->no);
                                        glVertex3fv(ls[1]->v->co);
 
                                        if (luv[2])
                                                glTexCoord2fv(luv[2]->uv);
                                        if (lcol[2])
-                                               glColor3ub(lcol[2]->b, lcol[2]->g, lcol[2]->r);
+                                               glColor3ubv((const GLubyte *)&(lcol[2]->r));
                                        glNormal3fv(ls[2]->v->no);
                                        glVertex3fv(ls[2]->v->co);
                                }
                                        glNormal3fv(ls[2]->v->no);
                                        glVertex3fv(ls[2]->v->co);
                                }
index 253541ea20a99b897d28c295eae5eeb5f571a303..e81c814e3d589a2c5909268b491812a608228cf2 100644 (file)
@@ -1942,11 +1942,11 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex,
                mloopcol = CustomData_get_n(&me->ldata, CD_MLOOPCOL, loopstart, i);
                mcol = CustomData_get_n(&me->fdata, CD_MCOL, findex, i);
 
                mloopcol = CustomData_get_n(&me->ldata, CD_MLOOPCOL, loopstart, i);
                mcol = CustomData_get_n(&me->fdata, CD_MCOL, findex, i);
 
-               mloopcol->r = mcol[0].r; mloopcol->g = mcol[0].g; mloopcol->b = mcol[0].b; mloopcol->a = mcol[0].a; mloopcol++;
-               mloopcol->r = mcol[1].r; mloopcol->g = mcol[1].g; mloopcol->b = mcol[1].b; mloopcol->a = mcol[1].a; mloopcol++;
-               mloopcol->r = mcol[2].r; mloopcol->g = mcol[2].g; mloopcol->b = mcol[2].b; mloopcol->a = mcol[2].a; mloopcol++;
+               MESH_MLOOPCOL_FROM_MCOL(mloopcol, &mcol[0]); mloopcol++;
+               MESH_MLOOPCOL_FROM_MCOL(mloopcol, &mcol[1]); mloopcol++;
+               MESH_MLOOPCOL_FROM_MCOL(mloopcol, &mcol[2]); mloopcol++;
                if (mf->v4) {
                if (mf->v4) {
-                       mloopcol->r = mcol[3].r; mloopcol->g = mcol[3].g; mloopcol->b = mcol[3].b; mloopcol->a = mcol[3].a; mloopcol++;
+                       MESH_MLOOPCOL_FROM_MCOL(mloopcol, &mcol[3]); mloopcol++;
                }
        }
        
                }
        }
        
@@ -2293,10 +2293,7 @@ void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata,
 
                for (j=0; j < mf_len; j++) {
                        mloopcol = CustomData_get_n(ldata, CD_MLOOPCOL, lindex[j], i);
 
                for (j=0; j < mf_len; j++) {
                        mloopcol = CustomData_get_n(ldata, CD_MLOOPCOL, lindex[j], i);
-                       mcol[j].r = mloopcol->r;
-                       mcol[j].g = mloopcol->g;
-                       mcol[j].b = mloopcol->b;
-                       mcol[j].a = mloopcol->a;
+                       MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]);
                }
        }
 
                }
        }
 
@@ -2305,10 +2302,7 @@ void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata,
 
                for (j=0; j < mf_len; j++) {
                        mloopcol = CustomData_get(ldata, lindex[j], CD_WEIGHT_MLOOPCOL);
 
                for (j=0; j < mf_len; j++) {
                        mloopcol = CustomData_get(ldata, lindex[j], CD_WEIGHT_MLOOPCOL);
-                       mcol[j].r = mloopcol->r;
-                       mcol[j].g = mloopcol->g;
-                       mcol[j].b = mloopcol->b;
-                       mcol[j].a = mloopcol->a;
+                       MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]);
                }
        }
 
                }
        }
 
index a3098823d428dbfb96ae05bd4ac6cad9633e7de8..44c519c5def0a6c48641d9ce9df64cb2dfa0b8e7 100644 (file)
@@ -2450,10 +2450,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
                mcol = CustomData_get_n(fdata, CD_MCOL, findex, i);
 
                for (j=0; j<4; j++, mloopcol++) {
                mcol = CustomData_get_n(fdata, CD_MCOL, findex, i);
 
                for (j=0; j<4; j++, mloopcol++) {
-                       mcol[j].r = mloopcol->r;
-                       mcol[j].g = mloopcol->g;
-                       mcol[j].b = mloopcol->b;
-                       mcol[j].a = mloopcol->a;
+                       MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]);
                }
        }
        
                }
        }
        
@@ -2462,10 +2459,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
                mcol = CustomData_get(fdata, findex, CD_WEIGHT_MCOL);
 
                for (j=0; j<4; j++, mloopcol++) {
                mcol = CustomData_get(fdata, findex, CD_WEIGHT_MCOL);
 
                for (j=0; j<4; j++, mloopcol++) {
-                       mcol[j].r = mloopcol->r;
-                       mcol[j].g = mloopcol->g;
-                       mcol[j].b = mloopcol->b;
-                       mcol[j].a = mloopcol->a;
+                       MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]);
                }
        }
 
                }
        }
 
index 0ba4c7a63d021ed96da2dfbadab4ae46c5ae9140..fcb492e02ca861ada7dae3a59ace10e8ccec9c0a 100644 (file)
@@ -7753,6 +7753,26 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo
        }
 }
 
        }
 }
 
+/* blue and red are swapped pre 2.62.1, be sane (red == red) now! */
+static void do_versions_mesh_mloopcol_swap_2_62_1(Mesh *me)
+{
+       CustomDataLayer *layer;
+       MLoopCol *mloopcol;
+       int a;
+       int i;
+
+       for(a = 0; a < me->ldata.totlayer; a++) {
+               layer = &me->ldata.layers[a];
+
+               if(layer->type == CD_MLOOPCOL) {
+                       mloopcol = (MLoopCol *)layer->data;
+                       for(i = 0; i < me->totloop; i++, mloopcol++) {
+                               SWAP(char, mloopcol->r, mloopcol->b);
+                       }
+               }
+       }
+}
+
 static void do_versions(FileData *fd, Library *lib, Main *main)
 {
        /* WATCH IT!!!: pointers from libdata have not been converted */
 static void do_versions(FileData *fd, Library *lib, Main *main)
 {
        /* WATCH IT!!!: pointers from libdata have not been converted */
@@ -13245,7 +13265,19 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        do_versions_nodetree_multi_file_output_format_2_62_1(NULL, ntree);
        }
 
                        do_versions_nodetree_multi_file_output_format_2_62_1(NULL, ntree);
        }
 
-       /* put compatibility code here until next subversion bump */
+       /* only swap for pre-release bmesh merge which had MLoopCol red/blue swap */
+       if (main->versionfile == 262 && main->subversionfile == 1)
+       {
+               {
+                       Mesh *me;
+                       for (me = main->mesh.first; me; me = me->id.next) {
+                               do_versions_mesh_mloopcol_swap_2_62_1(me);
+                       }
+               }
+
+       }
+
+       if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 2))
        {
                {
                        /* Set new idname of keyingsets from their now "label-only" name. */
        {
                {
                        /* Set new idname of keyingsets from their now "label-only" name. */
@@ -13260,6 +13292,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
                }
        }
 
+       /* put compatibility code here until next subversion bump */
+       {
+
+       }
+
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
 
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
 
index c69879fcd3296be6aa2bd6ff6182754fafa021c2..3bf4be1ec3d75e5d038a2bc112cceecec6cd0c49 100644 (file)
@@ -694,10 +694,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
                                lcol = &mloopcol[mp->loopstart];
 
                                for (j = 0; j <= totloop_clamp; j++, lcol++) {
                                lcol = &mloopcol[mp->loopstart];
 
                                for (j = 0; j <= totloop_clamp; j++, lcol++) {
-                                       tmp_mcol[j].a = lcol->a;
-                                       tmp_mcol[j].r = lcol->r;
-                                       tmp_mcol[j].g = lcol->g;
-                                       tmp_mcol[j].b = lcol->b;
+                                       MESH_MLOOPCOL_TO_MCOL(lcol, &tmp_mcol[j]);
                                }
                        }
 
                                }
                        }
 
index 6b526c6463e5fd292ab804d78b00135c69144323..2de89a31ab052b00146aef750617f478ca02c74e 100644 (file)
@@ -122,9 +122,30 @@ typedef struct MLoopUV {
 /* at the moment alpha is abused for vertex painting
  * and not used for transparency, note that red and blue are swapped */
 typedef struct MLoopCol {
 /* at the moment alpha is abused for vertex painting
  * and not used for transparency, note that red and blue are swapped */
 typedef struct MLoopCol {
-       char a, r, g, b;
+       char r, g, b, a;
 } MLoopCol;
 
 } MLoopCol;
 
+#define MESH_MLOOPCOL_FROM_MCOL(_mloopcol, _mcol) \
+{                                                 \
+       MLoopCol   *mloopcol__tmp = _mloopcol;        \
+       const MCol *mcol__tmp     = _mcol;            \
+       mloopcol__tmp->r = mcol__tmp->b;              \
+       mloopcol__tmp->g = mcol__tmp->g;              \
+       mloopcol__tmp->b = mcol__tmp->r;              \
+       mloopcol__tmp->a = mcol__tmp->a;              \
+} (void)0
+
+
+#define MESH_MLOOPCOL_TO_MCOL(_mloopcol, _mcol) \
+{                                               \
+       const MLoopCol *mloopcol__tmp = _mloopcol;  \
+       MCol           *mcol__tmp     = _mcol;      \
+       mcol__tmp->b = mloopcol__tmp->r;            \
+       mcol__tmp->g = mloopcol__tmp->g;            \
+       mcol__tmp->r = mloopcol__tmp->b;            \
+       mcol__tmp->a = mloopcol__tmp->a;            \
+} (void)0
+
 typedef struct MSticky {
        float co[2];
 } MSticky;
 typedef struct MSticky {
        float co[2];
 } MSticky;
index ec56004f2535517eba42ef7689757511c01b125d..f7dee561250b020e073e570b33ec67d78e743131 100644 (file)
@@ -432,18 +432,18 @@ static void rna_MeshLoopColor_color_get(PointerRNA *ptr, float *values)
 {
        MLoopCol *mcol = (MLoopCol *)ptr->data;
 
 {
        MLoopCol *mcol = (MLoopCol *)ptr->data;
 
-       values[2] = (&mcol->r)[0]/255.0f;
-       values[1] = (&mcol->r)[1]/255.0f;
-       values[0] = (&mcol->r)[2]/255.0f;
+       values[0] = (&mcol->r)[0] / 255.0f;
+       values[1] = (&mcol->r)[1] / 255.0f;
+       values[2] = (&mcol->r)[2] / 255.0f;
 }
 
 static void rna_MeshLoopColor_color_set(PointerRNA *ptr, const float *values)
 {
        MLoopCol *mcol = (MLoopCol *)ptr->data;
 
 }
 
 static void rna_MeshLoopColor_color_set(PointerRNA *ptr, const float *values)
 {
        MLoopCol *mcol = (MLoopCol *)ptr->data;
 
-       (&mcol->r)[2] = (char)(CLAMPIS(values[0]*255.0f, 0, 255));
-       (&mcol->r)[1] = (char)(CLAMPIS(values[1]*255.0f, 0, 255));
-       (&mcol->r)[0] = (char)(CLAMPIS(values[2]*255.0f, 0, 255));
+       (&mcol->r)[0] = (char)(CLAMPIS(values[0] * 255.0f, 0, 255));
+       (&mcol->r)[1] = (char)(CLAMPIS(values[1] * 255.0f, 0, 255));
+       (&mcol->r)[2] = (char)(CLAMPIS(values[2] * 255.0f, 0, 255));
 }
 
 static int rna_Mesh_texspace_editable(PointerRNA *ptr)
 }
 
 static int rna_Mesh_texspace_editable(PointerRNA *ptr)
index 0a45a4688c8807844e3f7b8db6d515af8ab42034..e98413012019715f8cb6e3dd4fc05a5afd5aad19 100644 (file)
@@ -150,16 +150,12 @@ PyObject *BPy_BMLoopUV_CreatePyObject(struct MLoopUV *mloopuv)
 
 static void mloopcol_to_float(const MLoopCol *mloopcol, float col_r[3])
 {
 
 static void mloopcol_to_float(const MLoopCol *mloopcol, float col_r[3])
 {
-       col_r[0] = ((float)mloopcol->b) / 255.0f;
-       col_r[1] = ((float)mloopcol->g) / 255.0f;
-       col_r[2] = ((float)mloopcol->r) / 255.0f;
+       rgb_uchar_to_float(col_r, (unsigned char *)&mloopcol->r);
 }
 
 static void mloopcol_from_float(MLoopCol *mloopcol, const float col[3])
 {
 }
 
 static void mloopcol_from_float(MLoopCol *mloopcol, const float col[3])
 {
-       mloopcol->b = FTOCHAR(col[0]);
-       mloopcol->g = FTOCHAR(col[1]);
-       mloopcol->r = FTOCHAR(col[2]);
+       rgb_float_to_uchar((unsigned char *)&mloopcol->r, col);
 }
 
 static unsigned char mathutils_bmloopcol_cb_index = -1;
 }
 
 static unsigned char mathutils_bmloopcol_cb_index = -1;