Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/editderivedmesh.c
| Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "GPU_glew.h" | #include "GPU_glew.h" | ||||
| #include "GPU_buffers.h" | #include "GPU_buffers.h" | ||||
| #include "GPU_legacy_stubs.h" | |||||
| #include "GPU_shader.h" | #include "GPU_shader.h" | ||||
| #include "GPU_basic_shader.h" | #include "GPU_basic_shader.h" | ||||
| static void bmdm_get_tri_colpreview(BMLoop *ls[3], MLoopCol *lcol[3], unsigned char(*color_vert_array)[4]); | static void bmdm_get_tri_colpreview(BMLoop *ls[3], MLoopCol *lcol[3], unsigned char(*color_vert_array)[4]); | ||||
| typedef struct EditDerivedBMesh { | typedef struct EditDerivedBMesh { | ||||
| DerivedMesh dm; | DerivedMesh dm; | ||||
| ▲ Show 20 Lines • Show All 667 Lines • ▼ Show 20 Lines | static void emDM_drawMappedEdges( | ||||
| BMEdge *eed; | BMEdge *eed; | ||||
| BMIter iter; | BMIter iter; | ||||
| int i; | int i; | ||||
| if (bmdm->vertexCos) { | if (bmdm->vertexCos) { | ||||
| BM_mesh_elem_index_ensure(bm, BM_VERT); | BM_mesh_elem_index_ensure(bm, BM_VERT); | ||||
| glBegin(GL_LINES); | oldBegin(GL_LINES); | ||||
| BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) { | BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) { | ||||
| if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { | if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { | ||||
| glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v1)]); | oldVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v1)]); | ||||
| glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v2)]); | oldVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v2)]); | ||||
| } | } | ||||
| } | } | ||||
| glEnd(); | oldEnd(); | ||||
| } | } | ||||
| else { | else { | ||||
| glBegin(GL_LINES); | oldBegin(GL_LINES); | ||||
| BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) { | BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) { | ||||
| if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { | if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { | ||||
| glVertex3fv(eed->v1->co); | oldVertex3fv(eed->v1->co); | ||||
| glVertex3fv(eed->v2->co); | oldVertex3fv(eed->v2->co); | ||||
| } | } | ||||
| } | } | ||||
| glEnd(); | oldEnd(); | ||||
| } | } | ||||
| } | } | ||||
| static void emDM_drawEdges( | static void emDM_drawEdges( | ||||
| DerivedMesh *dm, | DerivedMesh *dm, | ||||
| bool UNUSED(drawLooseEdges), | bool UNUSED(drawLooseEdges), | ||||
| bool UNUSED(drawAllEdges)) | bool UNUSED(drawAllEdges)) | ||||
| { | { | ||||
| emDM_drawMappedEdges(dm, NULL, NULL); | emDM_drawMappedEdges(dm, NULL, NULL); | ||||
| Show All 10 Lines | static void emDM_drawMappedEdgesInterp( | ||||
| BMEdge *eed; | BMEdge *eed; | ||||
| BMIter iter; | BMIter iter; | ||||
| int i; | int i; | ||||
| if (bmdm->vertexCos) { | if (bmdm->vertexCos) { | ||||
| BM_mesh_elem_index_ensure(bm, BM_VERT); | BM_mesh_elem_index_ensure(bm, BM_VERT); | ||||
| glBegin(GL_LINES); | oldBegin(GL_LINES); | ||||
| BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) { | BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) { | ||||
| if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { | if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { | ||||
| setDrawInterpOptions(userData, i, 0.0); | setDrawInterpOptions(userData, i, 0.0); | ||||
| glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v1)]); | oldVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v1)]); | ||||
| setDrawInterpOptions(userData, i, 1.0); | setDrawInterpOptions(userData, i, 1.0); | ||||
| glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v2)]); | oldVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v2)]); | ||||
| } | } | ||||
| } | } | ||||
| glEnd(); | oldEnd(); | ||||
| } | } | ||||
| else { | else { | ||||
| glBegin(GL_LINES); | oldBegin(GL_LINES); | ||||
| BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) { | BM_ITER_MESH_INDEX (eed, &iter, bm, BM_EDGES_OF_MESH, i) { | ||||
| if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { | if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { | ||||
| setDrawInterpOptions(userData, i, 0.0); | setDrawInterpOptions(userData, i, 0.0); | ||||
| glVertex3fv(eed->v1->co); | oldVertex3fv(eed->v1->co); | ||||
| setDrawInterpOptions(userData, i, 1.0); | setDrawInterpOptions(userData, i, 1.0); | ||||
| glVertex3fv(eed->v2->co); | oldVertex3fv(eed->v2->co); | ||||
| } | } | ||||
| } | } | ||||
| glEnd(); | oldEnd(); | ||||
| } | } | ||||
| } | } | ||||
| static void emDM_foreachMappedLoop( | static void emDM_foreachMappedLoop( | ||||
| DerivedMesh *dm, | DerivedMesh *dm, | ||||
| void (*func)(void *userData, int vertex_index, int face_index, const float co[3], const float no[3]), | void (*func)(void *userData, int vertex_index, int face_index, const float co[3], const float no[3]), | ||||
| void *userData, | void *userData, | ||||
| DMForeachFlag flag) | DMForeachFlag flag) | ||||
| ▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | for (i = 0; i < tottri; i++) { | ||||
| draw_option = (!setDrawOptions ? | draw_option = (!setDrawOptions ? | ||||
| DM_DRAW_OPTION_NORMAL : | DM_DRAW_OPTION_NORMAL : | ||||
| setDrawOptions(userData, BM_elem_index_get(efa))); | setDrawOptions(userData, BM_elem_index_get(efa))); | ||||
| if (draw_option != DM_DRAW_OPTION_SKIP) { | if (draw_option != DM_DRAW_OPTION_SKIP) { | ||||
| const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ | const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ | ||||
| if (draw_option_prev != draw_option) { | if (draw_option_prev != draw_option) { | ||||
| if (draw_option_prev == DM_DRAW_OPTION_STIPPLE) { | if (draw_option_prev == DM_DRAW_OPTION_STIPPLE) { | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| poly_prev = GL_ZERO; /* force glBegin */ | poly_prev = GL_ZERO; /* force oldBegin */ | ||||
| GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); | GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); | ||||
| } | } | ||||
| draw_option_prev = draw_option; | draw_option_prev = draw_option; | ||||
| } | } | ||||
| if (efa->mat_nr != prev_mat_nr) { | if (efa->mat_nr != prev_mat_nr) { | ||||
| if (setMaterial) { | if (setMaterial) { | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| poly_prev = GL_ZERO; /* force glBegin */ | poly_prev = GL_ZERO; /* force oldBegin */ | ||||
| setMaterial(efa->mat_nr + 1, NULL); | setMaterial(efa->mat_nr + 1, NULL); | ||||
| } | } | ||||
| prev_mat_nr = efa->mat_nr; | prev_mat_nr = efa->mat_nr; | ||||
| } | } | ||||
| if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ | if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| poly_prev = GL_ZERO; /* force glBegin */ | poly_prev = GL_ZERO; /* force oldBegin */ | ||||
| GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); | GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); | ||||
| GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE); | GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE); | ||||
| } | } | ||||
| if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array); | if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array); | ||||
| else if (has_fcol_preview) glColor3ubv((const GLubyte *)&(color_face_array[BM_elem_index_get(efa)])); | else if (has_fcol_preview) oldColor3ubv((const GLubyte *)&(color_face_array[BM_elem_index_get(efa)])); | ||||
| if (skip_normals) { | if (skip_normals) { | ||||
| if (poly_type != poly_prev) { | if (poly_type != poly_prev) { | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ | oldBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ | ||||
| } | } | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[0]->r)); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[1]->r)); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[2]->r)); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]); | ||||
| } | } | ||||
| else { | else { | ||||
| const GLenum shade_type = drawSmooth ? GL_SMOOTH : GL_FLAT; | const GLenum shade_type = drawSmooth ? GL_SMOOTH : GL_FLAT; | ||||
| if (shade_type != shade_prev) { | if (shade_type != shade_prev) { | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| glShadeModel((shade_prev = shade_type)); /* same as below but switch shading */ | oldShadeModel((shade_prev = shade_type)); /* same as below but switch shading */ | ||||
| glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ | oldBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ | ||||
| } | } | ||||
| if (poly_type != poly_prev) { | if (poly_type != poly_prev) { | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ | oldBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ | ||||
| } | } | ||||
| if (!drawSmooth) { | if (!drawSmooth) { | ||||
| glNormal3fv(polyNos[BM_elem_index_get(efa)]); | oldNormal3fv(polyNos[BM_elem_index_get(efa)]); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[0]->r)); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[1]->r)); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[2]->r)); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]); | ||||
| } | } | ||||
| else { | else { | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[0]->r)); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[0])]); | ||||
| else glNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]); | else oldNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[1]->r)); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[1])]); | ||||
| else glNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]); | else oldNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[2]->r)); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[2])]); | ||||
| else glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]); | else oldNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| short prev_mat_nr = -1; | short prev_mat_nr = -1; | ||||
| Show All 10 Lines | for (i = 0; i < tottri; i++) { | ||||
| setDrawOptions(userData, BM_elem_index_get(efa)) : | setDrawOptions(userData, BM_elem_index_get(efa)) : | ||||
| DM_DRAW_OPTION_NORMAL); | DM_DRAW_OPTION_NORMAL); | ||||
| if (draw_option != DM_DRAW_OPTION_SKIP) { | if (draw_option != DM_DRAW_OPTION_SKIP) { | ||||
| const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ | const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ | ||||
| if (draw_option_prev != draw_option) { | if (draw_option_prev != draw_option) { | ||||
| if (draw_option_prev == DM_DRAW_OPTION_STIPPLE) { | if (draw_option_prev == DM_DRAW_OPTION_STIPPLE) { | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| poly_prev = GL_ZERO; /* force glBegin */ | poly_prev = GL_ZERO; /* force oldBegin */ | ||||
| GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); | GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); | ||||
| } | } | ||||
| draw_option_prev = draw_option; | draw_option_prev = draw_option; | ||||
| } | } | ||||
| if (efa->mat_nr != prev_mat_nr) { | if (efa->mat_nr != prev_mat_nr) { | ||||
| if (setMaterial) { | if (setMaterial) { | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| poly_prev = GL_ZERO; /* force glBegin */ | poly_prev = GL_ZERO; /* force oldBegin */ | ||||
| setMaterial(efa->mat_nr + 1, NULL); | setMaterial(efa->mat_nr + 1, NULL); | ||||
| } | } | ||||
| prev_mat_nr = efa->mat_nr; | prev_mat_nr = efa->mat_nr; | ||||
| } | } | ||||
| if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ | if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| poly_prev = GL_ZERO; /* force glBegin */ | poly_prev = GL_ZERO; /* force oldBegin */ | ||||
| GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); | GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); | ||||
| GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE); | GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE); | ||||
| } | } | ||||
| if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array); | if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array); | ||||
| else if (has_fcol_preview) glColor3ubv((const GLubyte *)&(color_face_array[BM_elem_index_get(efa)])); | else if (has_fcol_preview) oldColor3ubv((const GLubyte *)&(color_face_array[BM_elem_index_get(efa)])); | ||||
| if (skip_normals) { | if (skip_normals) { | ||||
| if (poly_type != poly_prev) { | if (poly_type != poly_prev) { | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ | oldBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ | ||||
| } | } | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[0]->r)); | ||||
| glVertex3fv(ltri[0]->v->co); | oldVertex3fv(ltri[0]->v->co); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[1]->r)); | ||||
| glVertex3fv(ltri[1]->v->co); | oldVertex3fv(ltri[1]->v->co); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[2]->r)); | ||||
| glVertex3fv(ltri[2]->v->co); | oldVertex3fv(ltri[2]->v->co); | ||||
| } | } | ||||
| else { | else { | ||||
| const GLenum shade_type = drawSmooth ? GL_SMOOTH : GL_FLAT; | const GLenum shade_type = drawSmooth ? GL_SMOOTH : GL_FLAT; | ||||
| if (shade_type != shade_prev) { | if (shade_type != shade_prev) { | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| glShadeModel((shade_prev = shade_type)); /* same as below but switch shading */ | oldShadeModel((shade_prev = shade_type)); /* same as below but switch shading */ | ||||
| glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ | oldBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ | ||||
| } | } | ||||
| if (poly_type != poly_prev) { | if (poly_type != poly_prev) { | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ | oldBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ | ||||
| } | } | ||||
| if (!drawSmooth) { | if (!drawSmooth) { | ||||
| glNormal3fv(efa->no); | oldNormal3fv(efa->no); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[0]->r)); | ||||
| glVertex3fv(ltri[0]->v->co); | oldVertex3fv(ltri[0]->v->co); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[1]->r)); | ||||
| glVertex3fv(ltri[1]->v->co); | oldVertex3fv(ltri[1]->v->co); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[2]->r)); | ||||
| glVertex3fv(ltri[2]->v->co); | oldVertex3fv(ltri[2]->v->co); | ||||
| } | } | ||||
| else { | else { | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[0]->r)); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[0])]); | ||||
| else glNormal3fv(ltri[0]->v->no); | else oldNormal3fv(ltri[0]->v->no); | ||||
| glVertex3fv(ltri[0]->v->co); | oldVertex3fv(ltri[0]->v->co); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[1]->r)); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[1])]); | ||||
| else glNormal3fv(ltri[1]->v->no); | else oldNormal3fv(ltri[1]->v->no); | ||||
| glVertex3fv(ltri[1]->v->co); | oldVertex3fv(ltri[1]->v->co); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[2]->r)); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[2])]); | ||||
| else glNormal3fv(ltri[2]->v->no); | else oldNormal3fv(ltri[2]->v->no); | ||||
| glVertex3fv(ltri[2]->v->co); | oldVertex3fv(ltri[2]->v->co); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* if non zero we know a face was rendered */ | /* if non zero we know a face was rendered */ | ||||
| if (poly_prev != GL_ZERO) glEnd(); | if (poly_prev != GL_ZERO) oldEnd(); | ||||
| if (draw_option_prev == DM_DRAW_OPTION_STIPPLE) { | if (draw_option_prev == DM_DRAW_OPTION_STIPPLE) { | ||||
| GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); | GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); | ||||
| } | } | ||||
| if (shade_prev == GL_FLAT) { | if (shade_prev == GL_FLAT) { | ||||
| glShadeModel(GL_SMOOTH); | oldShadeModel(GL_SMOOTH); | ||||
| } | } | ||||
| } | } | ||||
| static void bmdm_get_tri_uv(BMLoop *ltri[3], MLoopUV *luv[3], const int cd_loop_uv_offset) | static void bmdm_get_tri_uv(BMLoop *ltri[3], MLoopUV *luv[3], const int cd_loop_uv_offset) | ||||
| { | { | ||||
| luv[0] = BM_ELEM_CD_GET_VOID_P(ltri[0], cd_loop_uv_offset); | luv[0] = BM_ELEM_CD_GET_VOID_P(ltri[0], cd_loop_uv_offset); | ||||
| luv[1] = BM_ELEM_CD_GET_VOID_P(ltri[1], cd_loop_uv_offset); | luv[1] = BM_ELEM_CD_GET_VOID_P(ltri[1], cd_loop_uv_offset); | ||||
| luv[2] = BM_ELEM_CD_GET_VOID_P(ltri[2], cd_loop_uv_offset); | luv[2] = BM_ELEM_CD_GET_VOID_P(ltri[2], cd_loop_uv_offset); | ||||
| ▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | for (i = 0; i < em->tottri; i++) { | ||||
| draw_option = DM_DRAW_OPTION_NORMAL; | draw_option = DM_DRAW_OPTION_NORMAL; | ||||
| if (draw_option != DM_DRAW_OPTION_SKIP) { | if (draw_option != DM_DRAW_OPTION_SKIP) { | ||||
| if (has_uv) bmdm_get_tri_uv(ltri, luv, cd_loop_uv_offset); | if (has_uv) bmdm_get_tri_uv(ltri, luv, cd_loop_uv_offset); | ||||
| if (has_vcol) bmdm_get_tri_col(ltri, lcol, cd_loop_color_offset); | if (has_vcol) bmdm_get_tri_col(ltri, lcol, cd_loop_color_offset); | ||||
| else if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array); | else if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array); | ||||
| glBegin(GL_TRIANGLES); | oldBegin(GL_TRIANGLES); | ||||
| if (!drawSmooth) { | if (!drawSmooth) { | ||||
| glNormal3fv(polyNos[BM_elem_index_get(efa)]); | oldNormal3fv(polyNos[BM_elem_index_get(efa)]); | ||||
| glTexCoord2fv(luv[0]->uv); | oldTexCoord2fv(luv[0]->uv); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[0]->r)); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]); | ||||
| glTexCoord2fv(luv[1]->uv); | oldTexCoord2fv(luv[1]->uv); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[1]->r)); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]); | ||||
| glTexCoord2fv(luv[2]->uv); | oldTexCoord2fv(luv[2]->uv); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[2]->r)); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]); | ||||
| } | } | ||||
| else { | else { | ||||
| glTexCoord2fv(luv[0]->uv); | oldTexCoord2fv(luv[0]->uv); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[0]->r)); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[0])]); | ||||
| else glNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]); | else oldNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]); | ||||
| glTexCoord2fv(luv[1]->uv); | oldTexCoord2fv(luv[1]->uv); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[1]->r)); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[1])]); | ||||
| else glNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]); | else oldNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]); | ||||
| glTexCoord2fv(luv[2]->uv); | oldTexCoord2fv(luv[2]->uv); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[2]->r)); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[2])]); | ||||
| else glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]); | else oldNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]); | ||||
| } | } | ||||
| glEnd(); | oldEnd(); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| BM_mesh_elem_index_ensure(bm, lnors ? BM_LOOP | BM_VERT : BM_VERT); | BM_mesh_elem_index_ensure(bm, lnors ? BM_LOOP | BM_VERT : BM_VERT); | ||||
| for (i = 0; i < em->tottri; i++) { | for (i = 0; i < em->tottri; i++) { | ||||
| BMLoop **ltri = looptris[i]; | BMLoop **ltri = looptris[i]; | ||||
| Show All 12 Lines | for (i = 0; i < em->tottri; i++) { | ||||
| draw_option = DM_DRAW_OPTION_NORMAL; | draw_option = DM_DRAW_OPTION_NORMAL; | ||||
| if (draw_option != DM_DRAW_OPTION_SKIP) { | if (draw_option != DM_DRAW_OPTION_SKIP) { | ||||
| if (has_uv) bmdm_get_tri_uv(ltri, luv, cd_loop_uv_offset); | if (has_uv) bmdm_get_tri_uv(ltri, luv, cd_loop_uv_offset); | ||||
| if (has_vcol) bmdm_get_tri_col(ltri, lcol, cd_loop_color_offset); | if (has_vcol) bmdm_get_tri_col(ltri, lcol, cd_loop_color_offset); | ||||
| else if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array); | else if (has_vcol_preview) bmdm_get_tri_colpreview(ltri, lcol, color_vert_array); | ||||
| glBegin(GL_TRIANGLES); | oldBegin(GL_TRIANGLES); | ||||
| if (!drawSmooth) { | if (!drawSmooth) { | ||||
| glNormal3fv(efa->no); | oldNormal3fv(efa->no); | ||||
| glTexCoord2fv(luv[0]->uv); | oldTexCoord2fv(luv[0]->uv); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[0]->r)); | ||||
| glVertex3fv(ltri[0]->v->co); | oldVertex3fv(ltri[0]->v->co); | ||||
| glTexCoord2fv(luv[1]->uv); | oldTexCoord2fv(luv[1]->uv); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[1]->r)); | ||||
| glVertex3fv(ltri[1]->v->co); | oldVertex3fv(ltri[1]->v->co); | ||||
| glTexCoord2fv(luv[2]->uv); | oldTexCoord2fv(luv[2]->uv); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[2]->r)); | ||||
| glVertex3fv(ltri[2]->v->co); | oldVertex3fv(ltri[2]->v->co); | ||||
| } | } | ||||
| else { | else { | ||||
| glTexCoord2fv(luv[0]->uv); | oldTexCoord2fv(luv[0]->uv); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[0]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[0]->r)); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[0])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[0])]); | ||||
| else glNormal3fv(ltri[0]->v->no); | else oldNormal3fv(ltri[0]->v->no); | ||||
| glVertex3fv(ltri[0]->v->co); | oldVertex3fv(ltri[0]->v->co); | ||||
| glTexCoord2fv(luv[1]->uv); | oldTexCoord2fv(luv[1]->uv); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[1]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[1]->r)); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[1])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[1])]); | ||||
| else glNormal3fv(ltri[1]->v->no); | else oldNormal3fv(ltri[1]->v->no); | ||||
| glVertex3fv(ltri[1]->v->co); | oldVertex3fv(ltri[1]->v->co); | ||||
| glTexCoord2fv(luv[2]->uv); | oldTexCoord2fv(luv[2]->uv); | ||||
| if (has_vcol_any) glColor3ubv((const GLubyte *)&(lcol[2]->r)); | if (has_vcol_any) oldColor3ubv((const GLubyte *)&(lcol[2]->r)); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[2])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[2])]); | ||||
| else glNormal3fv(ltri[2]->v->no); | else oldNormal3fv(ltri[2]->v->no); | ||||
| glVertex3fv(ltri[2]->v->co); | oldVertex3fv(ltri[2]->v->co); | ||||
| } | } | ||||
| glEnd(); | oldEnd(); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void emDM_drawFacesTex( | static void emDM_drawFacesTex( | ||||
| DerivedMesh *dm, | DerivedMesh *dm, | ||||
| DMSetDrawOptionsTex setDrawOptions, | DMSetDrawOptionsTex setDrawOptions, | ||||
| Show All 30 Lines | static void emdm_pass_attrib_vertex_glsl(const DMVertexAttribs *attribs, const BMLoop *loop) | ||||
| int i; | int i; | ||||
| const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | ||||
| if (attribs->totorco) { | if (attribs->totorco) { | ||||
| int index = BM_elem_index_get(eve); | int index = BM_elem_index_get(eve); | ||||
| const float *orco = (attribs->orco.array) ? attribs->orco.array[index] : zero; | const float *orco = (attribs->orco.array) ? attribs->orco.array[index] : zero; | ||||
| if (attribs->orco.gl_texco) | if (attribs->orco.gl_texco) | ||||
| glTexCoord3fv(orco); | oldTexCoord3fv(orco); | ||||
| else | else | ||||
| glVertexAttrib3fv(attribs->orco.gl_index, orco); | glVertexAttrib3fv(attribs->orco.gl_index, orco); | ||||
| } | } | ||||
| for (i = 0; i < attribs->tottface; i++) { | for (i = 0; i < attribs->tottface; i++) { | ||||
| const float *uv; | const float *uv; | ||||
| if (attribs->tface[i].em_offset != -1) { | if (attribs->tface[i].em_offset != -1) { | ||||
| const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(loop, attribs->tface[i].em_offset); | const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(loop, attribs->tface[i].em_offset); | ||||
| uv = luv->uv; | uv = luv->uv; | ||||
| } | } | ||||
| else { | else { | ||||
| uv = zero; | uv = zero; | ||||
| } | } | ||||
| if (attribs->tface[i].gl_texco) | if (attribs->tface[i].gl_texco) | ||||
| glTexCoord2fv(uv); | oldTexCoord2fv(uv); | ||||
| else | else | ||||
| glVertexAttrib2fv(attribs->tface[i].gl_index, uv); | glVertexAttrib2fv(attribs->tface[i].gl_index, uv); | ||||
| } | } | ||||
| for (i = 0; i < attribs->totmcol; i++) { | for (i = 0; i < attribs->totmcol; i++) { | ||||
| float col[4]; | float col[4]; | ||||
| if (attribs->mcol[i].em_offset != -1) { | if (attribs->mcol[i].em_offset != -1) { | ||||
| const MLoopCol *cp = BM_ELEM_CD_GET_VOID_P(loop, attribs->mcol[i].em_offset); | const MLoopCol *cp = BM_ELEM_CD_GET_VOID_P(loop, attribs->mcol[i].em_offset); | ||||
| rgba_uchar_to_float(col, &cp->r); | rgba_uchar_to_float(col, &cp->r); | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | for (i = 0; i < em->tottri; i++) { | ||||
| if (setDrawOptions && (setDrawOptions(userData, BM_elem_index_get(efa)) == DM_DRAW_OPTION_SKIP)) | if (setDrawOptions && (setDrawOptions(userData, BM_elem_index_get(efa)) == DM_DRAW_OPTION_SKIP)) | ||||
| continue; | continue; | ||||
| /* material */ | /* material */ | ||||
| new_matnr = efa->mat_nr + 1; | new_matnr = efa->mat_nr + 1; | ||||
| if (new_matnr != matnr) { | if (new_matnr != matnr) { | ||||
| if (matnr != -1) | if (matnr != -1) | ||||
| glEnd(); | oldEnd(); | ||||
| do_draw = setMaterial(matnr = new_matnr, &gattribs); | do_draw = setMaterial(matnr = new_matnr, &gattribs); | ||||
| if (do_draw) { | if (do_draw) { | ||||
| DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); | DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); | ||||
| DM_draw_attrib_vertex_uniforms(&attribs); | DM_draw_attrib_vertex_uniforms(&attribs); | ||||
| if (UNLIKELY(attribs.tottang && bm->elem_index_dirty & BM_LOOP)) { | if (UNLIKELY(attribs.tottang && bm->elem_index_dirty & BM_LOOP)) { | ||||
| BM_mesh_elem_index_ensure(bm, BM_LOOP); | BM_mesh_elem_index_ensure(bm, BM_LOOP); | ||||
| } | } | ||||
| } | } | ||||
| glBegin(GL_TRIANGLES); | oldBegin(GL_TRIANGLES); | ||||
| } | } | ||||
| if (do_draw) { | if (do_draw) { | ||||
| /* draw face */ | /* draw face */ | ||||
| drawSmooth = lnors || BM_elem_flag_test(efa, BM_ELEM_SMOOTH); | drawSmooth = lnors || BM_elem_flag_test(efa, BM_ELEM_SMOOTH); | ||||
| if (!drawSmooth) { | if (!drawSmooth) { | ||||
| if (vertexCos) { | if (vertexCos) { | ||||
| glNormal3fv(polyNos[BM_elem_index_get(efa)]); | oldNormal3fv(polyNos[BM_elem_index_get(efa)]); | ||||
| for (fi = 0; fi < 3; fi++) { | for (fi = 0; fi < 3; fi++) { | ||||
| emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[fi]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[fi]->v)]); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| glNormal3fv(efa->no); | oldNormal3fv(efa->no); | ||||
| for (fi = 0; fi < 3; fi++) { | for (fi = 0; fi < 3; fi++) { | ||||
| emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | ||||
| glVertex3fv(ltri[fi]->v->co); | oldVertex3fv(ltri[fi]->v->co); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (vertexCos) { | if (vertexCos) { | ||||
| for (fi = 0; fi < 3; fi++) { | for (fi = 0; fi < 3; fi++) { | ||||
| const int j = BM_elem_index_get(ltri[fi]->v); | const int j = BM_elem_index_get(ltri[fi]->v); | ||||
| emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[fi])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[fi])]); | ||||
| else glNormal3fv(vertexNos[j]); | else oldNormal3fv(vertexNos[j]); | ||||
| glVertex3fv(vertexCos[j]); | oldVertex3fv(vertexCos[j]); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| for (fi = 0; fi < 3; fi++) { | for (fi = 0; fi < 3; fi++) { | ||||
| emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[fi])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[fi])]); | ||||
| else glNormal3fv(ltri[fi]->v->no); | else oldNormal3fv(ltri[fi]->v->no); | ||||
| glVertex3fv(ltri[fi]->v->co); | oldVertex3fv(ltri[fi]->v->co); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (matnr != -1) { | if (matnr != -1) { | ||||
| glEnd(); | oldEnd(); | ||||
| } | } | ||||
| } | } | ||||
| static void emDM_drawFacesGLSL( | static void emDM_drawFacesGLSL( | ||||
| DerivedMesh *dm, | DerivedMesh *dm, | ||||
| int (*setMaterial)(int matnr, void *attribs)) | int (*setMaterial)(int matnr, void *attribs)) | ||||
| { | { | ||||
| dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL); | dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL); | ||||
| Show All 36 Lines | for (i = 0; i < em->tottri; i++) { | ||||
| /* face hiding */ | /* face hiding */ | ||||
| if (setFace && !setFace(userData, BM_elem_index_get(efa))) | if (setFace && !setFace(userData, BM_elem_index_get(efa))) | ||||
| continue; | continue; | ||||
| /* material */ | /* material */ | ||||
| new_matnr = efa->mat_nr + 1; | new_matnr = efa->mat_nr + 1; | ||||
| if (new_matnr != matnr) { | if (new_matnr != matnr) { | ||||
| if (matnr != -1) | if (matnr != -1) | ||||
| glEnd(); | oldEnd(); | ||||
| setMaterial(userData, matnr = new_matnr, &gattribs); | setMaterial(userData, matnr = new_matnr, &gattribs); | ||||
| DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); | DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); | ||||
| if (UNLIKELY(attribs.tottang && bm->elem_index_dirty & BM_LOOP)) { | if (UNLIKELY(attribs.tottang && bm->elem_index_dirty & BM_LOOP)) { | ||||
| BM_mesh_elem_index_ensure(bm, BM_LOOP); | BM_mesh_elem_index_ensure(bm, BM_LOOP); | ||||
| } | } | ||||
| glBegin(GL_TRIANGLES); | oldBegin(GL_TRIANGLES); | ||||
| } | } | ||||
| /* draw face */ | /* draw face */ | ||||
| drawSmooth = lnors || BM_elem_flag_test(efa, BM_ELEM_SMOOTH); | drawSmooth = lnors || BM_elem_flag_test(efa, BM_ELEM_SMOOTH); | ||||
| if (!drawSmooth) { | if (!drawSmooth) { | ||||
| if (vertexCos) { | if (vertexCos) { | ||||
| glNormal3fv(polyNos[BM_elem_index_get(efa)]); | oldNormal3fv(polyNos[BM_elem_index_get(efa)]); | ||||
| for (fi = 0; fi < 3; fi++) { | for (fi = 0; fi < 3; fi++) { | ||||
| emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | ||||
| glVertex3fv(vertexCos[BM_elem_index_get(ltri[fi]->v)]); | oldVertex3fv(vertexCos[BM_elem_index_get(ltri[fi]->v)]); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| glNormal3fv(efa->no); | oldNormal3fv(efa->no); | ||||
| for (fi = 0; fi < 3; fi++) { | for (fi = 0; fi < 3; fi++) { | ||||
| emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | ||||
| glVertex3fv(ltri[fi]->v->co); | oldVertex3fv(ltri[fi]->v->co); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (vertexCos) { | if (vertexCos) { | ||||
| for (fi = 0; fi < 3; fi++) { | for (fi = 0; fi < 3; fi++) { | ||||
| const int j = BM_elem_index_get(ltri[fi]->v); | const int j = BM_elem_index_get(ltri[fi]->v); | ||||
| emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[fi])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[fi])]); | ||||
| else glNormal3fv(vertexNos[j]); | else oldNormal3fv(vertexNos[j]); | ||||
| glVertex3fv(vertexCos[j]); | oldVertex3fv(vertexCos[j]); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| for (fi = 0; fi < 3; fi++) { | for (fi = 0; fi < 3; fi++) { | ||||
| emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | emdm_pass_attrib_vertex_glsl(&attribs, ltri[fi]); | ||||
| if (lnors) glNormal3fv(lnors[BM_elem_index_get(ltri[fi])]); | if (lnors) oldNormal3fv(lnors[BM_elem_index_get(ltri[fi])]); | ||||
| else glNormal3fv(ltri[fi]->v->no); | else oldNormal3fv(ltri[fi]->v->no); | ||||
| glVertex3fv(ltri[fi]->v->co); | oldVertex3fv(ltri[fi]->v->co); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (matnr != -1) { | if (matnr != -1) { | ||||
| glEnd(); | oldEnd(); | ||||
| } | } | ||||
| } | } | ||||
| static void emDM_getMinMax(DerivedMesh *dm, float r_min[3], float r_max[3]) | static void emDM_getMinMax(DerivedMesh *dm, float r_min[3], float r_max[3]) | ||||
| { | { | ||||
| EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; | EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; | ||||
| BMesh *bm = bmdm->em->bm; | BMesh *bm = bmdm->em->bm; | ||||
| BMVert *eve; | BMVert *eve; | ||||
| ▲ Show 20 Lines • Show All 1,120 Lines • Show Last 20 Lines | |||||