Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/editderivedmesh.c
| Show All 40 Lines | |||||
| * is likely to be a little slow. | * is likely to be a little slow. | ||||
| */ | */ | ||||
| #include "GL/glew.h" | #include "GL/glew.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_jitter.h" | #include "BLI_jitter.h" | ||||
| #include "BLI_bitmap.h" | #include "BLI_bitmap.h" | ||||
| #include "BLI_listbase.h" | |||||
campbellbarton: this file can be unchanged | |||||
| #include "BKE_cdderivedmesh.h" | #include "BKE_cdderivedmesh.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_editmesh_bvh.h" | #include "BKE_editmesh_bvh.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_mesh_types.h" | |||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "BKE_deform.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "GPU_extensions.h" | #include "GPU_extensions.h" | ||||
| extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */ | extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */ | ||||
| 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]); | ||||
| ▲ Show 20 Lines • Show All 233 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void emDM_drawEdges(DerivedMesh *dm, | static void emDM_drawEdges(DerivedMesh *dm, | ||||
| bool UNUSED(drawLooseEdges), | bool UNUSED(drawLooseEdges), | ||||
| bool UNUSED(drawAllEdges)) | bool UNUSED(drawAllEdges)) | ||||
| { | { | ||||
| emDM_drawMappedEdges(dm, NULL, NULL); | emDM_drawMappedEdges(dm, NULL, NULL); | ||||
| } | } | ||||
| static void bm_vert_weight_gl_color(BMVert *eve, int vgroup_index, int cd_dvert_offset, int defgroup_tot) | |||||
| { | |||||
| MDeformVert *dvert; | |||||
| float weight; | |||||
| float col[3]; | |||||
| if (cd_dvert_offset != -1) { | |||||
| dvert = BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset); | |||||
| weight = defvert_find_weight(dvert, vgroup_index); | |||||
| if (weight == 0.0f) | |||||
| { | |||||
| if (DM_get_weight_user() == OB_DRAW_GROUPUSER_ACTIVE || | |||||
| DM_get_weight_user() == OB_DRAW_GROUPUSER_ALL && defvert_is_weight_zero(dvert, defgroup_tot)) { | |||||
| DM_get_weight_alert_color(col); | |||||
| glColor3fv(col); | |||||
| return; | |||||
| } | |||||
| } | |||||
| weight_to_rgb(col, weight); | |||||
| } | |||||
| else { | |||||
| DM_get_weight_alert_color(col); | |||||
| } | |||||
| glColor3fv(col); | |||||
| } | |||||
| static void emDM_drawMappedEdgesInterp(DerivedMesh *dm, | static void emDM_drawMappedEdgesInterp(DerivedMesh *dm, | ||||
| DMSetDrawOptions setDrawOptions, | DMSetDrawOptions setDrawOptions, | ||||
| DMSetDrawInterpOptions setDrawInterpOptions, | DMSetDrawInterpOptions setDrawInterpOptions, | ||||
| void *userData) | void *userData) | ||||
| { | { | ||||
| EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; | EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; | ||||
| BMesh *bm = bmdm->em->bm; | BMesh *bm = bmdm->em->bm; | ||||
| Object *ob = bmdm->em->ob; | |||||
| BMEdge *eed; | BMEdge *eed; | ||||
| BMIter iter; | BMIter iter; | ||||
| int i; | int i; | ||||
| const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT); | |||||
| const int defgroup_tot = BLI_countlist(&ob->defbase); | |||||
| const bool draw_weights = ((((Mesh *)ob->data)->drawflag & ME_DRAWEIGHT) != 0); | |||||
| glBegin(GL_LINES); | |||||
| if (draw_weights) { | |||||
campbellbartonUnsubmitted Not Done Inline ActionsI don't think this block of code is needed at all, setDrawInterpOptions can be used to set the color to use weights, This will also make drawing work with modifiers (subsurf in edimode for eg) The way this would work is the caller has to check if weights are used and pass a different setDrawInterpOptions function in that case. campbellbarton: I don't think this block of code is needed at all, `setDrawInterpOptions` can be used to set… | |||||
| const int vgroup_index = ob->actdef - 1; | |||||
| glEnable(GL_BLEND); | |||||
| if (bmdm->vertexCos) { | |||||
| BM_mesh_elem_index_ensure(bm, BM_VERT); | |||||
| BM_ITER_MESH_INDEX(eed, &iter, bm, BM_EDGES_OF_MESH, i) { | |||||
| if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { | |||||
| bm_vert_weight_gl_color(eed->v1, vgroup_index, cd_dvert_offset, defgroup_tot); | |||||
| glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v1)]); | |||||
| bm_vert_weight_gl_color(eed->v2, vgroup_index, cd_dvert_offset, defgroup_tot); | |||||
| glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v2)]); | |||||
| } | |||||
| } | |||||
| } | |||||
| else { | |||||
| BM_ITER_MESH_INDEX(eed, &iter, bm, BM_EDGES_OF_MESH, i) { | |||||
| if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { | |||||
| bm_vert_weight_gl_color(eed->v1, vgroup_index, cd_dvert_offset, defgroup_tot); | |||||
| glVertex3fv(eed->v1->co); | |||||
| bm_vert_weight_gl_color(eed->v2, vgroup_index, cd_dvert_offset, defgroup_tot); | |||||
| glVertex3fv(eed->v2->co); | |||||
| } | |||||
| } | |||||
| } | |||||
| glDisable(GL_BLEND); | |||||
| } | |||||
| else { | |||||
| 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); | |||||
| 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)]); | glVertex3fv(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)]); | glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v2)]); | ||||
| } | } | ||||
| } | } | ||||
| glEnd(); | |||||
| } | } | ||||
| else { | else { | ||||
| glBegin(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); | glVertex3fv(eed->v1->co); | ||||
| setDrawInterpOptions(userData, i, 1.0); | setDrawInterpOptions(userData, i, 1.0); | ||||
| glVertex3fv(eed->v2->co); | glVertex3fv(eed->v2->co); | ||||
| } | } | ||||
| } | } | ||||
| glEnd(); | |||||
| } | } | ||||
| } | } | ||||
| glEnd(); | |||||
| } | |||||
| static void emDM_drawUVEdges(DerivedMesh *dm) | static void emDM_drawUVEdges(DerivedMesh *dm) | ||||
| { | { | ||||
| EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; | EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; | ||||
| BMesh *bm = bmdm->em->bm; | BMesh *bm = bmdm->em->bm; | ||||
| BMFace *efa; | BMFace *efa; | ||||
| BMIter iter; | BMIter iter; | ||||
| ▲ Show 20 Lines • Show All 1,966 Lines • Show Last 20 Lines | |||||
this file can be unchanged