} drawDMEdgesSel_userData;
typedef struct drawDMFacesSel_userData {
- unsigned char *cols[3];
+ unsigned char *cols[4];
DerivedMesh *dm; /* BMESH BRANCH ONLY */
BMEditMesh *em; /* BMESH BRANCH ONLY */
dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em);
}
+/* Draw only Freestyle feature edges */
+static DMDrawOption draw_dm_edges_freestyle__setDrawOptions(void *userData, int index)
+{
+ BMEdge *eed = EDBM_edge_at_index(userData, index);
+
+ if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_FREESTYLE))
+ return DM_DRAW_OPTION_NORMAL;
+ else
+ return DM_DRAW_OPTION_SKIP;
+}
+
+static void draw_dm_edges_freestyle(BMEditMesh *em, DerivedMesh *dm)
+{
+ dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, em);
+}
/* Draw faces with color set based on selection
* return 2 for the active face so it renders with stipple enabled */
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
if (efa == data->efa_act) {
- glColor4ubv(data->cols[2]);
+ glColor4ubv(data->cols[3]);
return DM_DRAW_OPTION_STIPPLE;
}
else {
- col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0];
+ col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(efa, BM_ELEM_FREESTYLE) ? 2 : 0];
if (col[3] == 0)
return DM_DRAW_OPTION_SKIP;
glColor4ubv(col);
if (efa == data->efa_act || next_efa == data->efa_act)
return 0;
- col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0];
- next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : 0];
+ col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(efa, BM_ELEM_FREESTYLE) ? 2 : 0];
+ next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(next_efa, BM_ELEM_FREESTYLE) ? 2 : 0];
if (col[3] == 0 || next_col[3] == 0)
return 0;
/* also draws the active face */
static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
- unsigned char *selCol, unsigned char *actCol, BMFace *efa_act)
+ unsigned char *selCol, unsigned char *markCol, unsigned char *actCol, BMFace *efa_act)
{
drawDMFacesSel_userData data;
data.dm = dm;
data.cols[0] = baseCol;
data.em = em;
data.cols[1] = selCol;
- data.cols[2] = actCol;
+ data.cols[2] = markCol;
+ data.cols[3] = actCol;
data.efa_act = efa_act;
/* double lookup */
data.orig_index_mf_to_mpoly = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
}
if (me->drawflag & ME_DRAWFACES) { /* transp faces */
- unsigned char col1[4], col2[4], col3[4];
+ unsigned char col1[4], col2[4], col3[4], col4[4];
UI_GetThemeColor4ubv(TH_FACE, col1);
UI_GetThemeColor4ubv(TH_FACE_SELECT, col2);
- UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
+ UI_GetThemeColor4ubv(TH_FREESTYLE_FACE_MARK, col3);
+ UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4);
glEnable(GL_BLEND);
glDepthMask(0); /* disable write in zbuffer, needed for nice transp */
if (check_object_draw_texture(scene, v3d, dt))
col1[3] = 0;
- draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act);
+ if (!(me->drawflag & ME_DRAW_FREESTYLE_FACE))
+ col3[3] = 0;
+
+ draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act);
glDisable(GL_BLEND);
glDepthMask(1); /* restore write in zbuffer */
/* even if draw faces is off it would be nice to draw the stipple face
* Make all other faces zero alpha except for the active
* */
- unsigned char col1[4], col2[4], col3[4];
- col1[3] = col2[3] = 0; /* don't draw */
- UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
+ unsigned char col1[4], col2[4], col3[4], col4[4];
+ col1[3] = col2[3] = col3[3] = 0; /* don't draw */
+ UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4);
glEnable(GL_BLEND);
glDepthMask(0); /* disable write in zbuffer, needed for nice transp */
- draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act);
+ draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act);
glDisable(GL_BLEND);
glDepthMask(1); /* restore write in zbuffer */
glLineWidth(1);
}
+ if(me->drawflag & ME_DRAW_FREESTYLE_EDGE) {
+ UI_ThemeColor(TH_FREESTYLE_EDGE_MARK);
+ glLineWidth(2);
+
+ draw_dm_edges_freestyle(em, cageDM);
+
+ glColor3ub(0,0,0);
+ glLineWidth(1);
+ }
+
if (me->drawflag & ME_DRAWCREASES && CustomData_has_layer(&em->bm->edata, CD_CREASE)) {
draw_dm_creases(em, cageDM);
}