Mesh Drawing:

Option to draw mesh vertex-weights in editmode, available from the 'Mesh Display' panel.

TODO: get this to work when modifiers are applied in solid mode (texface-solidmode is working).
This commit is contained in:
Campbell Barton 2013-04-13 20:20:21 +00:00
parent e1c9353c94
commit 31c375b97a
6 changed files with 174 additions and 67 deletions

@ -2554,6 +2554,8 @@ class VIEW3D_PT_view3d_meshdisplay(Panel):
mesh = context.active_object.data
layout.prop(mesh, "show_weight")
split = layout.split()
with_freestyle = context.scene and bpy.app.build_options.freestyle
@ -2571,7 +2573,7 @@ class VIEW3D_PT_view3d_meshdisplay(Panel):
if not with_freestyle:
col.prop(mesh, "show_edge_seams", text="Seams")
col.prop(mesh, "show_edge_sharp", text="Sharp", text_ctxt=i18n_contexts.plural)
col.prop(mesh, "show_edge_bevel_weight", text="Weights")
col.prop(mesh, "show_edge_bevel_weight", text="Bevel")
if with_freestyle:
col.prop(mesh, "show_freestyle_edge_marks", text="Edge Marks")
col.prop(mesh, "show_freestyle_face_marks", text="Face Marks")

