forked from bartvdbraak/blender
Fixed bug #23922, Sculpting - Textured display draws incorrectly
Root cause is that some drawing modes don't work with PBVH drawing. Worked around by adding a call to update mesh normals from the PBVH so that sculpted changes appear correctly in those "unsupported" modes. (They'll still draw much more slowly than solid, but should at least appear correct now.)
This commit is contained in:
parent
35f431b3d0
commit
98f642dd31
@ -226,6 +226,21 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
|
||||
return cddm->pbvh;
|
||||
}
|
||||
|
||||
/* update vertex normals so that drawing smooth faces works during sculpt
|
||||
TODO: proper fix is to support the pbvh in all drawing modes */
|
||||
static void cdDM_update_normals_from_pbvh(DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
float (*face_nors)[3];
|
||||
|
||||
if(!cddm->pbvh || !cddm->pbvh_draw || !dm->numFaceData)
|
||||
return;
|
||||
|
||||
face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL);
|
||||
|
||||
BLI_pbvh_update(cddm->pbvh, PBVH_UpdateNormals, face_nors);
|
||||
}
|
||||
|
||||
static void cdDM_drawVerts(DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
|
||||
@ -538,6 +553,8 @@ static void cdDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha
|
||||
if(col1 && col2)
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
cdDM_update_normals_from_pbvh(dm);
|
||||
|
||||
if( GPU_buffer_legacy(dm) ) {
|
||||
DEBUG_VBO( "Using legacy code. cdDM_drawFacesColored\n" );
|
||||
glShadeModel(GL_SMOOTH);
|
||||
@ -617,6 +634,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
|
||||
if(!mcol)
|
||||
mcol = dm->getFaceDataArray(dm, CD_MCOL);
|
||||
|
||||
cdDM_update_normals_from_pbvh(dm);
|
||||
|
||||
if( GPU_buffer_legacy(dm) ) {
|
||||
DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common\n" );
|
||||
for(i = 0; i < dm->numFaceData; i++, mf++) {
|
||||
@ -792,6 +811,8 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
|
||||
if(!mc)
|
||||
mc = DM_get_face_data_layer(dm, CD_MCOL);
|
||||
|
||||
cdDM_update_normals_from_pbvh(dm);
|
||||
|
||||
/* back-buffer always uses legacy since VBO's would need the
|
||||
* color array temporarily overwritten for drawing, then reset. */
|
||||
if( GPU_buffer_legacy(dm) || G.f & G_BACKBUFSEL) {
|
||||
@ -938,6 +959,8 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
|
||||
int transp, new_transp, orig_transp;
|
||||
int orig, *index = dm->getFaceDataArray(dm, CD_ORIGINDEX);
|
||||
|
||||
cdDM_update_normals_from_pbvh(dm);
|
||||
|
||||
matnr = -1;
|
||||
smoothnormal = 0;
|
||||
dodraw = 0;
|
||||
|
@ -1245,7 +1245,7 @@ static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d)
|
||||
no[1] = b_dZ*a_cX - b_dX*a_cZ;
|
||||
no[2] = b_dX*a_cY - b_dY*a_cX;
|
||||
|
||||
/* don't normalize, GL_NORMALIZE is be enabled */
|
||||
/* don't normalize, GL_NORMALIZE is enabled */
|
||||
glNormal3fv(no);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user