From a462d69bbf771e49d2fa49589608c375376b42ed Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Thu, 20 Dec 2012 07:57:26 +0000 Subject: Another big patch set by Bastien Montagne, thanks a lot! * Made Freestyle optional (turned on by default). * Fix for missing bpath.c updates in the previous merge of trunk changes. --- source/blender/editors/space_view3d/CMakeLists.txt | 4 ++ source/blender/editors/space_view3d/SConscript | 3 + source/blender/editors/space_view3d/drawobject.c | 64 +++++++++++++++++----- 3 files changed, 58 insertions(+), 13 deletions(-) (limited to 'source/blender/editors/space_view3d') diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index 35dd88c3209..462619a7e8b 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -75,4 +75,8 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +if(WITH_FREESTYLE) + add_definitions(-DWITH_FREESTYLE) +endif() + blender_add_lib(bf_editor_space_view3d "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_view3d/SConscript b/source/blender/editors/space_view3d/SConscript index 578f06ada16..b775c5bba59 100644 --- a/source/blender/editors/space_view3d/SConscript +++ b/source/blender/editors/space_view3d/SConscript @@ -45,4 +45,7 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', ' if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') +if env['WITH_BF_FREESTYLE']: + defs.append('WITH_FREESTYLE') + env.BlenderLib ( 'bf_editors_space_view3d', sources, Split(incs), defines = defs, libtype=['core'], priority=[40] ) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index fd1eb7852c1..1f071e5f20e 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -126,7 +126,11 @@ typedef struct drawDMEdgesSel_userData { } drawDMEdgesSel_userData; typedef struct drawDMFacesSel_userData { +#ifdef WITH_FREESTYLE unsigned char *cols[4]; +#else + unsigned char *cols[3]; +#endif DerivedMesh *dm; /* BMESH BRANCH ONLY */ BMEditMesh *em; /* BMESH BRANCH ONLY */ @@ -2280,6 +2284,7 @@ static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm) dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em); } +#ifdef WITH_FREESTYLE /* Draw only Freestyle feature edges */ static DMDrawOption draw_dm_edges_freestyle__setDrawOptions(void *userData, int index) { @@ -2295,6 +2300,7 @@ static void draw_dm_edges_freestyle(BMEditMesh *em, DerivedMesh *dm) { dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, em); } +#endif /* Draw faces with color set based on selection * return 2 for the active face so it renders with stipple enabled */ @@ -2309,11 +2315,15 @@ static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index) if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { if (efa == data->efa_act) { - glColor4ubv(data->cols[3]); + glColor4ubv(data->cols[2]); return DM_DRAW_OPTION_STIPPLE; } else { - col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(efa, BM_ELEM_FREESTYLE) ? 2 : 0]; +#ifdef WITH_FREESTYLE + col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(efa, BM_ELEM_FREESTYLE) ? 3 : 0]; +#else + col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0]; +#endif if (col[3] == 0) return DM_DRAW_OPTION_SKIP; glColor4ubv(col); @@ -2344,8 +2354,13 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int if (efa == data->efa_act || next_efa == data->efa_act) return 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]; +#ifdef WITH_FREESTYLE + col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(efa, BM_ELEM_FREESTYLE) ? 3 : 0]; + next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : BM_elem_flag_test(next_efa, BM_ELEM_FREESTYLE) ? 3 : 0]; +#else + 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]; +#endif if (col[3] == 0 || next_col[3] == 0) return 0; @@ -2354,16 +2369,23 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int } /* also draws the active face */ +#ifdef WITH_FREESTYLE static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, - unsigned char *selCol, unsigned char *markCol, unsigned char *actCol, BMFace *efa_act) + unsigned char *selCol, unsigned char *actCol, unsigned char *markCol, BMFace *efa_act) +#else +static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, + unsigned char *selCol, unsigned char *actCol, BMFace *efa_act) +#endif { drawDMFacesSel_userData data; data.dm = dm; data.cols[0] = baseCol; data.em = em; data.cols[1] = selCol; - data.cols[2] = markCol; - data.cols[3] = actCol; + data.cols[2] = actCol; +#ifdef WITH_FREESTYLE + data.cols[3] = markCol; +#endif data.efa_act = efa_act; /* double lookup */ data.orig_index_mf_to_mpoly = DM_get_tessface_data_layer(dm, CD_ORIGINDEX); @@ -2900,12 +2922,17 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, } if (me->drawflag & ME_DRAWFACES) { /* transp faces */ - unsigned char col1[4], col2[4], col3[4], col4[4]; + unsigned char col1[4], col2[4], col3[4]; +#ifdef WITH_FREESTYLE + unsigned char col4[4]; +#endif UI_GetThemeColor4ubv(TH_FACE, col1); UI_GetThemeColor4ubv(TH_FACE_SELECT, col2); - UI_GetThemeColor4ubv(TH_FREESTYLE_FACE_MARK, col3); - UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col4); + UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3); +#ifdef WITH_FREESTYLE + UI_GetThemeColor4ubv(TH_FREESTYLE_FACE_MARK, col4); +#endif glEnable(GL_BLEND); glDepthMask(0); /* disable write in zbuffer, needed for nice transp */ @@ -2914,10 +2941,14 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, if (check_object_draw_texture(scene, v3d, dt)) col1[3] = 0; +#ifdef WITH_FREESTYLE if (!(me->drawflag & ME_DRAW_FREESTYLE_FACE)) - col3[3] = 0; + col4[3] = 0; draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act); +#else + draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act); +#endif glDisable(GL_BLEND); glDepthMask(1); /* restore write in zbuffer */ @@ -2926,14 +2957,19 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, /* 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 * */ + /* col4 is only used by WITH_FREESTYLE, but keeping it here spares some #ifdef's... */ 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); + col1[3] = col2[3] = col4[3] = 0; /* don't draw */ + UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3); glEnable(GL_BLEND); glDepthMask(0); /* disable write in zbuffer, needed for nice transp */ +#ifdef WITH_FREESTYLE draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act); +#else + draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act); +#endif glDisable(GL_BLEND); glDepthMask(1); /* restore write in zbuffer */ @@ -2969,6 +3005,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, glLineWidth(1); } +#ifdef WITH_FREESTYLE if(me->drawflag & ME_DRAW_FREESTYLE_EDGE) { UI_ThemeColor(TH_FREESTYLE_EDGE_MARK); glLineWidth(2); @@ -2978,6 +3015,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, glColor3ub(0,0,0); glLineWidth(1); } +#endif if (me->drawflag & ME_DRAWCREASES && CustomData_has_layer(&em->bm->edata, CD_CREASE)) { draw_dm_creases(em, cageDM); -- cgit v1.2.3