@ -60,6 +60,8 @@ typedef struct BMEditMesh {
/*derivedmesh stuff*/
struct DerivedMesh *derivedFinal, *derivedCage;
CustomDataMask lastDataMask;
unsigned char (*derivedVertColor)[4];
int derivedVertColorLen;
/* index tables, to map indices to elements via
* EDBM_index_arrays_init and associated functions. don't

@ -1032,6 +1032,14 @@ typedef struct DMWeightColorInfo {
} DMWeightColorInfo;
static int dm_drawflag_calc(ToolSettings *ts)
{
return ((ts->multipaint ? CALC_WP_MULTIPAINT :
/* CALC_WP_GROUP_USER_ACTIVE or CALC_WP_GROUP_USER_ALL*/
(1 << ts->weightuser)) |
(ts->auto_normalize ? CALC_WP_AUTO_NORMALIZE : 0));
}
static void weightpaint_color(unsigned char r_col[4], DMWeightColorInfo *dm_wcinfo, const float input)
{
float colf[4];
@ -1130,14 +1138,14 @@ void vDM_ColorBand_store(const ColorBand *coba, const char alert_color[4])
* note that we could save some memory and allocate RGB only but then we'd need to
* re-arrange the colors when copying to the face since MCol has odd ordering,
* so leave this as is - campbell */
static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, int const draw_flag, DMWeightColorInfo *dm_wcinfo)
static void calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, int const draw_flag, DMWeightColorInfo *dm_wcinfo,
unsigned char (*r_wtcol_v)[4])
{
MDeformVert *dv = DM_get_vert_data_layer(dm, CD_MDEFORMVERT);
int numVerts = dm->getNumVerts(dm);
unsigned char *wtcol_v = MEM_mallocN(sizeof(unsigned char) * numVerts * 4, "weightmap_v");
if (dv) {
unsigned char *wc = wtcol_v;
unsigned char (*wc)[4] = r_wtcol_v;
unsigned int i;
/* variables for multipaint */
@ -1151,8 +1159,8 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, i
defbase_sel = BKE_objdef_selected_get(ob, defbase_tot, &defbase_sel_tot);
}
for (i = numVerts; i != 0; i--, wc += 4, dv++) {
calc_weightpaint_vert_color(wc, dv, dm_wcinfo, defbase_tot, defbase_act, defbase_sel, defbase_sel_tot, draw_flag);
for (i = numVerts; i != 0; i--, wc++, dv++) {
calc_weightpaint_vert_color((unsigned char *)wc, dv, dm_wcinfo, defbase_tot, defbase_act, defbase_sel, defbase_sel_tot, draw_flag);
}
if (defbase_sel) {
@ -1167,10 +1175,8 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, i
else {
weightpaint_color((unsigned char *)&col_i, dm_wcinfo, 0.0f);
}
fill_vn_i((int *)wtcol_v, numVerts, col_i);
fill_vn_i((int *)r_wtcol_v, numVerts, col_i);
}
return wtcol_v;
}
/* return an array of vertex weight colors from given weights, caller must free.
@ -1178,23 +1184,22 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, i
* note that we could save some memory and allocate RGB only but then we'd need to
* re-arrange the colors when copying to the face since MCol has odd ordering,
* so leave this as is - campbell */
static unsigned char *calc_colors_from_weights_array(const int num, float *weights)
static void calc_colors_from_weights_array(const int num, const float *weights,
unsigned char (*r_wtcol_v)[4])
{
unsigned char *wtcol_v = MEM_mallocN(sizeof(unsigned char) * num * 4, "weightmap_v");
unsigned char *wc = wtcol_v;
unsigned char (*wc)[4] = r_wtcol_v;
int i;
for (i = 0; i < num; i++, wc += 4, weights++)
weightpaint_color((unsigned char *) wc, NULL, *weights);
return wtcol_v;
for (i = 0; i < num; i++, wc++, weights++) {
weightpaint_color((unsigned char *)wc, NULL, *weights);
}
}
void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
float *weights, int num, const int *indices)
{
unsigned char *wtcol_v;
BMEditMesh *em = (dm->type == DM_TYPE_EDITBMESH) ? BMEdit_FromObject(ob) : NULL;
unsigned char (*wtcol_v)[4];
unsigned char(*wtcol_l)[4] = CustomData_get_layer(dm->getLoopDataLayout(dm), CD_PREVIEW_MLOOPCOL);
MLoop *mloop = dm->getLoopArray(dm), *ml;
MPoly *mp = dm->getPolyArray(dm);
@ -1202,6 +1207,20 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
int totloop;
int i, j;
if (em) {
if (em->derivedVertColor && em->derivedVertColorLen == numVerts) {
wtcol_v = em->derivedVertColor;
}
else {
if (em->derivedVertColor) MEM_freeN(em->derivedVertColor);
wtcol_v = em->derivedVertColor = MEM_mallocN(sizeof(*wtcol_v) * numVerts, __func__);
em->derivedVertColorLen = numVerts;
}
}
else {
wtcol_v = MEM_mallocN(sizeof(*wtcol_v) * numVerts, __func__);
}
/* Weights are given by caller. */
if (weights) {
float *w = weights;
@ -1215,46 +1234,51 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
}
/* Convert float weights to colors. */
wtcol_v = calc_colors_from_weights_array(numVerts, w);
calc_colors_from_weights_array(numVerts, w, wtcol_v);
if (indices)
MEM_freeN(w);
}
else {
/* No weights given, take them from active vgroup(s). */
wtcol_v = calc_weightpaint_vert_array(ob, dm, draw_flag, &G_dm_wcinfo);
calc_weightpaint_vert_array(ob, dm, draw_flag, &G_dm_wcinfo, wtcol_v);
}
/* now add to loops, so the data can be passed through the modifier stack */
/* If no CD_PREVIEW_MLOOPCOL existed yet, we have to add a new one! */
if (!wtcol_l) {
BLI_array_declare(wtcol_l);
totloop = 0;
for (i = 0; i < dm->numPolyData; i++, mp++) {
ml = mloop + mp->loopstart;
BLI_array_grow_items(wtcol_l, mp->totloop);
for (j = 0; j < mp->totloop; j++, ml++, totloop++) {
copy_v4_v4_char((char *)&wtcol_l[totloop],
(char *)&wtcol_v[4 * ml->v]);
}
}
CustomData_add_layer(&dm->loopData, CD_PREVIEW_MLOOPCOL, CD_ASSIGN, wtcol_l, totloop);
if (dm->type == DM_TYPE_EDITBMESH) {
/* editmesh draw function checks spesifically for this */
}
else {
totloop = 0;
for (i = 0; i < dm->numPolyData; i++, mp++) {
ml = mloop + mp->loopstart;
/* now add to loops, so the data can be passed through the modifier stack */
/* If no CD_PREVIEW_MLOOPCOL existed yet, we have to add a new one! */
if (!wtcol_l) {
BLI_array_declare(wtcol_l);
totloop = 0;
for (i = 0; i < dm->numPolyData; i++, mp++) {
ml = mloop + mp->loopstart;
for (j = 0; j < mp->totloop; j++, ml++, totloop++) {
copy_v4_v4_char((char *)&wtcol_l[totloop],
(char *)&wtcol_v[4 * ml->v]);
BLI_array_grow_items(wtcol_l, mp->totloop);
for (j = 0; j < mp->totloop; j++, ml++, totloop++) {
copy_v4_v4_char((char *)&wtcol_l[totloop],
(char *)&wtcol_v[ml->v]);
}
}
CustomData_add_layer(&dm->loopData, CD_PREVIEW_MLOOPCOL, CD_ASSIGN, wtcol_l, totloop);
}
else {
totloop = 0;
for (i = 0; i < dm->numPolyData; i++, mp++) {
ml = mloop + mp->loopstart;
for (j = 0; j < mp->totloop; j++, ml++, totloop++) {
copy_v4_v4_char((char *)&wtcol_l[totloop],
(char *)&wtcol_v[ml->v]);
}
}
}
}
MEM_freeN(wtcol_v);
MEM_freeN(wtcol_v);
dm->dirty |= DM_DIRTY_TESS_CDLAYERS;
dm->dirty |= DM_DIRTY_TESS_CDLAYERS;
}
}
@ -1380,11 +1404,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
int has_multires = mmd != NULL, multires_applied = 0;
int sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt;
int sculpt_dyntopo = (sculpt_mode && ob->sculpt->bm);
const int draw_flag = ((scene->toolsettings->multipaint ? CALC_WP_MULTIPAINT :
/* CALC_WP_GROUP_USER_ACTIVE or CALC_WP_GROUP_USER_ALL*/
(1 << scene->toolsettings->weightuser)) |
(scene->toolsettings->auto_normalize ? CALC_WP_AUTO_NORMALIZE : 0));
int draw_flag = dm_drawflag_calc(scene->toolsettings);
/* Generic preview only in object mode! */
const int do_mod_mcol = (ob->mode == OB_MODE_OBJECT);
@ -1909,6 +1929,14 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
int i, numVerts = 0, cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1);
CDMaskLink *datamasks, *curr;
int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
int draw_flag = dm_drawflag_calc(scene->toolsettings);
// const int do_mod_mcol = true; // (ob->mode == OB_MODE_OBJECT);
#if 0 /* XXX Will re-enable this when we have global mod stack options. */
const int do_final_wmcol = (scene->toolsettings->weights_preview == WP_WPREVIEW_FINAL) && do_wmcol;
#endif
const int do_final_wmcol = FALSE;
int do_init_wmcol = ((((Mesh *)ob->data)->drawflag & ME_DRAWEIGHT) && !do_final_wmcol);
modifiers_clearErrors(ob);
@ -1992,6 +2020,10 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
CDDM_apply_vert_coords(dm, deformedVerts);
CDDM_calc_normals(dm);
}
if (do_init_wmcol) {
DM_update_weight_mcol(ob, dm, draw_flag, NULL, 0, NULL);
}
}
/* create an orco derivedmesh in parallel */
@ -2089,11 +2121,19 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
#if 0 // was added for bmesh but is not needed
(*final_r)->calcNormals(*final_r);
#endif
/* In this case, we should never have weight-modifying modifiers in stack... */
if (do_init_wmcol)
DM_update_weight_mcol(ob, *final_r, draw_flag, NULL, 0, NULL);
}
else {
/* this is just a copy of the editmesh, no need to calc normals */
*final_r = getEditDerivedBMesh(em, ob, deformedVerts);
deformedVerts = NULL;
/* In this case, we should never have weight-modifying modifiers in stack... */
if (do_init_wmcol)
DM_update_weight_mcol(ob, *final_r, draw_flag, NULL, 0, NULL);
}
/* --- */

