Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/drawobject.c
| Show First 20 Lines • Show All 2,166 Lines • ▼ Show 20 Lines | static void draw_dm_vert_normals(BMEditMesh *em, Scene *scene, Object *ob, DerivedMesh *dm) | ||||
| calcDrawDMNormalScale(ob, &data); | calcDrawDMNormalScale(ob, &data); | ||||
| glBegin(GL_LINES); | glBegin(GL_LINES); | ||||
| dm->foreachMappedVert(dm, draw_dm_vert_normals__mapFunc, &data, DM_FOREACH_USE_NORMAL); | dm->foreachMappedVert(dm, draw_dm_vert_normals__mapFunc, &data, DM_FOREACH_USE_NORMAL); | ||||
| glEnd(); | glEnd(); | ||||
| } | } | ||||
| /* Draw verts with color set based on selection */ | /* Draw verts with color set based on selection */ | ||||
| static void draw_dm_verts__mapFunc(void *userData, int index, const float co[3], | static void draw_dm_verts__mapFunc(void *userData, int index, const float co[3], | ||||
| const float UNUSED(no_f[3]), const short UNUSED(no_s[3])) | const float UNUSED(no_f[3]), const short UNUSED(no_s[3])) | ||||
| { | { | ||||
| drawDMVerts_userData *data = userData; | drawDMVerts_userData *data = userData; | ||||
| BMVert *eve = BM_vert_at_index(data->bm, index); | BMVert *eve = BM_vert_at_index(data->bm, index); | ||||
| if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT) == data->sel) { | if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT) == data->sel) { | ||||
| Show All 24 Lines | if (eve == data->eve_act) { | ||||
| bglVertex3fv(co); | bglVertex3fv(co); | ||||
| bglEnd(); | bglEnd(); | ||||
| glColor4ubv(data->sel ? data->th_vertex_select : data->th_vertex); | glColor4ubv(data->sel ? data->th_vertex_select : data->th_vertex); | ||||
| glPointSize(data->th_vertex_size); | glPointSize(data->th_vertex_size); | ||||
| bglBegin(GL_POINTS); | bglBegin(GL_POINTS); | ||||
| } | } | ||||
| else { | else { | ||||
| bglVertex3fv(co); | bglVertex3fv(co); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void draw_dm_verts(BMEditMesh *em, DerivedMesh *dm, const char sel, BMVert *eve_act, | static void draw_dm_verts(Object *obedit, BMEditMesh *em, DerivedMesh *dm, const char sel, BMVert *eve_act, | ||||
campbellbarton: is obedit arg needed? | |||||
| RegionView3D *rv3d) | RegionView3D *rv3d) | ||||
| { | { | ||||
| drawDMVerts_userData data; | drawDMVerts_userData data; | ||||
| data.sel = sel; | data.sel = sel; | ||||
| data.eve_act = eve_act; | data.eve_act = eve_act; | ||||
| data.bm = em->bm; | data.bm = em->bm; | ||||
| /* Cache theme values */ | /* Cache theme values */ | ||||
| ▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int index, float t) | ||||
| unsigned char *col1 = cols[(BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) ? 2 : 1]; | unsigned char *col1 = cols[(BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) ? 2 : 1]; | ||||
| glColor4ub(col0[0] + (col1[0] - col0[0]) * t, | glColor4ub(col0[0] + (col1[0] - col0[0]) * t, | ||||
| col0[1] + (col1[1] - col0[1]) * t, | col0[1] + (col1[1] - col0[1]) * t, | ||||
| col0[2] + (col1[2] - col0[2]) * t, | col0[2] + (col1[2] - col0[2]) * t, | ||||
| col0[3] + (col1[3] - col0[3]) * t); | col0[3] + (col1[3] - col0[3]) * t); | ||||
| } | } | ||||
| static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol) | static void draw_dm_edges_sel_interp(struct Object *ob, BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, const char dt) | ||||
| { | { | ||||
| void *cols[3] = {em->bm, baseCol, selCol}; | void *cols[3] = {em->bm, baseCol, selCol}; | ||||
| dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, cols); | dm->drawMappedEdgesInterp(ob, dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, cols, dt); | ||||
| } | } | ||||
| /* Draw only seam edges */ | /* Draw only seam edges */ | ||||
| static DMDrawOption draw_dm_edges_seams__setDrawOptions(void *userData, int index) | static DMDrawOption draw_dm_edges_seams__setDrawOptions(void *userData, int index) | ||||
| { | { | ||||
| BMEdge *eed = BM_edge_at_index(userData, index); | BMEdge *eed = BM_edge_at_index(userData, index); | ||||
| if (!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)) | ||||
| ▲ Show 20 Lines • Show All 297 Lines • ▼ Show 20 Lines | for (pass = 0; pass < 2; pass++) { | ||||
| } | } | ||||
| else { | else { | ||||
| col[3] = fcol[3] = 255; | col[3] = fcol[3] = 255; | ||||
| } | } | ||||
| if (ts->selectmode & SCE_SELECT_VERTEX) { | if (ts->selectmode & SCE_SELECT_VERTEX) { | ||||
| glPointSize(size); | glPointSize(size); | ||||
| glColor4ubv(col); | glColor4ubv(col); | ||||
| draw_dm_verts(em, cageDM, sel, eve_act, rv3d); | draw_dm_verts(obedit, em, cageDM, sel, eve_act, rv3d); | ||||
| } | } | ||||
| if (check_ob_drawface_dot(scene, v3d, obedit->dt)) { | if (check_ob_drawface_dot(scene, v3d, obedit->dt)) { | ||||
| glPointSize(fsize); | glPointSize(fsize); | ||||
| glColor4ubv(fcol); | glColor4ubv(fcol); | ||||
| draw_dm_face_centers(em, cageDM, sel); | draw_dm_face_centers(em, cageDM, sel); | ||||
| } | } | ||||
| if (pass == 0) { | if (pass == 0) { | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| glEnable(GL_DEPTH_TEST); | glEnable(GL_DEPTH_TEST); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (v3d->zbuf) glDepthMask(1); | if (v3d->zbuf) glDepthMask(1); | ||||
| glPointSize(1.0); | glPointSize(1.0); | ||||
| } | } | ||||
| static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d, | static void draw_em_fancy_edges(struct Object *ob, | ||||
| BMEditMesh *em, | |||||
| Scene *scene, | |||||
| View3D *v3d, | |||||
| Mesh *me, DerivedMesh *cageDM, short sel_only, | Mesh *me, DerivedMesh *cageDM, short sel_only, | ||||
| BMEdge *eed_act) | BMEdge *eed_act) | ||||
| { | { | ||||
| ToolSettings *ts = scene->toolsettings; | ToolSettings *ts = scene->toolsettings; | ||||
| int pass; | int pass; | ||||
| unsigned char wireCol[4], selCol[4], actCol[4]; | unsigned char wireCol[4], selCol[4], actCol[4]; | ||||
| /* since this function does transparent... */ | /* since this function does transparent... */ | ||||
| Show All 25 Lines | for (pass = 0; pass < 2; pass++) { | ||||
| } | } | ||||
| if (ts->selectmode == SCE_SELECT_FACE) { | if (ts->selectmode == SCE_SELECT_FACE) { | ||||
| draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act); | draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act); | ||||
| } | } | ||||
| else if ((me->drawflag & ME_DRAWEDGES) || (ts->selectmode & SCE_SELECT_EDGE)) { | else if ((me->drawflag & ME_DRAWEDGES) || (ts->selectmode & SCE_SELECT_EDGE)) { | ||||
| if (cageDM->drawMappedEdgesInterp && (ts->selectmode & SCE_SELECT_VERTEX)) { | if (cageDM->drawMappedEdgesInterp && (ts->selectmode & SCE_SELECT_VERTEX)) { | ||||
| glShadeModel(GL_SMOOTH); | glShadeModel(GL_SMOOTH); | ||||
| draw_dm_edges_sel_interp(em, cageDM, wireCol, selCol); | draw_dm_edges_sel_interp(ob, em, cageDM, wireCol, selCol, v3d->drawtype); | ||||
| glShadeModel(GL_FLAT); | glShadeModel(GL_FLAT); | ||||
| } | } | ||||
| else { | else { | ||||
| draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act); | draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (!sel_only) { | if (!sel_only) { | ||||
| ▲ Show 20 Lines • Show All 569 Lines • ▼ Show 20 Lines | #endif | ||||
| } | } | ||||
| /* here starts all fancy draw-extra over */ | /* here starts all fancy draw-extra over */ | ||||
| if ((me->drawflag & ME_DRAWEDGES) == 0 && check_object_draw_texture(scene, v3d, dt)) { | if ((me->drawflag & ME_DRAWEDGES) == 0 && check_object_draw_texture(scene, v3d, dt)) { | ||||
| /* we are drawing textures and 'ME_DRAWEDGES' is disabled, don't draw any edges */ | /* we are drawing textures and 'ME_DRAWEDGES' is disabled, don't draw any edges */ | ||||
| /* only draw selected edges otherwise there is no way of telling if a face is selected */ | /* only draw selected edges otherwise there is no way of telling if a face is selected */ | ||||
| draw_em_fancy_edges(em, scene, v3d, me, cageDM, 1, eed_act); | draw_em_fancy_edges(ob, em, scene, v3d, me, cageDM, 1, eed_act); | ||||
| } | } | ||||
| else { | else { | ||||
| if (me->drawflag & ME_DRAWSEAMS) { | if (me->drawflag & ME_DRAWSEAMS) { | ||||
| UI_ThemeColor(TH_EDGE_SEAM); | UI_ThemeColor(TH_EDGE_SEAM); | ||||
| glLineWidth(2); | glLineWidth(2); | ||||
| draw_dm_edges_seams(em, cageDM); | draw_dm_edges_seams(em, cageDM); | ||||
| Show All 26 Lines | #endif | ||||
| if (me->drawflag & ME_DRAWCREASES) { | if (me->drawflag & ME_DRAWCREASES) { | ||||
| draw_dm_creases(em, cageDM); | draw_dm_creases(em, cageDM); | ||||
| } | } | ||||
| if (me->drawflag & ME_DRAWBWEIGHTS) { | if (me->drawflag & ME_DRAWBWEIGHTS) { | ||||
| draw_dm_bweights(em, scene, cageDM); | draw_dm_bweights(em, scene, cageDM); | ||||
| } | } | ||||
| draw_em_fancy_edges(em, scene, v3d, me, cageDM, 0, eed_act); | draw_em_fancy_edges(ob, em, scene, v3d, me, cageDM, 0, eed_act); | ||||
| } | } | ||||
| { | { | ||||
| draw_em_fancy_verts(scene, v3d, ob, em, cageDM, eve_act, rv3d); | draw_em_fancy_verts(scene, v3d, ob, em, cageDM, eve_act, rv3d); | ||||
| if (me->drawflag & ME_DRAWNORMALS) { | if (me->drawflag & ME_DRAWNORMALS) { | ||||
| UI_ThemeColor(TH_NORMAL); | UI_ThemeColor(TH_NORMAL); | ||||
| draw_dm_face_normals(em, scene, ob, cageDM); | draw_dm_face_normals(em, scene, ob, cageDM); | ||||
| ▲ Show 20 Lines • Show All 4,496 Lines • Show Last 20 Lines | |||||
is obedit arg needed?