Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-08-29 20:07:44 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-08-29 20:07:44 +0400
commit88a538048bf7671db6a51fa2791ed1c87fa88611 (patch)
tree15a400e318b1a4550d872243ebc7c47597289652 /source/blender/editors
parent6cf447a29c0c8dbdb318e28e3c8c8f95f92f5152 (diff)
Fix #28347: VBO's highlights wrong faces when Mirror modifier is in use
Added callback to drawMappedFaces which checks if two faces have got equal draw options. After discussion with Brecht we found it's nicest solution for now: - Disabling VBOs in edit mode for this case wouldn't be nicer for this case - some additional flag stored in DM should be added in this case. - Adding new callback in DM isn't nicer that this solution. - Handling face selection in drawobject would lead to duplicated code which is also not nice. Hopefully, this callback could handle all cases in the future. Also, Brecht mentioned current VBO implementation isn't perfect, so maybe when we'll redesign this area dealing with edit mode wouldn't be so tricky.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c2
-rw-r--r--source/blender/editors/space_view3d/drawobject.c44
2 files changed, 34 insertions, 12 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index 71c85483244..6e02ecbd5a8 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -607,7 +607,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o
}
else if(faceselect) {
if(ob->mode & OB_MODE_WEIGHT_PAINT)
- dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1, GPU_enable_material);
+ dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1, GPU_enable_material, NULL);
else
dm->drawMappedFacesTex(dm, me->mface ? draw_tface_mapped__set_draw : NULL, me);
}
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 638d197ccf7..8ca352ffe42 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -2030,6 +2030,28 @@ static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *UNU
return 0;
}
+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);
+ unsigned char *col, *next_col;
+
+ if(efa == next_efa)
+ return 1;
+
+ if(efa == data->efa_act || next_efa == data->efa_act)
+ return 0;
+
+ col = data->cols[(efa->f&SELECT)?1:0];
+ next_col = data->cols[(next_efa->f&SELECT)?1:0];
+
+ if(col[3]==0 || next_col[3]==0)
+ return 0;
+
+ return col == next_col;
+}
+
/* 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)
{
@@ -2039,7 +2061,7 @@ static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned
data.cols[2] = actCol;
data.efa_act = efa_act;
- dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0, GPU_enable_material);
+ dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0, GPU_enable_material, draw_dm_faces_sel__compareDrawOptions);
}
static int draw_dm_creases__setDrawOptions(void *UNUSED(userData), int index)
@@ -2449,7 +2471,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
glEnable(GL_LIGHTING);
glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
- finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, NULL, 0, GPU_enable_material);
+ finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, NULL, 0, GPU_enable_material, NULL);
glFrontFace(GL_CCW);
glDisable(GL_LIGHTING);
@@ -2678,7 +2700,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
/* weight paint in solid mode, special case. focus on making the weights clear
* rather than the shading, this is also forced in wire view */
GPU_enable_material(0, NULL);
- dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1, GPU_enable_material);
+ dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1, GPU_enable_material, NULL);
bglPolygonOffset(rv3d->dist, 1.0);
glDepthMask(0); // disable write in zbuffer, selected edge wires show better
@@ -2758,7 +2780,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
- dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1, GPU_enable_material);
+ dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1, GPU_enable_material, NULL);
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING);
@@ -2766,10 +2788,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
}
else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_TEXTURE_PAINT)) {
if(me->mcol)
- dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1, GPU_enable_material);
+ dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1, GPU_enable_material, NULL);
else {
glColor3f(1.0f, 1.0f, 1.0f);
- dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0, GPU_enable_material);
+ dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0, GPU_enable_material, NULL);
}
}
}
@@ -6459,7 +6481,7 @@ static void bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh
cpack(0);
if (facecol) {
- dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*)(intptr_t) 1, 0, GPU_enable_material);
+ dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*)(intptr_t) 1, 0, GPU_enable_material, NULL);
if(check_ob_drawface_dot(scene, v3d, ob->dt)) {
glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE));
@@ -6470,7 +6492,7 @@ static void bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh
}
} else {
- dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*) 0, 0, GPU_enable_material);
+ dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*) 0, 0, GPU_enable_material, NULL);
}
}
@@ -6499,8 +6521,8 @@ static void bbs_mesh_solid(Scene *scene, Object *ob)
glColor3ub(0, 0, 0);
- if((me->editflag & ME_EDIT_PAINT_MASK)) dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, me, 0, GPU_enable_material);
- else dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, me, 0, GPU_enable_material);
+ if((me->editflag & ME_EDIT_PAINT_MASK)) dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, me, 0, GPU_enable_material, NULL);
+ else dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, me, 0, GPU_enable_material, NULL);
dm->release(dm);
}
@@ -6607,7 +6629,7 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r
GPU_end_object_materials();
}
else if(edm)
- edm->drawMappedFaces(edm, NULL, NULL, 0, GPU_enable_material);
+ edm->drawMappedFaces(edm, NULL, NULL, 0, GPU_enable_material, NULL);
glDisable(GL_LIGHTING);
}