@ -68,6 +68,8 @@
extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */
static void bmdm_get_tri_colpreview(BMLoop *ls[3], MLoopCol *lcol[3], unsigned char(*color_vert_array)[4]);
BMEditMesh *BMEdit_Create(BMesh *bm, const bool do_tessellate)
{
@ -87,6 +89,7 @@ BMEditMesh *BMEdit_Copy(BMEditMesh *em)
*em_copy = *em;
em_copy->derivedCage = em_copy->derivedFinal = NULL;
em_copy->derivedVertColor = NULL;
em_copy->bm = BM_mesh_copy(em->bm);
@ -333,6 +336,8 @@ void BMEdit_Free(BMEditMesh *em)
em->derivedCage = NULL;
}
if (em->derivedVertColor) MEM_freeN(em->derivedVertColor);
if (em->looptris) MEM_freeN(em->looptris);
if (em->vert_index) MEM_freeN(em->vert_index);
@ -606,6 +611,8 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
DMDrawFlag flag)
{
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
BMEditMesh *em = bmdm->tc;
BMesh *bm = em->bm;
BMFace *efa;
struct BMLoop *(*looptris)[3] = bmdm->tc->looptris;
const int tottri = bmdm->tc->tottri;
@ -614,6 +621,11 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
int i, flush;
const int skip_normals = !glIsEnabled(GL_LIGHTING); /* could be passed as an arg */
MLoopCol *lcol[3] = {NULL} /* , dummylcol = {0} */;
unsigned char(*color_vert_array)[4] = (((Mesh *)em->ob->data)->drawflag & ME_DRAWEIGHT) ? em->derivedVertColor : NULL;
bool has_vcol_preview = (color_vert_array != NULL) && !skip_normals;
bool has_vcol_any = has_vcol_preview;
/* GL_ZERO is used to detect if drawing has started or not */
GLenum poly_prev = GL_ZERO;
GLenum shade_prev = GL_ZERO;
@ -623,6 +635,13 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
/* currently unused -- each original face is handled separately */
(void)compareDrawOptions;
/* call again below is ok */
if (has_vcol_preview) {
BM_mesh_elem_index_ensure(bm, BM_VERT);
flag |= DM_DRAW_ALWAYS_SMOOTH;
glDisable(GL_LIGHTING); /* grr */
}
if (bmdm->vertexCos) {
/* add direct access */
float (*vertexCos)[3] = bmdm->vertexCos;
@ -653,13 +672,18 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
glPolygonStipple(stipple_quarttone);
}
if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array);
if (skip_normals) {
if (poly_type != poly_prev) {
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));
glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
}
else {
@ -676,15 +700,21 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
if (!drawSmooth) {
glNormal3fv(polyNos[BM_elem_index_get(efa)]);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
if (has_vcol_any) glColor3ubv((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));
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));
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));
glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]);
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
}
@ -727,13 +757,18 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
glPolygonStipple(stipple_quarttone);
}
if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array);
if (skip_normals) {
if (poly_type != poly_prev) {
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));
glVertex3fv(ltri[0]->v->co);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
glVertex3fv(ltri[1]->v->co);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
glVertex3fv(ltri[2]->v->co);
}
else {
@ -750,15 +785,21 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
if (!drawSmooth) {
glNormal3fv(efa->no);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
glVertex3fv(ltri[0]->v->co);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
glVertex3fv(ltri[1]->v->co);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
glVertex3fv(ltri[2]->v->co);
}
else {
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
glNormal3fv(ltri[0]->v->no);
glVertex3fv(ltri[0]->v->co);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
glNormal3fv(ltri[1]->v->no);
glVertex3fv(ltri[1]->v->co);
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
glNormal3fv(ltri[2]->v->no);
glVertex3fv(ltri[2]->v->co);
}
@ -797,6 +838,13 @@ static void bmdm_get_tri_col(BMLoop *ltri[3], MLoopCol *lcol[3], const int cd_lo
lcol[2] = BM_ELEM_CD_GET_VOID_P(ltri[2], cd_loop_color_offset);
}
static void bmdm_get_tri_colpreview(BMLoop *ls[3], MLoopCol *lcol[3], unsigned char(*color_vert_array)[4])
{
lcol[0] = (MLoopCol *)color_vert_array[BM_elem_index_get(ls[0]->v)];
lcol[1] = (MLoopCol *)color_vert_array[BM_elem_index_get(ls[1]->v)];
lcol[2] = (MLoopCol *)color_vert_array[BM_elem_index_get(ls[2]->v)];
}
static void emDM_drawFacesTex_common(DerivedMesh *dm,
DMSetDrawOptionsTex drawParams,
DMSetDrawOptions drawParamsMapped,
@ -816,8 +864,11 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
const int cd_loop_color_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPCOL);
const int cd_poly_tex_offset = CustomData_get_offset(&bm->pdata, CD_MTEXPOLY);
unsigned char(*color_vert_array)[4] = (((Mesh *)em->ob->data)->drawflag & ME_DRAWEIGHT) ? em->derivedVertColor : NULL;
bool has_uv = (cd_loop_uv_offset != -1);
bool has_vcol = (cd_loop_color_offset != -1);
bool has_vcol_preview = (color_vert_array != NULL);
bool has_vcol = (cd_loop_color_offset != -1) && (has_vcol_preview == false);
bool has_vcol_any = (has_vcol_preview || has_vcol);
int i;
(void) compareDrawOptions;
@ -831,6 +882,11 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
BM_mesh_elem_index_ensure(bm, BM_FACE);
/* call again below is ok */
if (has_vcol_preview) {
BM_mesh_elem_index_ensure(bm, BM_VERT);
}
if (vertexCos) {
BM_mesh_elem_index_ensure(bm, BM_VERT);
@ -857,38 +913,39 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
if (draw_option != DM_DRAW_OPTION_SKIP) {
if (has_uv) bmdm_get_tri_uv(ltri, luv, cd_loop_uv_offset);
if (has_vcol) bmdm_get_tri_col(ltri, lcol, cd_loop_color_offset);
if (has_uv) bmdm_get_tri_uv(ltri, luv, cd_loop_uv_offset);
if (has_vcol) bmdm_get_tri_col(ltri, lcol, cd_loop_color_offset);
else if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array);
glBegin(GL_TRIANGLES);
if (!drawSmooth) {
glNormal3fv(polyNos[BM_elem_index_get(efa)]);
glTexCoord2fv(luv[0]->uv);
if (has_vcol) glColor3ubv((const GLubyte *)&(lcol[0]->r));
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]);
glTexCoord2fv(luv[1]->uv);
if (has_vcol) glColor3ubv((const GLubyte *)&(lcol[1]->r));
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]);
glTexCoord2fv(luv[2]->uv);
if (has_vcol) glColor3ubv((const GLubyte *)&(lcol[2]->r));
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
}
else {
glTexCoord2fv(luv[0]->uv);
if (has_vcol) glColor3ubv((const GLubyte *)&(lcol[0]->r));
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
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) glColor3ubv((const GLubyte *)&(lcol[1]->r));
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
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) glColor3ubv((const GLubyte *)&(lcol[2]->r));
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]);
glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]);
}
@ -922,38 +979,39 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
if (draw_option != DM_DRAW_OPTION_SKIP) {
if (has_uv) bmdm_get_tri_uv(ltri, luv, cd_loop_uv_offset);
if (has_vcol) bmdm_get_tri_col(ltri, lcol, cd_loop_color_offset);
if (has_uv) bmdm_get_tri_uv(ltri, luv, cd_loop_uv_offset);
if (has_vcol) bmdm_get_tri_col(ltri, lcol, cd_loop_color_offset);
else if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array);
glBegin(GL_TRIANGLES);
if (!drawSmooth) {
glNormal3fv(efa->no);
glTexCoord2fv(luv[0]->uv);
if (has_vcol) glColor3ubv((const GLubyte *)&(lcol[0]->r));
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
glVertex3fv(ltri[0]->v->co);
glTexCoord2fv(luv[1]->uv);
if (has_vcol) glColor3ubv((const GLubyte *)&(lcol[1]->r));
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
glVertex3fv(ltri[1]->v->co);
glTexCoord2fv(luv[2]->uv);
if (has_vcol) glColor3ubv((const GLubyte *)&(lcol[2]->r));
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
glVertex3fv(ltri[2]->v->co);
}
else {
glTexCoord2fv(luv[0]->uv);
if (has_vcol) glColor3ubv((const GLubyte *)&(lcol[0]->r));
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r));
glNormal3fv(ltri[0]->v->no);
glVertex3fv(ltri[0]->v->co);
glTexCoord2fv(luv[1]->uv);
if (has_vcol) glColor3ubv((const GLubyte *)&(lcol[1]->r));
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r));
glNormal3fv(ltri[1]->v->no);
glVertex3fv(ltri[1]->v->co);
glTexCoord2fv(luv[2]->uv);
if (has_vcol) glColor3ubv((const GLubyte *)&(lcol[2]->r));
if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r));
glNormal3fv(ltri[2]->v->no);
glVertex3fv(ltri[2]->v->co);
}

@ -187,7 +187,7 @@ typedef struct TFace {
#define ME_DRAWNORMALS (1 << 2)
#define ME_DRAW_VNORMALS (1 << 3)
// #define ME_ALLEDGES (1 << 4)
#define ME_DRAWEIGHT (1 << 4)
#define ME_HIDDENEDGES (1 << 5)
#define ME_DRAWCREASES (1 << 6)

@ -2919,6 +2919,11 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Draw Vertex Normals", "Display vertex normals as lines");
RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
prop = RNA_def_property(srna, "show_weight", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEIGHT);
RNA_def_property_ui_text(prop, "Show Weights", "Draw weights in editmode");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); /* needs to rebuild 'dm' */
prop = RNA_def_property(srna, "show_edge_crease", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWCREASES);
RNA_def_property_ui_text(prop, "Draw Creases", "Display creases created for subsurf weighting");