Yet another fix for crashes when drawing empty base mesh with constructive modifier. This crashed with ocean modifier (#29241). The previous fix was to avoid drawing mapped faces altogether for empty edit mesh, but that also disables the actual derived mesh display (#29346).

The real reason for this crash is that ocean modifier (in generative setting) does not properly set the derived mesh face ORIGINDEX data to ORIGINDEX_NONE. With this the previous fixes are not necessary.
This commit is contained in:
Lukas Toenne 2011-11-21 11:46:05 +00:00
parent 4ab1dadf72
commit d4f27b7bf0
2 changed files with 22 additions and 23 deletions

@ -2735,35 +2735,29 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
if(dt>OB_WIRE) {
if(CHECK_OB_DRAWTEXTURE(v3d, dt)) {
if(draw_glsl_material(scene, ob, v3d, dt)) {
/* if em has no faces the drawMappedFaces callback will fail */
if(em->faces.first) {
glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material,
draw_em_fancy__setGLSLFaceOpts, NULL);
GPU_disable_material();
glFrontFace(GL_CCW);
}
glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material,
draw_em_fancy__setGLSLFaceOpts, NULL);
GPU_disable_material();
glFrontFace(GL_CCW);
}
else {
draw_mesh_textured(scene, v3d, rv3d, ob, finalDM, 0);
}
}
else {
/* if em has no faces the drawMappedFaces callback will fail */
if(em->faces.first) {
/* 3 floats for position, 3 for normal and times two because the faces may actually be quads instead of triangles */
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED);
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, NULL);
glFrontFace(GL_CCW);
glDisable(GL_LIGHTING);
}
/* 3 floats for position, 3 for normal and times two because the faces may actually be quads instead of triangles */
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED);
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, NULL);
glFrontFace(GL_CCW);
glDisable(GL_LIGHTING);
}
// Setup for drawing wire over, disable zbuffer

@ -277,6 +277,7 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd)
MVert *mv;
MFace *mf;
MTFace *tf;
int *origindex;
int cdlayer;
@ -305,6 +306,7 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd)
mv = CDDM_get_verts(result);
mf = CDDM_get_faces(result);
origindex= result->getFaceDataArray(result, CD_ORIGINDEX);
/* create vertices */
#pragma omp parallel for private(x, y) if (rx > OMP_MIN_RES)
@ -329,6 +331,9 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd)
mf[fi].v4 = vi + res_x+1;
mf[fi].flag |= ME_SMOOTH;
/* generated geometry does not map to original faces */
origindex[fi] = ORIGINDEX_NONE;
}
}