diff options
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 75 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 109 |
2 files changed, 105 insertions, 79 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index fabd3f92573..32f2d1bab9f 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -139,7 +139,7 @@ static EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me) } -static int draw_mesh_face_select__setHiddenOpts(void *userData, int index) +static DMDrawOption draw_mesh_face_select__setHiddenOpts(void *userData, int index) { drawMeshFaceSelect_userData *data = userData; Mesh *me= data->me; @@ -147,34 +147,36 @@ static int draw_mesh_face_select__setHiddenOpts(void *userData, int index) uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2); if (me->drawflag & ME_DRAWEDGES) { - if (me->drawflag & ME_HIDDENEDGES) - return 1; + if ((me->drawflag & ME_HIDDENEDGES) || (flags & eEdge_Visible)) + return DM_DRAW_OPTION_NORMAL; else - return (flags & eEdge_Visible); + return DM_DRAW_OPTION_SKIP; } + else if(flags & eEdge_Select) + return DM_DRAW_OPTION_NORMAL; else - return (flags & eEdge_Select); + return DM_DRAW_OPTION_SKIP; } -static int draw_mesh_face_select__setSelectOpts(void *userData, int index) +static DMDrawOption draw_mesh_face_select__setSelectOpts(void *userData, int index) { drawMeshFaceSelect_userData *data = userData; MEdge *med = &data->me->medge[index]; uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2); - return flags & eEdge_Select; + return (flags & eEdge_Select) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP; } /* draws unselected */ -static int draw_mesh_face_select__drawFaceOptsInv(void *userData, int index) +static DMDrawOption draw_mesh_face_select__drawFaceOptsInv(void *userData, int index) { Mesh *me = (Mesh*)userData; MPoly *mface = &me->mpoly[index]; if (!(mface->flag&ME_HIDE) && !(mface->flag&ME_FACE_SEL)) - return 2; /* Don't set color */ + return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */ else - return 0; + return DM_DRAW_OPTION_SKIP; } static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm) @@ -388,22 +390,23 @@ static void draw_textured_end(void) glPopMatrix(); } -static int draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int matnr) +static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int matnr) { Material *ma= give_current_material(Gtexdraw.ob, matnr+1); int validtexture=0; - if (ma && (ma->game.flag & GEMAT_INVISIBLE)) return 0; + if (ma && (ma->game.flag & GEMAT_INVISIBLE)) + return DM_DRAW_OPTION_SKIP; validtexture = set_draw_settings_cached(0, tface, ma, Gtexdraw); if (tface && validtexture) { glColor3ub(0xFF, 0x00, 0xFF); - return 2; /* Don't set color */ + return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */ } else if (ma && ma->shade_flag&MA_OBCOLOR) { glColor3ubv(Gtexdraw.obcol); - return 2; /* Don't set color */ + return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */ } else if (!has_mcol) { if (tface) glColor3f(1.0, 1.0, 1.0); @@ -417,36 +420,39 @@ static int draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int matnr) } else glColor3f(1.0, 1.0, 1.0); } - return 2; /* Don't set color */ + return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */ } else { - return 1; /* Set color from mcol */ + return DM_DRAW_OPTION_NORMAL; /* Set color from mcol */ } } -static int draw_mcol__set_draw_legacy(MTFace *UNUSED(tface), int has_mcol, int UNUSED(matnr)) +static DMDrawOption draw_mcol__set_draw_legacy(MTFace *UNUSED(tface), int has_mcol, int UNUSED(matnr)) { - if (has_mcol) return 1; - else return 2; + if (has_mcol) + return DM_DRAW_OPTION_NORMAL; + else + return DM_DRAW_OPTION_NO_MCOL; } -static int draw_tface__set_draw(MTFace *tface, int has_mcol, int matnr) +static DMDrawOption draw_tface__set_draw(MTFace *tface, int has_mcol, int matnr) { Material *ma= give_current_material(Gtexdraw.ob, matnr+1); if (ma && (ma->game.flag & GEMAT_INVISIBLE)) return 0; if (tface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) { - return 2; /* Don't set color */ + return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */ } else if (tface && tface->mode&TF_OBCOL) { - return 2; /* Don't set color */ + return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */ } else if (!has_mcol) { - return 1; /* Don't set color */ + /* XXX: this return value looks wrong (and doesn't match comment) */ + return DM_DRAW_OPTION_NORMAL; /* Don't set color */ } else { - return 1; /* Set color from mcol */ + return DM_DRAW_OPTION_NORMAL; /* Set color from mcol */ } } static void add_tface_color_layer(DerivedMesh *dm) @@ -528,7 +534,7 @@ static void add_tface_color_layer(DerivedMesh *dm) CustomData_add_layer( &dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numTessFaceData ); } -static int draw_tface_mapped__set_draw(void *userData, int index) +static DMDrawOption draw_tface_mapped__set_draw(void *userData, int index) { Mesh *me = (Mesh *)userData; @@ -538,7 +544,7 @@ static int draw_tface_mapped__set_draw(void *userData, int index) BLI_assert(index >= 0 && index < me->totpoly); if (mpoly->flag & ME_HIDE) { - return 0; + return DM_DRAW_OPTION_SKIP; } else { MTexPoly *tpoly = (me->mtpoly) ? &me->mtpoly[index] : NULL; @@ -553,14 +559,14 @@ static int draw_tface_mapped__set_draw(void *userData, int index) } } -static int draw_em_tf_mapped__set_draw(void *userData, int index) +static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int index) { drawEMTFMapped_userData *data = userData; BMEditMesh *em = data->em; BMFace *efa= EDBM_get_face_for_index(em, index); if (efa==NULL || BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { - return 0; + return DM_DRAW_OPTION_SKIP; } else { MTFace mtf= {{{0}}}; @@ -576,27 +582,28 @@ static int draw_em_tf_mapped__set_draw(void *userData, int index) } } -static int wpaint__setSolidDrawOptions_material(void *userData, int index) +static DMDrawOption wpaint__setSolidDrawOptions_material(void *userData, int index) { Mesh *me = (Mesh*)userData; if (me->mat && me->mpoly) { Material *ma= me->mat[me->mpoly[index].mat_nr]; if (ma && (ma->game.flag & GEMAT_INVISIBLE)) { - return 0; + return DM_DRAW_OPTION_SKIP; } } - return 1; + return DM_DRAW_OPTION_NORMAL; } /* when face select is on, use face hidden flag */ -static int wpaint__setSolidDrawOptions_facemask(void *userData, int index) +static DMDrawOption wpaint__setSolidDrawOptions_facemask(void *userData, int index) { Mesh *me = (Mesh*)userData; MPoly *mp = &me->mpoly[index]; - if (mp->flag & ME_HIDE) return 0; - return 1; + if (mp->flag & ME_HIDE) + return DM_DRAW_OPTION_SKIP; + return DM_DRAW_OPTION_NORMAL; } static void draw_mesh_text(Scene *scene, Object *ob, int glsl) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index aad6530f049..9dd9636a271 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2375,7 +2375,7 @@ static void draw_dm_verts(BMEditMesh *em, DerivedMesh *dm, int sel, BMVert *eve_ } /* Draw edges with color set based on selection */ -static int draw_dm_edges_sel__setDrawOptions(void *userData, int index) +static DMDrawOption draw_dm_edges_sel__setDrawOptions(void *userData, int index) { BMEdge *eed; //unsigned char **cols = userData, *col; @@ -2396,14 +2396,15 @@ static int draw_dm_edges_sel__setDrawOptions(void *userData, int index) col = data->baseCol; } /* no alpha, this is used so a transparent color can disable drawing unselected edges in editmode */ - if (col[3]==0) return 0; + if (col[3]==0) + return DM_DRAW_OPTION_SKIP; glColor4ubv(col); } - return 1; + return DM_DRAW_OPTION_NORMAL; } else { - return 0; + return DM_DRAW_OPTION_SKIP; } } static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, @@ -2420,19 +2421,26 @@ static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba } /* Draw edges */ -static int draw_dm_edges__setDrawOptions(void *userData, int index) +static DMDrawOption draw_dm_edges__setDrawOptions(void *userData, int index) { - return !BM_elem_flag_test(EDBM_get_edge_for_index(userData, index), BM_ELEM_HIDDEN); + if (BM_elem_flag_test(EDBM_get_edge_for_index(userData, index), BM_ELEM_HIDDEN)) + return DM_DRAW_OPTION_SKIP; + else + return DM_DRAW_OPTION_NORMAL; } + static void draw_dm_edges(BMEditMesh *em, DerivedMesh *dm) { dm->drawMappedEdges(dm, draw_dm_edges__setDrawOptions, em); } /* Draw edges with color interpolated based on selection */ -static int draw_dm_edges_sel_interp__setDrawOptions(void *userData, int index) +static DMDrawOption draw_dm_edges_sel_interp__setDrawOptions(void *userData, int index) { - return !BM_elem_flag_test(EDBM_get_edge_for_index(((void**)userData)[0], index), BM_ELEM_HIDDEN); + if (BM_elem_flag_test(EDBM_get_edge_for_index(((void**)userData)[0], index), BM_ELEM_HIDDEN)) + return DM_DRAW_OPTION_SKIP; + else + return DM_DRAW_OPTION_NORMAL; } static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int index, float t) { @@ -2455,11 +2463,14 @@ static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned c } /* Draw only seam edges */ -static int draw_dm_edges_seams__setDrawOptions(void *userData, int index) +static DMDrawOption draw_dm_edges_seams__setDrawOptions(void *userData, int index) { BMEdge *eed = EDBM_get_edge_for_index(userData, index); - return !BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SEAM); + if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SEAM)) + return DM_DRAW_OPTION_NORMAL; + else + return DM_DRAW_OPTION_SKIP; } static void draw_dm_edges_seams(BMEditMesh *em, DerivedMesh *dm) @@ -2468,12 +2479,16 @@ static void draw_dm_edges_seams(BMEditMesh *em, DerivedMesh *dm) } /* Draw only sharp edges */ -static int draw_dm_edges_sharp__setDrawOptions(void *userData, int index) +static DMDrawOption draw_dm_edges_sharp__setDrawOptions(void *userData, int index) { BMEdge *eed = EDBM_get_edge_for_index(userData, index); - return !BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && !BM_elem_flag_test(eed, BM_ELEM_SMOOTH); + if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && !BM_elem_flag_test(eed, BM_ELEM_SMOOTH)) + return DM_DRAW_OPTION_NORMAL; + else + return DM_DRAW_OPTION_SKIP; } + static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm) { dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em); @@ -2482,28 +2497,29 @@ static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm) /* Draw faces with color set based on selection * return 2 for the active face so it renders with stipple enabled */ -static int draw_dm_faces_sel__setDrawOptions(void *userData, int index) +static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index) { drawDMFacesSel_userData * data = userData; BMFace *efa = EDBM_get_face_for_index(data->em, index); unsigned char *col; if (!efa) - return 0; + return DM_DRAW_OPTION_SKIP; if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { if (efa == data->efa_act) { glColor4ubv(data->cols[2]); - return 2; /* stipple */ + return DM_DRAW_OPTION_STIPPLE; } else { col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT)?1:0]; - if (col[3]==0) return 0; + if (col[3]==0) + return DM_DRAW_OPTION_SKIP; glColor4ubv(col); - return 1; + return DM_DRAW_OPTION_NORMAL; } } - return 0; + return DM_DRAW_OPTION_SKIP; } static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int next_index) @@ -2552,21 +2568,21 @@ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, GPU_enable_material, draw_dm_faces_sel__compareDrawOptions, &data, 0); } -static int draw_dm_creases__setDrawOptions(void *userData, int index) +static DMDrawOption draw_dm_creases__setDrawOptions(void *userData, int index) { BMEditMesh *em = userData; BMEdge *eed = EDBM_get_edge_for_index(userData, index); float *crease = eed ? (float *)CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE) : NULL; if (!crease) - return 0; + return DM_DRAW_OPTION_SKIP; if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && *crease!=0.0f) { UI_ThemeColorBlend(TH_WIRE, TH_EDGE_CREASE, *crease); - return 1; + return DM_DRAW_OPTION_NORMAL; } else { - return 0; + return DM_DRAW_OPTION_SKIP; } } static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm) @@ -2576,21 +2592,21 @@ static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm) glLineWidth(1.0); } -static int draw_dm_bweights__setDrawOptions(void *userData, int index) +static DMDrawOption draw_dm_bweights__setDrawOptions(void *userData, int index) { BMEditMesh *em = userData; BMEdge *eed = EDBM_get_edge_for_index(userData, index); float *bweight = (float *)CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT); if (!bweight) - return 0; + return DM_DRAW_OPTION_SKIP; if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && *bweight!=0.0f) { UI_ThemeColorBlend(TH_WIRE, TH_EDGE_SELECT, *bweight); - return 1; + return DM_DRAW_OPTION_NORMAL; } else { - return 0; + return DM_DRAW_OPTION_SKIP; } } static void draw_dm_bweights__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s)) @@ -2965,23 +2981,26 @@ static void draw_em_indices(BMEditMesh *em) } } -static int draw_em_fancy__setFaceOpts(void *userData, int index) +static DMDrawOption draw_em_fancy__setFaceOpts(void *userData, int index) { BMFace *efa = EDBM_get_face_for_index(userData, index); if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { GPU_enable_material(efa->mat_nr+1, NULL); - return 1; + return DM_DRAW_OPTION_NORMAL; } else - return 0; + return DM_DRAW_OPTION_SKIP; } -static int draw_em_fancy__setGLSLFaceOpts(void *userData, int index) +static DMDrawOption draw_em_fancy__setGLSLFaceOpts(void *userData, int index) { BMFace *efa = EDBM_get_face_for_index(userData, index); - return !BM_elem_flag_test(efa, BM_ELEM_HIDDEN); + if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) + return DM_DRAW_OPTION_SKIP; + else + return DM_DRAW_OPTION_NORMAL; } static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, @@ -7125,7 +7144,7 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset) glPointSize(1.0); } -static int bbs_mesh_wire__setDrawOptions(void *userData, int index) +static DMDrawOption bbs_mesh_wire__setDrawOptions(void *userData, int index) { void **ptrs = userData; int offset = (intptr_t) ptrs[0]; @@ -7133,10 +7152,10 @@ static int bbs_mesh_wire__setDrawOptions(void *userData, int index) if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { WM_set_framebuffer_index_color(offset+index); - return 1; + return DM_DRAW_OPTION_NORMAL; } else { - return 0; + return DM_DRAW_OPTION_SKIP; } } static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset) @@ -7145,7 +7164,7 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset) dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOptions, ptrs); } -static int bbs_mesh_solid__setSolidDrawOptions(void *userData, int index) +static DMDrawOption bbs_mesh_solid__setSolidDrawOptions(void *userData, int index) { BMFace *efa = EDBM_get_face_for_index(((void**)userData)[0], index); @@ -7153,10 +7172,10 @@ static int bbs_mesh_solid__setSolidDrawOptions(void *userData, int index) if (((void**)userData)[1]) { WM_set_framebuffer_index_color(index+1); } - return 1; + return DM_DRAW_OPTION_NORMAL; } else { - return 0; + return DM_DRAW_OPTION_SKIP; } } @@ -7196,35 +7215,35 @@ static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d, } } -static int bbs_mesh_solid__setDrawOpts(void *UNUSED(userData), int index) +static DMDrawOption bbs_mesh_solid__setDrawOpts(void *UNUSED(userData), int index) { WM_set_framebuffer_index_color(index+1); - return 1; + return DM_DRAW_OPTION_NORMAL; } -static int bbs_mesh_solid_hide__setDrawOpts(void *userData, int index) +static DMDrawOption bbs_mesh_solid_hide__setDrawOpts(void *userData, int index) { Mesh *me = userData; if (!(me->mpoly[index].flag&ME_HIDE)) { WM_set_framebuffer_index_color(index+1); - return 1; + return DM_DRAW_OPTION_NORMAL; } else { - return 0; + return DM_DRAW_OPTION_SKIP; } } // must have called WM_set_framebuffer_index_color beforehand -static int bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index) +static DMDrawOption bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index) { Mesh *me = userData; if (!(me->mpoly[index].flag & ME_HIDE)) { - return 1; + return DM_DRAW_OPTION_NORMAL; } else { - return 0; + return DM_DRAW_OPTION_SKIP; } } static void bbs_mesh_solid(Scene *scene, Object *ob) |