diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 1c2537464c2..aade98ec9da 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -804,15 +804,9 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, flush= !flag || i == tottri - 1; if(!flush && compareDrawOptions) { - int next_orig= (index==NULL) ? next_actualFace : index[next_actualFace]; - - if(orig==ORIGINDEX_NONE || next_orig==ORIGINDEX_NONE) { - flush= 1; - } else { - /* also compare draw options and flush buffer if they're different - need for face selection highlight in edit mode */ - flush|= compareDrawOptions(userData, orig, next_orig) == 0; - } + /* also compare draw options and flush buffer if they're different + need for face selection highlight in edit mode */ + flush|= compareDrawOptions(userData, actualFace, next_actualFace) == 0; } if(flush) { @@ -990,15 +984,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, flush|= mf[actualFace].mat_nr != mf[next_actualFace].mat_nr; if(!flush && compareDrawOptions) { - int next_orig= (index==NULL) ? next_actualFace : index[next_actualFace]; - - if(orig==ORIGINDEX_NONE || next_orig==ORIGINDEX_NONE) { - flush= 1; - } else { - /* also compare draw options and flush buffer if they're different - need for face selection highlight in edit mode */ - flush|= compareDrawOptions(userData, orig, next_orig) == 0; - } + flush|= compareDrawOptions(userData, actualFace, next_actualFace) == 0; } if(flush) { diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 690694cb7d9..4fc9c1e2839 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -631,14 +631,14 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) static int compareDrawOptions(void *userData, int cur_index, int next_index) { - Mesh *me= (Mesh*) userData; - MFace *mf= CustomData_get_layer(&me->fdata, CD_MFACE); - MTFace *tf= CustomData_get_layer(&me->fdata, CD_MTFACE); + DerivedMesh *dm= (DerivedMesh*) userData; + MFace *mf = DM_get_face_data_layer(dm, CD_MFACE); + MTFace *tf = DM_get_face_data_layer(dm, CD_MTFACE); - if(mf[cur_index].mat_nr != mf[next_index].mat_nr) + if(mf && mf[cur_index].mat_nr != mf[next_index].mat_nr) return 0; - if(tf[cur_index].tpage != tf[next_index].tpage) + if(tf && tf[cur_index].tpage != tf[next_index].tpage) return 0; return 1; @@ -683,7 +683,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec if(!CustomData_has_layer(&dm->faceData,CD_TEXTURE_MCOL)) add_tface_color_layer(dm); - dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, ob->data); + dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, dm); } } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index c5fa943ae87..0bb6f3429cc 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2323,7 +2323,7 @@ static void draw_dm_edges_sharp(DerivedMesh *dm) * return 2 for the active face so it renders with stipple enabled */ static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *UNUSED(drawSmooth_r)) { - struct { unsigned char *cols[3]; EditFace *efa_act; } * data = userData; + struct { DerivedMesh *dm; unsigned char *cols[3]; EditFace *efa_act; } * data = userData; EditFace *efa = EM_get_face_for_index(index); unsigned char *col; @@ -2343,11 +2343,18 @@ static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *UNU static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int next_index) { - struct { unsigned char *cols[3]; EditFace *efa_act; } * data = userData; - EditFace *efa = EM_get_face_for_index(index); - EditFace *next_efa = EM_get_face_for_index(next_index); + struct { DerivedMesh *dm; unsigned char *cols[3]; EditFace *efa_act; } * data = userData; + int *orig_index= DM_get_face_data_layer(data->dm, CD_ORIGINDEX); + EditFace *efa; + EditFace *next_efa; unsigned char *col, *next_col; + if(!orig_index) + return 0; + + efa= EM_get_face_for_index(orig_index[index]); + next_efa= EM_get_face_for_index(orig_index[next_index]); + if(efa == next_efa) return 1; @@ -2366,7 +2373,8 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int /* also draws the active face */ static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditFace *efa_act) { - struct { unsigned char *cols[3]; EditFace *efa_act; } data; + struct { DerivedMesh *dm; unsigned char *cols[3]; EditFace *efa_act; } data; + data.dm= dm; data.cols[0] = baseCol; data.cols[1] = selCol; data.cols[2] = actCol;