Fix T45605 crash with editmode selection on solidify modifier.

Looks like derivedmesh draw code always assumed a mesh is available.
Make sure that if we use a bmesh, a flag is used to control that.
This commit is contained in:
Antonis Ryakiotakis 2015-07-29 16:18:33 +02:00
parent 30679179dd
commit becf20e29f
Notes: blender-bot 2023-02-14 08:49:49 +01:00
Referenced by issue #45605, Blender 2.75-32157d8-win64 solidify crash
3 changed files with 24 additions and 5 deletions

View File

@ -151,6 +151,7 @@ typedef enum DMDrawFlag {
DM_DRAW_USE_TEXPAINT_UV = (1 << 3),
DM_DRAW_SKIP_HIDDEN = (1 << 4),
DM_DRAW_SKIP_SELECT = (1 << 5),
DM_DRAW_SELECT_USE_EDITMODE = (1 << 6)
} DMDrawFlag;
typedef enum DMForeachFlag {

View File

@ -654,9 +654,15 @@ static void cdDM_drawMappedFaces(
/* if we do selection, fill the selection buffer color */
if (G.f & G_BACKBUFSEL) {
if (!(flag & DM_DRAW_SKIP_SELECT)) {
Mesh *me = userData;
Mesh *me = NULL;
BMesh *bm = NULL;
unsigned int *fi_map;
if (flag & DM_DRAW_SELECT_USE_EDITMODE)
bm = userData;
else
me = userData;
findex_buffer = GPU_buffer_alloc(dm->drawObject->tot_loop_verts * sizeof(int), false);
fi_map = GPU_buffer_lock(findex_buffer, GPU_BINDING_ARRAY);
@ -664,10 +670,22 @@ static void cdDM_drawMappedFaces(
for (i = 0; i < totpoly; i++, mpoly++) {
int selcol = 0xFFFFFFFF;
const int orig = (index_mp_to_orig) ? index_mp_to_orig[i] : i;
bool is_hidden;
if ((orig != ORIGINDEX_NONE) && (!useHide || !(me->mpoly[orig].flag & ME_HIDE))) {
WM_framebuffer_index_get(orig + 1, &selcol);
if (useHide) {
if (flag & DM_DRAW_SELECT_USE_EDITMODE) {
BMFace *efa = BM_face_at_index(bm, orig);
is_hidden = BM_elem_flag_test(efa, BM_ELEM_HIDDEN) != 0;
}
else {
is_hidden = (me->mpoly[orig].flag & ME_HIDE) != 0;
}
if ((orig != ORIGINDEX_NONE) && !is_hidden)
WM_framebuffer_index_get(orig + 1, &selcol);
}
else if (orig != ORIGINDEX_NONE)
WM_framebuffer_index_get(orig + 1, &selcol);
for (j = 0; j < mpoly->totloop; j++)
fi_map[start_element++] = selcol;

View File

@ -8445,7 +8445,7 @@ static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d,
cpack(0);
if (use_faceselect) {
dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, NULL, NULL, em->bm, DM_DRAW_SKIP_HIDDEN);
dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, NULL, NULL, em->bm, DM_DRAW_SKIP_HIDDEN | DM_DRAW_SELECT_USE_EDITMODE);
if (check_ob_drawface_dot(scene, v3d, ob->dt)) {
glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE));
@ -8457,7 +8457,7 @@ static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d,
}
else {
dm->drawMappedFaces(dm, bbs_mesh_mask__setSolidDrawOptions, NULL, NULL, em->bm, DM_DRAW_SKIP_SELECT | DM_DRAW_SKIP_HIDDEN);
dm->drawMappedFaces(dm, bbs_mesh_mask__setSolidDrawOptions, NULL, NULL, em->bm, DM_DRAW_SKIP_SELECT | DM_DRAW_SKIP_HIDDEN | DM_DRAW_SELECT_USE_EDITMODE);
}
}