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:
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c10
-rw-r--r--source/blender/blenkernel/intern/customdata.c6
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c14
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c26
-rw-r--r--source/blender/blenkernel/intern/mesh.c18
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c10
-rw-r--r--source/blender/blenloader/intern/readfile.c39
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c5
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h23
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c12
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_meshdata.c8
12 files changed, 101 insertions, 72 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 392642b5305..7bc89a746f7 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
* 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
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 674535d9fb3..5eeccb7b450 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -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);
- 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);
- 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]);
}
}
}
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index e7af73c5e0f..1387b2be884 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -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) {
- 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.a += src->a * (*sub_weight) * weight;
sub_weight++;
}
else {
- col.a += src->a * 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);
- mc->a = (int)col.a;
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)
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 2c7814a6a43..ea3e31de75c 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -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]);
- 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 {
- 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].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;
- 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;
- col[i].a = 255;
col[i].r =
col[i].g =
col[i].b = FTOCHAR(pPoint[index].wetness);
+ col[i].a = 255;
}
}
}
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index 3f4ca1b00a2..4c3e92027e8 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -803,7 +803,7 @@ static void emDM_drawFacesTex_common(
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);
@@ -844,17 +844,17 @@ static void emDM_drawFacesTex_common(
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])
- 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])
- 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 {
@@ -862,19 +862,19 @@ static void emDM_drawFacesTex_common(
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])
- 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])
- 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)]);
}
@@ -917,19 +917,19 @@ static void emDM_drawFacesTex_common(
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])
- 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])
- glColor3ub(lcol[2]->b, lcol[2]->g, lcol[2]->r);
+ glColor3ubv((const GLubyte *)&(lcol[2]->r));
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])
- 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])
- 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])
- 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);
}
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 253541ea20a..e81c814e3d5 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -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->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) {
- 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);
- 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);
- 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]);
}
}
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index a3098823d42..44c519c5def 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -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[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[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]);
}
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 0ba4c7a63d0..fcb492e02ca 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -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 */
@@ -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);
}
- /* 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. */
@@ -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! */
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index c69879fcd32..3bf4be1ec3d 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -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++) {
- 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]);
}
}
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index 6b526c6463e..2de89a31ab0 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -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 {
- char a, r, g, b;
+ char r, g, b, a;
} 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;
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index ec56004f253..f7dee561250 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -432,18 +432,18 @@ static void rna_MeshLoopColor_color_get(PointerRNA *ptr, float *values)
{
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;
- (&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)
diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
index 0a45a4688c8..e9841301201 100644
--- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
@@ -150,16 +150,12 @@ PyObject *BPy_BMLoopUV_CreatePyObject(struct MLoopUV *mloopuv)
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])
{
- 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;