Fix vertex paint w/ subsurf drawing
Only use alpha blending when in vertex paint mode.
This commit is contained in:
@@ -752,18 +752,8 @@ static void cdDM_drawMappedFaces(
|
||||
/* avoid buffer problems in following code */
|
||||
}
|
||||
else if (setDrawOptions == NULL) {
|
||||
const bool show_alpha = true;
|
||||
if (show_alpha) {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
/* just draw the entire face array */
|
||||
GPU_buffer_draw_elements(dm->drawObject->triangles, GL_TRIANGLES, 0, tot_tri_elem);
|
||||
|
||||
if (show_alpha) {
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (mat_index = 0; mat_index < dm->drawObject->totmaterial; mat_index++) {
|
||||
|
||||
@@ -1036,11 +1036,11 @@ static void emDM_drawMappedFaces(
|
||||
if (poly_prev != GL_ZERO) glEnd();
|
||||
glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */
|
||||
}
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[0]->r));
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[1]->r));
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[2]->r));
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
|
||||
}
|
||||
else {
|
||||
@@ -1057,23 +1057,23 @@ static void emDM_drawMappedFaces(
|
||||
|
||||
if (!drawSmooth) {
|
||||
glNormal3fv(polyNos[BM_elem_index_get(efa)]);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[0]->r));
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[1]->r));
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[2]->r));
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
|
||||
}
|
||||
else {
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]);
|
||||
else glNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]);
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]);
|
||||
else glNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]);
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]);
|
||||
else glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]);
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
|
||||
@@ -1138,11 +1138,11 @@ static void emDM_drawMappedFaces(
|
||||
if (poly_prev != GL_ZERO) glEnd();
|
||||
glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */
|
||||
}
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[0]->r));
|
||||
glVertex3fv(ltri[0]->v->co);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[1]->r));
|
||||
glVertex3fv(ltri[1]->v->co);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[2]->r));
|
||||
glVertex3fv(ltri[2]->v->co);
|
||||
}
|
||||
else {
|
||||
@@ -1159,23 +1159,23 @@ static void emDM_drawMappedFaces(
|
||||
|
||||
if (!drawSmooth) {
|
||||
glNormal3fv(efa->no);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[0]->r));
|
||||
glVertex3fv(ltri[0]->v->co);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[1]->r));
|
||||
glVertex3fv(ltri[1]->v->co);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[2]->r));
|
||||
glVertex3fv(ltri[2]->v->co);
|
||||
}
|
||||
else {
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]);
|
||||
else glNormal3fv(ltri[0]->v->no);
|
||||
glVertex3fv(ltri[0]->v->co);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]);
|
||||
else glNormal3fv(ltri[1]->v->no);
|
||||
glVertex3fv(ltri[1]->v->co);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]);
|
||||
else glNormal3fv(ltri[2]->v->no);
|
||||
glVertex3fv(ltri[2]->v->co);
|
||||
@@ -1298,32 +1298,32 @@ static void emDM_drawFacesTex_common(
|
||||
glNormal3fv(polyNos[BM_elem_index_get(efa)]);
|
||||
|
||||
glTexCoord2fv(luv[0]->uv);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[0]->r));
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
|
||||
|
||||
glTexCoord2fv(luv[1]->uv);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[1]->r));
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
|
||||
|
||||
glTexCoord2fv(luv[2]->uv);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[2]->r));
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
|
||||
}
|
||||
else {
|
||||
glTexCoord2fv(luv[0]->uv);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]);
|
||||
else glNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]);
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
|
||||
|
||||
glTexCoord2fv(luv[1]->uv);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]);
|
||||
else glNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]);
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
|
||||
|
||||
glTexCoord2fv(luv[2]->uv);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]);
|
||||
else glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]);
|
||||
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
|
||||
@@ -1362,32 +1362,32 @@ static void emDM_drawFacesTex_common(
|
||||
glNormal3fv(efa->no);
|
||||
|
||||
glTexCoord2fv(luv[0]->uv);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[0]->r));
|
||||
glVertex3fv(ltri[0]->v->co);
|
||||
|
||||
glTexCoord2fv(luv[1]->uv);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[1]->r));
|
||||
glVertex3fv(ltri[1]->v->co);
|
||||
|
||||
glTexCoord2fv(luv[2]->uv);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[2]->r));
|
||||
glVertex3fv(ltri[2]->v->co);
|
||||
}
|
||||
else {
|
||||
glTexCoord2fv(luv[0]->uv);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[0]->r));
|
||||
if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]);
|
||||
else glNormal3fv(ltri[0]->v->no);
|
||||
glVertex3fv(ltri[0]->v->co);
|
||||
|
||||
glTexCoord2fv(luv[1]->uv);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[1]->r));
|
||||
if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]);
|
||||
else glNormal3fv(ltri[1]->v->no);
|
||||
glVertex3fv(ltri[1]->v->co);
|
||||
|
||||
glTexCoord2fv(luv[2]->uv);
|
||||
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (has_vcol_any) glColor4ubv((const GLubyte *)&(lcol[2]->r));
|
||||
if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]);
|
||||
else glNormal3fv(ltri[2]->v->no);
|
||||
glVertex3fv(ltri[2]->v->co);
|
||||
|
||||
@@ -2198,12 +2198,12 @@ static void ccgDM_buffer_copy_color(
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
for (y = 0; y < gridFaces; y++) {
|
||||
for (x = 0; x < gridFaces; x++) {
|
||||
copy_v3_v3_uchar(&varray[start + 0], &mloopcol[iface * 16 + 0]);
|
||||
copy_v3_v3_uchar(&varray[start + 3], &mloopcol[iface * 16 + 12]);
|
||||
copy_v3_v3_uchar(&varray[start + 6], &mloopcol[iface * 16 + 8]);
|
||||
copy_v3_v3_uchar(&varray[start + 9], &mloopcol[iface * 16 + 4]);
|
||||
copy_v4_v4_uchar(&varray[start + 0], &mloopcol[iface * 16 + 0]);
|
||||
copy_v4_v4_uchar(&varray[start + 4], &mloopcol[iface * 16 + 12]);
|
||||
copy_v4_v4_uchar(&varray[start + 8], &mloopcol[iface * 16 + 8]);
|
||||
copy_v4_v4_uchar(&varray[start + 12], &mloopcol[iface * 16 + 4]);
|
||||
|
||||
start += 12;
|
||||
start += 16;
|
||||
iface++;
|
||||
}
|
||||
}
|
||||
@@ -3798,16 +3798,16 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
|
||||
float *c = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
|
||||
float *d = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
|
||||
|
||||
if (cp) glColor3ubv(&cp[4]);
|
||||
if (cp) glColor4ubv(&cp[4]);
|
||||
glNormal3fv(ln[1]);
|
||||
glVertex3fv(d);
|
||||
if (cp) glColor3ubv(&cp[8]);
|
||||
if (cp) glColor4ubv(&cp[8]);
|
||||
glNormal3fv(ln[2]);
|
||||
glVertex3fv(c);
|
||||
if (cp) glColor3ubv(&cp[12]);
|
||||
if (cp) glColor4ubv(&cp[12]);
|
||||
glNormal3fv(ln[3]);
|
||||
glVertex3fv(b);
|
||||
if (cp) glColor3ubv(&cp[0]);
|
||||
if (cp) glColor4ubv(&cp[0]);
|
||||
glNormal3fv(ln[0]);
|
||||
glVertex3fv(a);
|
||||
|
||||
@@ -3825,10 +3825,10 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
|
||||
a = CCG_grid_elem(&key, faceGridData, x, y + 0);
|
||||
b = CCG_grid_elem(&key, faceGridData, x, y + 1);
|
||||
|
||||
if (cp) glColor3ubv(&cp[0]);
|
||||
if (cp) glColor4ubv(&cp[0]);
|
||||
glNormal3fv(CCG_elem_no(&key, a));
|
||||
glVertex3fv(CCG_elem_co(&key, a));
|
||||
if (cp) glColor3ubv(&cp[4]);
|
||||
if (cp) glColor4ubv(&cp[4]);
|
||||
glNormal3fv(CCG_elem_no(&key, b));
|
||||
glVertex3fv(CCG_elem_co(&key, b));
|
||||
|
||||
@@ -3840,10 +3840,10 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
|
||||
a = CCG_grid_elem(&key, faceGridData, x, y + 0);
|
||||
b = CCG_grid_elem(&key, faceGridData, x, y + 1);
|
||||
|
||||
if (cp) glColor3ubv(&cp[12]);
|
||||
if (cp) glColor4ubv(&cp[12]);
|
||||
glNormal3fv(CCG_elem_no(&key, a));
|
||||
glVertex3fv(CCG_elem_co(&key, a));
|
||||
if (cp) glColor3ubv(&cp[8]);
|
||||
if (cp) glColor4ubv(&cp[8]);
|
||||
glNormal3fv(CCG_elem_no(&key, b));
|
||||
glVertex3fv(CCG_elem_co(&key, b));
|
||||
|
||||
@@ -3863,13 +3863,13 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
|
||||
|
||||
ccgDM_glNormalFast(a, b, c, d);
|
||||
|
||||
if (cp) glColor3ubv(&cp[4]);
|
||||
if (cp) glColor4ubv(&cp[4]);
|
||||
glVertex3fv(d);
|
||||
if (cp) glColor3ubv(&cp[8]);
|
||||
if (cp) glColor4ubv(&cp[8]);
|
||||
glVertex3fv(c);
|
||||
if (cp) glColor3ubv(&cp[12]);
|
||||
if (cp) glColor4ubv(&cp[12]);
|
||||
glVertex3fv(b);
|
||||
if (cp) glColor3ubv(&cp[0]);
|
||||
if (cp) glColor4ubv(&cp[0]);
|
||||
glVertex3fv(a);
|
||||
|
||||
if (cp) cp += 16;
|
||||
|
||||
@@ -678,6 +678,7 @@ static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol)
|
||||
finalCol[loop_index].r = 255;
|
||||
finalCol[loop_index].g = 0;
|
||||
finalCol[loop_index].b = 255;
|
||||
finalCol[loop_index].a = 255;
|
||||
}
|
||||
copy_mode = COPY_PREV;
|
||||
}
|
||||
@@ -685,6 +686,7 @@ static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol)
|
||||
int loop_index = mp->loopstart;
|
||||
for (j = 0; j < mp->totloop; j++, loop_index++) {
|
||||
copy_v3_v3_uchar(&finalCol[loop_index].r, Gtexdraw.obcol);
|
||||
finalCol[loop_index].a = 255;
|
||||
}
|
||||
copy_mode = COPY_PREV;
|
||||
}
|
||||
@@ -1297,6 +1299,13 @@ void draw_mesh_paint_vcolor_faces(DerivedMesh *dm, const bool use_light,
|
||||
flags |= DM_DRAW_NEED_NORMALS;
|
||||
}
|
||||
|
||||
/* Don't show alpha in wire mode. */
|
||||
const bool show_alpha = use_light;
|
||||
if (show_alpha) {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
if (me->mloopcol) {
|
||||
dm->drawMappedFaces(dm, facemask_cb, setMaterial, NULL, user_data,
|
||||
DM_DRAW_USE_COLORS | flags);
|
||||
@@ -1306,6 +1315,10 @@ void draw_mesh_paint_vcolor_faces(DerivedMesh *dm, const bool use_light,
|
||||
dm->drawMappedFaces(dm, facemask_cb, setMaterial, NULL, user_data, flags);
|
||||
}
|
||||
|
||||
if (show_alpha) {
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
if (use_light) {
|
||||
draw_mesh_paint_light_end();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user