Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/drawobject.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
| #include "BIF_glutil.h" | #include "BIF_glutil.h" | ||||
| #include "GPU_draw.h" | #include "GPU_draw.h" | ||||
| #include "GPU_select.h" | #include "GPU_select.h" | ||||
| #include "GPU_basic_shader.h" | #include "GPU_basic_shader.h" | ||||
| #include "GPU_legacy_stubs.h" | |||||
| #include "GPU_shader.h" | #include "GPU_shader.h" | ||||
| #include "GPU_immediate.h" | #include "GPU_immediate.h" | ||||
| #include "GPU_immediate_util.h" | #include "GPU_immediate_util.h" | ||||
| #include "GPU_batch.h" | #include "GPU_batch.h" | ||||
| #include "GPU_matrix.h" | #include "GPU_matrix.h" | ||||
| #include "ED_mesh.h" | #include "ED_mesh.h" | ||||
| #include "ED_particle.h" | #include "ED_particle.h" | ||||
| ▲ Show 20 Lines • Show All 417 Lines • ▼ Show 20 Lines | for (int i = 0; i < n; i++) { | ||||
| add_v3_v3(buffer[i], c); | add_v3_v3(buffer[i], c); | ||||
| immVertex3fv(pos, buffer[i]); | immVertex3fv(pos, buffer[i]); | ||||
| } | } | ||||
| immEnd(); | immEnd(); | ||||
| /* TODO: recode this function for clarity once we're not in a hurry to modernize GL usage */ | /* TODO: recode this function for clarity once we're not in a hurry to modernize GL usage */ | ||||
| #if 0 | #if 0 | ||||
| glEnableClientState(GL_VERTEX_ARRAY); | oldEnableClientState(GL_VERTEX_ARRAY); | ||||
| glVertexPointer(3, GL_FLOAT, 0, buffer); | oldVertexPointer(3, GL_FLOAT, 0, buffer); | ||||
| glDrawArrays(line_type, 0, n); | glDrawArrays(line_type, 0, n); | ||||
| glDisableClientState(GL_VERTEX_ARRAY); | oldDisableClientState(GL_VERTEX_ARRAY); | ||||
| #endif | #endif | ||||
| } | } | ||||
| void drawaxes(const float viewmat_local[4][4], float size, char drawtype, const unsigned char color[4]) | void drawaxes(const float viewmat_local[4][4], float size, char drawtype, const unsigned char color[4]) | ||||
| { | { | ||||
| int axis; | int axis; | ||||
| float v1[3] = {0.0, 0.0, 0.0}; | float v1[3] = {0.0, 0.0, 0.0}; | ||||
| float v2[3] = {0.0, 0.0, 0.0}; | float v2[3] = {0.0, 0.0, 0.0}; | ||||
| ▲ Show 20 Lines • Show All 409 Lines • ▼ Show 20 Lines | if (tot) { | ||||
| } | } | ||||
| else { | else { | ||||
| glDepthMask(GL_FALSE); | glDepthMask(GL_FALSE); | ||||
| } | } | ||||
| for (vos = g_v3d_strings[g_v3d_string_level]; vos; vos = vos->next) { | for (vos = g_v3d_strings[g_v3d_string_level]; vos; vos = vos->next) { | ||||
| if (vos->sco[0] != IS_CLIPPED) { | if (vos->sco[0] != IS_CLIPPED) { | ||||
| if (col_pack_prev != vos->col.pack) { | if (col_pack_prev != vos->col.pack) { | ||||
| //glColor3ubv(vos->col.ub); | //oldColor3ubv(vos->col.ub); | ||||
| col_pack_prev = vos->col.pack; | col_pack_prev = vos->col.pack; | ||||
| } | } | ||||
| ((vos->flag & V3D_CACHE_TEXT_ASCII) ? | ((vos->flag & V3D_CACHE_TEXT_ASCII) ? | ||||
| BLF_draw_default_ascii : | BLF_draw_default_ascii : | ||||
| BLF_draw_default | BLF_draw_default | ||||
| )((float)(vos->sco[0] + vos->xoffs), | )((float)(vos->sco[0] + vos->xoffs), | ||||
| (float)(vos->sco[1]), | (float)(vos->sco[1]), | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | const GLfloat verts[8][3] = { | ||||
| { size, -size, size}, | { size, -size, size}, | ||||
| { size, size, -size}, | { size, size, -size}, | ||||
| { size, size, size} | { size, size, size} | ||||
| }; | }; | ||||
| const GLubyte indices[24] = {0,1,1,3,3,2,2,0,0,4,4,5,5,7,7,6,6,4,1,5,3,7,2,6}; | const GLubyte indices[24] = {0,1,1,3,3,2,2,0,0,4,4,5,5,7,7,6,6,4,1,5,3,7,2,6}; | ||||
| #if 0 | #if 0 | ||||
| glEnableClientState(GL_VERTEX_ARRAY); | oldEnableClientState(GL_VERTEX_ARRAY); | ||||
| glVertexPointer(3, GL_FLOAT, 0, verts); | oldVertexPointer(3, GL_FLOAT, 0, verts); | ||||
| glDrawRangeElements(GL_LINES, 0, 7, 24, GL_UNSIGNED_BYTE, indices); | glDrawRangeElements(GL_LINES, 0, 7, 24, GL_UNSIGNED_BYTE, indices); | ||||
| glDisableClientState(GL_VERTEX_ARRAY); | oldDisableClientState(GL_VERTEX_ARRAY); | ||||
| #else | #else | ||||
| immBegin(GL_LINES, 24); | immBegin(GL_LINES, 24); | ||||
| for (int i = 0; i < 24; ++i) { | for (int i = 0; i < 24; ++i) { | ||||
| immVertex3fv(pos, verts[indices[i]]); | immVertex3fv(pos, verts[indices[i]]); | ||||
| } | } | ||||
| immEnd(); | immEnd(); | ||||
| #endif | #endif | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 974 Lines • ▼ Show 20 Lines | for (int i = 0; i < 2; i++) { | ||||
| } | } | ||||
| } | } | ||||
| /* the remaining drawing takes place in the view space */ | /* the remaining drawing takes place in the view space */ | ||||
| gpuLoadMatrix3D(rv3d->viewmat); | gpuLoadMatrix3D(rv3d->viewmat); | ||||
| if (is_stereo3d_cameras) { | if (is_stereo3d_cameras) { | ||||
| /* draw connecting lines */ | /* draw connecting lines */ | ||||
| glLineStipple(2, 0xAAAA); | oldLineStipple(2, 0xAAAA); | ||||
| glEnable(GL_LINE_STIPPLE); | oldEnable(GL_LINE_STIPPLE); | ||||
| immBegin(GL_LINES, 2); | immBegin(GL_LINES, 2); | ||||
| immVertex3fv(pos, origin[0]); | immVertex3fv(pos, origin[0]); | ||||
| immVertex3fv(pos, origin[1]); | immVertex3fv(pos, origin[1]); | ||||
| immEnd(); | immEnd(); | ||||
| glDisable(GL_LINE_STIPPLE); | oldDisable(GL_LINE_STIPPLE); | ||||
| } | } | ||||
| /* draw convergence plane */ | /* draw convergence plane */ | ||||
| if (is_stereo3d_plane) { | if (is_stereo3d_plane) { | ||||
| float axis_center[3], screen_center[3]; | float axis_center[3], screen_center[3]; | ||||
| float world_plane[4][3]; | float world_plane[4][3]; | ||||
| float local_plane[4][3]; | float local_plane[4][3]; | ||||
| float offset; | float offset; | ||||
| ▲ Show 20 Lines • Show All 798 Lines • ▼ Show 20 Lines | static DMDrawOption draw_dm_edges_sel__setDrawOptions(void *userData, int index) | ||||
| BMEdge *eed; | BMEdge *eed; | ||||
| drawDMEdgesSel_userData *data = userData; | drawDMEdgesSel_userData *data = userData; | ||||
| unsigned char *col; | unsigned char *col; | ||||
| eed = BM_edge_at_index(data->bm, index); | eed = BM_edge_at_index(data->bm, index); | ||||
| if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { | if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { | ||||
| if (eed == data->eed_act) { | if (eed == data->eed_act) { | ||||
| glColor4ubv(data->actCol); | oldColor4ubv(data->actCol); | ||||
| } | } | ||||
| else { | else { | ||||
| if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { | if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { | ||||
| col = data->selCol; | col = data->selCol; | ||||
| } | } | ||||
| else { | else { | ||||
| col = data->baseCol; | col = data->baseCol; | ||||
| } | } | ||||
| /* no alpha, this is used so a transparent color can disable drawing unselected edges in editmode */ | /* no alpha, this is used so a transparent color can disable drawing unselected edges in editmode */ | ||||
| if (col[3] == 0) | if (col[3] == 0) | ||||
| return DM_DRAW_OPTION_SKIP; | return DM_DRAW_OPTION_SKIP; | ||||
| glColor4ubv(col); | oldColor4ubv(col); | ||||
| } | } | ||||
| return DM_DRAW_OPTION_NORMAL; | return DM_DRAW_OPTION_NORMAL; | ||||
| } | } | ||||
| else { | else { | ||||
| return DM_DRAW_OPTION_SKIP; | return DM_DRAW_OPTION_SKIP; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | else if (t == 0.0f) { | ||||
| col_pt = col0; | col_pt = col0; | ||||
| } | } | ||||
| else if (t == 1.0f) { | else if (t == 1.0f) { | ||||
| col_pt = col1; | col_pt = col1; | ||||
| } | } | ||||
| else { | else { | ||||
| unsigned char col_blend[4]; | unsigned char col_blend[4]; | ||||
| interp_v4_v4v4_uchar(col_blend, col0, col1, t); | interp_v4_v4v4_uchar(col_blend, col0, col1, t); | ||||
| glColor4ubv(col_blend); | oldColor4ubv(col_blend); | ||||
| data->lastCol = NULL; | data->lastCol = NULL; | ||||
| return; | return; | ||||
| } | } | ||||
| if (data->lastCol != col_pt) { | if (data->lastCol != col_pt) { | ||||
| data->lastCol = col_pt; | data->lastCol = col_pt; | ||||
| glColor4ubv(col_pt); | oldColor4ubv(col_pt); | ||||
| } | } | ||||
| } | } | ||||
| static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol) | static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol) | ||||
| { | { | ||||
| drawDMEdgesSelInterp_userData data; | drawDMEdgesSelInterp_userData data; | ||||
| data.bm = em->bm; | data.bm = em->bm; | ||||
| data.baseCol = baseCol; | data.baseCol = baseCol; | ||||
| Show All 40 Lines | else { | ||||
| float col_v1[3]; | float col_v1[3]; | ||||
| float col_v2[3]; | float col_v2[3]; | ||||
| bm_color_from_weight(col_v1, eed->v1, data); | bm_color_from_weight(col_v1, eed->v1, data); | ||||
| bm_color_from_weight(col_v2, eed->v2, data); | bm_color_from_weight(col_v2, eed->v2, data); | ||||
| interp_v3_v3v3(col, col_v1, col_v2, t); | interp_v3_v3v3(col, col_v1, col_v2, t); | ||||
| } | } | ||||
| glColor3fv(col); | oldColor3fv(col); | ||||
| } | } | ||||
| static void draw_dm_edges_weight_interp(BMEditMesh *em, DerivedMesh *dm, const char weight_user) | static void draw_dm_edges_weight_interp(BMEditMesh *em, DerivedMesh *dm, const char weight_user) | ||||
| { | { | ||||
| drawDMEdgesWeightInterp_userData data; | drawDMEdgesWeightInterp_userData data; | ||||
| Object *ob = em->ob; | Object *ob = em->ob; | ||||
| data.bm = em->bm; | data.bm = em->bm; | ||||
| Show All 16 Lines | else { | ||||
| float col[3]; | float col[3]; | ||||
| if (data.weight_user == OB_DRAW_GROUPUSER_NONE) { | if (data.weight_user == OB_DRAW_GROUPUSER_NONE) { | ||||
| weight_to_rgb(col, 0.0f); | weight_to_rgb(col, 0.0f); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(col, data.alert_color); | copy_v3_v3(col, data.alert_color); | ||||
| } | } | ||||
| glColor3fv(col); | oldColor3fv(col); | ||||
| dm->drawMappedEdgesInterp( | dm->drawMappedEdgesInterp( | ||||
| dm, | dm, | ||||
| draw_dm_edges_sel_interp__setDrawOptions, | draw_dm_edges_sel_interp__setDrawOptions, | ||||
| draw_dm_edges_nop_interp__setDrawInterpOptions, | draw_dm_edges_nop_interp__setDrawInterpOptions, | ||||
| &data); | &data); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | |||||
| static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index) | static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index) | ||||
| { | { | ||||
| drawDMFacesSel_userData *data = userData; | drawDMFacesSel_userData *data = userData; | ||||
| BMFace *efa = BM_face_at_index(data->bm, index); | BMFace *efa = BM_face_at_index(data->bm, index); | ||||
| unsigned char *col; | unsigned char *col; | ||||
| if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { | if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { | ||||
| if (efa == data->efa_act) { | if (efa == data->efa_act) { | ||||
| glColor4ubv(data->cols[2]); | oldColor4ubv(data->cols[2]); | ||||
| return DM_DRAW_OPTION_STIPPLE; | return DM_DRAW_OPTION_STIPPLE; | ||||
| } | } | ||||
| else { | else { | ||||
| #ifdef WITH_FREESTYLE | #ifdef WITH_FREESTYLE | ||||
| col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->bm, efa) ? 3 : 0]; | col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->bm, efa) ? 3 : 0]; | ||||
| #else | #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 : 0]; | ||||
| #endif | #endif | ||||
| if (col[3] == 0) | if (col[3] == 0) | ||||
| return DM_DRAW_OPTION_SKIP; | return DM_DRAW_OPTION_SKIP; | ||||
| glColor4ubv(col); | oldColor4ubv(col); | ||||
| return DM_DRAW_OPTION_NORMAL; | return DM_DRAW_OPTION_NORMAL; | ||||
| } | } | ||||
| } | } | ||||
| return DM_DRAW_OPTION_SKIP; | return DM_DRAW_OPTION_SKIP; | ||||
| } | } | ||||
| static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int next_index) | static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int next_index) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | if ((me->drawflag & ME_DRAWEDGES) || (ts->selectmode & SCE_SELECT_EDGE)) { | ||||
| } | } | ||||
| } | } | ||||
| 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) { | ||||
| glColor4ubv(wireCol); | oldColor4ubv(wireCol); | ||||
| draw_dm_edges(em, cageDM); | draw_dm_edges(em, cageDM); | ||||
| } | } | ||||
| } | } | ||||
| if (pass == 0) { | if (pass == 0) { | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| glEnable(GL_DEPTH_TEST); | glEnable(GL_DEPTH_TEST); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 569 Lines • ▼ Show 20 Lines | #endif | ||||
| } | } | ||||
| else { | else { | ||||
| if (me->drawflag & ME_DRAWSEAMS) { | if (me->drawflag & ME_DRAWSEAMS) { | ||||
| UI_ThemeColor(TH_EDGE_SEAM); | UI_ThemeColor(TH_EDGE_SEAM); | ||||
| glLineWidth(2.0f); | glLineWidth(2.0f); | ||||
| draw_dm_edges_seams(em, cageDM); | draw_dm_edges_seams(em, cageDM); | ||||
| glColor3ub(0, 0, 0); | oldColor3ub(0, 0, 0); | ||||
| } | } | ||||
| if (me->drawflag & ME_DRAWSHARP) { | if (me->drawflag & ME_DRAWSHARP) { | ||||
| UI_ThemeColor(TH_EDGE_SHARP); | UI_ThemeColor(TH_EDGE_SHARP); | ||||
| glLineWidth(2.0f); | glLineWidth(2.0f); | ||||
| draw_dm_edges_sharp(em, cageDM); | draw_dm_edges_sharp(em, cageDM); | ||||
| glColor3ub(0, 0, 0); | oldColor3ub(0, 0, 0); | ||||
| } | } | ||||
| #ifdef WITH_FREESTYLE | #ifdef WITH_FREESTYLE | ||||
| if (me->drawflag & ME_DRAW_FREESTYLE_EDGE && CustomData_has_layer(&em->bm->edata, CD_FREESTYLE_EDGE)) { | if (me->drawflag & ME_DRAW_FREESTYLE_EDGE && CustomData_has_layer(&em->bm->edata, CD_FREESTYLE_EDGE)) { | ||||
| UI_ThemeColor(TH_FREESTYLE_EDGE_MARK); | UI_ThemeColor(TH_FREESTYLE_EDGE_MARK); | ||||
| glLineWidth(2.0f); | glLineWidth(2.0f); | ||||
| draw_dm_edges_freestyle(em, cageDM); | draw_dm_edges_freestyle(em, cageDM); | ||||
| glColor3ub(0, 0, 0); | oldColor3ub(0, 0, 0); | ||||
| } | } | ||||
| #endif | #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); | ||||
| ▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | |||||
| void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm, const unsigned char ob_wire_col[4]) /* LEGACY */ | void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm, const unsigned char ob_wire_col[4]) /* LEGACY */ | ||||
| { | { | ||||
| if ((v3d->transp == false) && /* not when we draw the transparent pass */ | if ((v3d->transp == false) && /* not when we draw the transparent pass */ | ||||
| (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */ | (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */ | ||||
| { | { | ||||
| glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f); | glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f); | ||||
| glDepthMask(GL_FALSE); | glDepthMask(GL_FALSE); | ||||
| if (ob_wire_col) glColor4ubv(ob_wire_col); | if (ob_wire_col) oldColor4ubv(ob_wire_col); | ||||
| /* if transparent, we cannot draw the edges for solid select... edges | /* if transparent, we cannot draw the edges for solid select... edges | ||||
| * have no material info. GPU_object_material_visible will skip the | * have no material info. GPU_object_material_visible will skip the | ||||
| * transparent faces */ | * transparent faces */ | ||||
| if (ob->dtx & OB_DRAWTRANSP) { | if (ob->dtx & OB_DRAWTRANSP) { | ||||
| glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | ||||
| dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_visible); | dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_visible); | ||||
| glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | ||||
| ▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | #endif | ||||
| } | } | ||||
| else { | else { | ||||
| draw_mesh_textured(scene, sl, v3d, rv3d, ob, dm, draw_flags); | draw_mesh_textured(scene, sl, v3d, rv3d, ob, dm, draw_flags); | ||||
| } | } | ||||
| if (draw_loose && !(draw_flags & DRAW_FACE_SELECT)) { | if (draw_loose && !(draw_flags & DRAW_FACE_SELECT)) { | ||||
| if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { | if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { | ||||
| if ((dflag & DRAW_CONSTCOLOR) == 0) { | if ((dflag & DRAW_CONSTCOLOR) == 0) { | ||||
| glColor3ubv(ob_wire_col); | oldColor3ubv(ob_wire_col); | ||||
| } | } | ||||
| glLineWidth(1.0f); | glLineWidth(1.0f); | ||||
| dm->drawLooseEdges(dm); | dm->drawLooseEdges(dm); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (dt == OB_SOLID) { | else if (dt == OB_SOLID) { | ||||
| if (draw_flags & DRAW_MODIFIERS_PREVIEW) { | if (draw_flags & DRAW_MODIFIERS_PREVIEW) { | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | else { | ||||
| dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind); | dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind); | ||||
| glFrontFace(GL_CCW); | glFrontFace(GL_CCW); | ||||
| GPU_object_material_unbind(); | GPU_object_material_unbind(); | ||||
| if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { | if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { | ||||
| if ((dflag & DRAW_CONSTCOLOR) == 0) { | if ((dflag & DRAW_CONSTCOLOR) == 0) { | ||||
| glColor3ubv(ob_wire_col); | oldColor3ubv(ob_wire_col); | ||||
| } | } | ||||
| glLineWidth(1.0f); | glLineWidth(1.0f); | ||||
| dm->drawLooseEdges(dm); | dm->drawLooseEdges(dm); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (dt == OB_PAINT) { | else if (dt == OB_PAINT) { | ||||
| draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); | draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); | ||||
| Show All 9 Lines | if ((draw_wire != OBDRAW_WIRE_OFF) && /* draw extra wire */ | ||||
| /* When using wireframe object draw in particle edit mode | /* When using wireframe object draw in particle edit mode | ||||
| * the mesh gets in the way of seeing the particles, fade the wire color | * the mesh gets in the way of seeing the particles, fade the wire color | ||||
| * with the background. */ | * with the background. */ | ||||
| if ((dflag & DRAW_CONSTCOLOR) == 0) { | if ((dflag & DRAW_CONSTCOLOR) == 0) { | ||||
| if (is_obact && (ob->mode & OB_MODE_PARTICLE_EDIT)) { | if (is_obact && (ob->mode & OB_MODE_PARTICLE_EDIT)) { | ||||
| float color[3]; | float color[3]; | ||||
| ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.15f, color); | ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.15f, color); | ||||
| glColor3fv(color); | oldColor3fv(color); | ||||
| } | } | ||||
| else { | else { | ||||
| glColor3ubv(ob_wire_col); | oldColor3ubv(ob_wire_col); | ||||
| } | } | ||||
| } | } | ||||
| /* If drawing wire and drawtype is not OB_WIRE then we are | /* If drawing wire and drawtype is not OB_WIRE then we are | ||||
| * overlaying the wires. | * overlaying the wires. | ||||
| * | * | ||||
| * UPDATE bug #10290 - With this wire-only objects can draw | * UPDATE bug #10290 - With this wire-only objects can draw | ||||
| * behind other objects depending on their order in the scene. 2x if 0's below. undo'ing zr's commit: r4059 | * behind other objects depending on their order in the scene. 2x if 0's below. undo'ing zr's commit: r4059 | ||||
| Show All 12 Lines | if ((draw_wire != OBDRAW_WIRE_OFF) && /* draw extra wire */ | ||||
| if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) { | if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) { | ||||
| glDepthMask(GL_TRUE); | glDepthMask(GL_TRUE); | ||||
| ED_view3d_polygon_offset(rv3d, 0.0); | ED_view3d_polygon_offset(rv3d, 0.0); | ||||
| } | } | ||||
| } | } | ||||
| if (is_obact && BKE_paint_select_vert_test(ob)) { | if (is_obact && BKE_paint_select_vert_test(ob)) { | ||||
| const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0; | const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0; | ||||
| glColor3f(0.0f, 0.0f, 0.0f); | oldColor3f(0.0f, 0.0f, 0.0f); | ||||
| glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); | glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); | ||||
| if (!use_depth) glDisable(GL_DEPTH_TEST); | if (!use_depth) glDisable(GL_DEPTH_TEST); | ||||
| else ED_view3d_polygon_offset(rv3d, 1.0); | else ED_view3d_polygon_offset(rv3d, 1.0); | ||||
| drawSelectedVertices(dm, ob->data); | drawSelectedVertices(dm, ob->data); | ||||
| if (!use_depth) glEnable(GL_DEPTH_TEST); | if (!use_depth) glEnable(GL_DEPTH_TEST); | ||||
| else ED_view3d_polygon_offset(rv3d, 0.0); | else ED_view3d_polygon_offset(rv3d, 0.0); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 323 Lines • ▼ Show 20 Lines | else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) || | ||||
| } | } | ||||
| else { | else { | ||||
| draw_mesh_textured(scene, sl, v3d, rv3d, ob, dm, draw_flags); | draw_mesh_textured(scene, sl, v3d, rv3d, ob, dm, draw_flags); | ||||
| } | } | ||||
| if (draw_loose && !(draw_flags & DRAW_FACE_SELECT)) { | if (draw_loose && !(draw_flags & DRAW_FACE_SELECT)) { | ||||
| if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { | if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { | ||||
| if ((dflag & DRAW_CONSTCOLOR) == 0) { | if ((dflag & DRAW_CONSTCOLOR) == 0) { | ||||
| glColor3ubv(ob_wire_col); | oldColor3ubv(ob_wire_col); | ||||
| } | } | ||||
| glLineWidth(1.0f); | glLineWidth(1.0f); | ||||
| dm->drawLooseEdges(dm); | dm->drawLooseEdges(dm); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (dt == OB_SOLID) { | else if (dt == OB_SOLID) { | ||||
| if (draw_flags & DRAW_MODIFIERS_PREVIEW) { | if (draw_flags & DRAW_MODIFIERS_PREVIEW) { | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | else { | ||||
| dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind); | dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind); | ||||
| glFrontFace(GL_CCW); | glFrontFace(GL_CCW); | ||||
| GPU_object_material_unbind(); | GPU_object_material_unbind(); | ||||
| if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { | if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { | ||||
| if ((dflag & DRAW_CONSTCOLOR) == 0) { | if ((dflag & DRAW_CONSTCOLOR) == 0) { | ||||
| glColor3ubv(ob_wire_col); | oldColor3ubv(ob_wire_col); | ||||
| } | } | ||||
| glLineWidth(1.0f); | glLineWidth(1.0f); | ||||
| dm->drawLooseEdges(dm); | dm->drawLooseEdges(dm); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (dt == OB_PAINT) { | else if (dt == OB_PAINT) { | ||||
| draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); | draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); | ||||
| Show All 27 Lines | |||||
| #else | #else | ||||
| /* something */ | /* something */ | ||||
| #endif | #endif | ||||
| } | } | ||||
| #if 0 // (merwin) what is this for? | #if 0 // (merwin) what is this for? | ||||
| if (is_obact && BKE_paint_select_vert_test(ob)) { | if (is_obact && BKE_paint_select_vert_test(ob)) { | ||||
| const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0; | const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0; | ||||
| glColor3f(0.0f, 0.0f, 0.0f); | oldColor3f(0.0f, 0.0f, 0.0f); | ||||
| glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); | glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); | ||||
| if (!use_depth) glDisable(GL_DEPTH_TEST); | if (!use_depth) glDisable(GL_DEPTH_TEST); | ||||
| else ED_view3d_polygon_offset(rv3d, 1.0); | else ED_view3d_polygon_offset(rv3d, 1.0); | ||||
| drawSelectedVertices(dm, ob->data); | drawSelectedVertices(dm, ob->data); | ||||
| if (!use_depth) glEnable(GL_DEPTH_TEST); | if (!use_depth) glEnable(GL_DEPTH_TEST); | ||||
| else ED_view3d_polygon_offset(rv3d, 0.0); | else ED_view3d_polygon_offset(rv3d, 0.0); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 322 Lines • ▼ Show 20 Lines | switch (dl->type) { | ||||
| if (col != dl->col) { | if (col != dl->col) { | ||||
| GPU_object_material_bind(dl->col + 1, use_glsl ? &gattribs : NULL); | GPU_object_material_bind(dl->col + 1, use_glsl ? &gattribs : NULL); | ||||
| col = dl->col; | col = dl->col; | ||||
| } | } | ||||
| #if 0 | #if 0 | ||||
| /* for polys only one normal needed */ | /* for polys only one normal needed */ | ||||
| if (index3_nors_incr) { | if (index3_nors_incr) { | ||||
| glEnableClientState(GL_NORMAL_ARRAY); | oldEnableClientState(GL_NORMAL_ARRAY); | ||||
| glNormalPointer(GL_FLOAT, 0, dl->nors); | oldNormalPointer(GL_FLOAT, 0, dl->nors); | ||||
| } | } | ||||
| else | else | ||||
| glNormal3fv(ndata); | oldNormal3fv(ndata); | ||||
| #endif | #endif | ||||
| drawDispListElem(false, (dl->rt & CU_SMOOTH), dl->verts, dl->nors, dl->nr, dl->index, dl->parts, ob_wire_col); | drawDispListElem(false, (dl->rt & CU_SMOOTH), dl->verts, dl->nors, dl->nr, dl->index, dl->parts, ob_wire_col); | ||||
| #if 0 | #if 0 | ||||
| if (index3_nors_incr) | if (index3_nors_incr) | ||||
| glDisableClientState(GL_NORMAL_ARRAY); | oldDisableClientState(GL_NORMAL_ARRAY); | ||||
| #endif | #endif | ||||
| break; | break; | ||||
| case DL_INDEX4: | case DL_INDEX4: | ||||
| if (col != dl->col) { | if (col != dl->col) { | ||||
| GPU_object_material_bind(dl->col + 1, use_glsl ? &gattribs : NULL); | GPU_object_material_bind(dl->col + 1, use_glsl ? &gattribs : NULL); | ||||
| col = dl->col; | col = dl->col; | ||||
| ▲ Show 20 Lines • Show All 1,120 Lines • ▼ Show 20 Lines | #if 0 | ||||
| /* enable other data arrays */ | /* enable other data arrays */ | ||||
| /* billboards are drawn this way */ | /* billboards are drawn this way */ | ||||
| if (pdd->ndata && ob_dt > OB_WIRE) { | if (pdd->ndata && ob_dt > OB_WIRE) { | ||||
| GPU_basic_shader_colors(NULL, NULL, 0.0f, 1.0f); | GPU_basic_shader_colors(NULL, NULL, 0.0f, 1.0f); | ||||
| GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR); | GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR); | ||||
| } | } | ||||
| if ((dflag & DRAW_CONSTCOLOR) == 0) { | if ((dflag & DRAW_CONSTCOLOR) == 0) { | ||||
| if (pdd->cdata) { | if (pdd->cdata) { | ||||
| glEnableClientState(GL_COLOR_ARRAY); | oldEnableClientState(GL_COLOR_ARRAY); | ||||
| glColorPointer(3, GL_FLOAT, 0, pdd->cdata); | oldColorPointer(3, GL_FLOAT, 0, pdd->cdata); | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| draw_particle_arrays_new(draw_as, ob_dt, 0, pdd->vdata, pdd->ndata, pdd->cdata, totpoint, NULL); | draw_particle_arrays_new(draw_as, ob_dt, 0, pdd->vdata, pdd->ndata, pdd->cdata, totpoint, NULL); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,268 Lines • ▼ Show 20 Lines | static bool drawmball(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Base *base, | ||||
| invert_m4_m4(imat, rv3d->viewmatob); | invert_m4_m4(imat, rv3d->viewmatob); | ||||
| normalize_v3(imat[0]); | normalize_v3(imat[0]); | ||||
| normalize_v3(imat[1]); | normalize_v3(imat[1]); | ||||
| #if 0 /* no purpose? */ | #if 0 /* no purpose? */ | ||||
| if (mb->editelems == NULL) { | if (mb->editelems == NULL) { | ||||
| if ((dflag & DRAW_CONSTCOLOR) == 0) { | if ((dflag & DRAW_CONSTCOLOR) == 0) { | ||||
| glColor3ubv(ob_wire_col); | oldColor3ubv(ob_wire_col); | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| glLineWidth(1.0f); | glLineWidth(1.0f); | ||||
| const unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT); | const unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| ▲ Show 20 Lines • Show All 843 Lines • ▼ Show 20 Lines | void draw_object(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, Base *base, const short dflag) | ||||
| /* which wire color */ | /* which wire color */ | ||||
| if ((dflag & DRAW_CONSTCOLOR) == 0) { | if ((dflag & DRAW_CONSTCOLOR) == 0) { | ||||
| ED_view3d_project_base(ar, base); | ED_view3d_project_base(ar, base); | ||||
| draw_object_wire_color(scene, sl, base, _ob_wire_col); | draw_object_wire_color(scene, sl, base, _ob_wire_col); | ||||
| ob_wire_col = _ob_wire_col; | ob_wire_col = _ob_wire_col; | ||||
| //glColor3ubv(ob_wire_col); | //oldColor3ubv(ob_wire_col); | ||||
| } | } | ||||
| /* maximum drawtype */ | /* maximum drawtype */ | ||||
| char dt = v3d->drawtype; | char dt = v3d->drawtype; | ||||
| if (dt == OB_RENDER) dt = v3d->prev_drawtype; | if (dt == OB_RENDER) dt = v3d->prev_drawtype; | ||||
| dt = MIN2(dt, ob->dt); | dt = MIN2(dt, ob->dt); | ||||
| if (v3d->zbuf == 0 && dt > OB_WIRE) dt = OB_WIRE; | if (v3d->zbuf == 0 && dt > OB_WIRE) dt = OB_WIRE; | ||||
| short dtx = 0; | short dtx = 0; | ||||
| ▲ Show 20 Lines • Show All 985 Lines • ▼ Show 20 Lines | if (ob->mode & OB_MODE_EDIT) { | ||||
| DM_update_materials(edm, ob); | DM_update_materials(edm, ob); | ||||
| } | } | ||||
| else { | else { | ||||
| dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); | dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); | ||||
| DM_update_materials(dm, ob); | DM_update_materials(dm, ob); | ||||
| } | } | ||||
| if (dt <= OB_WIRE) { | if (dt <= OB_WIRE) { | ||||
| glColor4ubv(ob_wire_col); | oldColor4ubv(ob_wire_col); | ||||
| if (dm) | if (dm) | ||||
| dm->drawEdges(dm, 1, 0); | dm->drawEdges(dm, 1, 0); | ||||
| else if (edm) | else if (edm) | ||||
| edm->drawEdges(edm, 1, 0); | edm->drawEdges(edm, 1, 0); | ||||
| } | } | ||||
| else { | else { | ||||
| if (outline) | if (outline) | ||||
| draw_mesh_object_outline(v3d, ob, dm ? dm : edm, ob_wire_col); | draw_mesh_object_outline(v3d, ob, dm ? dm : edm, ob_wire_col); | ||||
| ▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines | |||||