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:
authorCampbell Barton <ideasman42@gmail.com>2010-10-04 23:01:25 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-10-04 23:01:25 +0400
commitf994c6caee126f00f97e7da9fde79bdefadd27ec (patch)
treee13d472552fc8a42814dff7dec90f9af5dd581a4 /source/blender/blenkernel/intern/cdderivedmesh.c
parente88b8dac7b7bba016fca80d4d2e83850ed924968 (diff)
bugfix [#24133] r32303, Mirror Modifier + EditMode + VBO's Problem.
drawing the triangle arrays were only broken up by hidden faces, but switches in material were ignored. now check for materual context changes.
Diffstat (limited to 'source/blender/blenkernel/intern/cdderivedmesh.c')
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c67
1 files changed, 42 insertions, 25 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index ca81e216006..e2ecf21bd62 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -872,34 +872,51 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
if( !GPU_buffer_legacy(dm) ) {
int tottri = dm->drawObject->nelements/3;
glShadeModel(GL_SMOOTH);
-
- for( i = 0; i < tottri; i++ ) {
- int actualFace = dm->drawObject->faceRemap[i];
- int drawSmooth = (mf[actualFace].flag & ME_SMOOTH);
- int draw = 1;
-
- if(index) {
- orig = index[actualFace];
- if(setDrawOptions && orig == ORIGINDEX_NONE)
+
+ if(tottri == 0) {
+ /* avoid buffer problems in following code */
+ }
+ if(setDrawOptions == NULL) {
+ /* just draw the entire face array */
+ glDrawArrays(GL_TRIANGLES, 0, (tottri-1) * 3);
+ }
+ else {
+ /* we need to check if the next material changes */
+ int next_actualFace= dm->drawObject->faceRemap[0];
+
+ for( i = 0; i < tottri; i++ ) {
+ //int actualFace = dm->drawObject->faceRemap[i];
+ int actualFace = next_actualFace;
+ int drawSmooth = (mf[actualFace].flag & ME_SMOOTH);
+ int draw = 1;
+
+ if(i != tottri-1)
+ next_actualFace= dm->drawObject->faceRemap[i+1];
+
+ if(index) {
+ orig = index[actualFace];
+ if(orig == ORIGINDEX_NONE)
+ draw = 0;
+ }
+ else
+ orig = actualFace;
+
+ if(draw && !setDrawOptions(userData, orig, &drawSmooth))
draw = 0;
- }
- else
- orig = actualFace;
-
- if(draw && setDrawOptions && !setDrawOptions(userData, orig, &drawSmooth))
- draw = 0;
-
- /* Goal is to draw as long of a contiguous triangle
- array as possible, so draw when we hit either an
- invisible triangle or at the end of the array */
- if(!draw || i == tottri - 1) {
- if(prevstart != i)
- /* Add one to the length (via `draw')
- if we're drawing at the end of the array */
- glDrawArrays(GL_TRIANGLES,prevstart*3, (i-prevstart+draw)*3);
- prevstart = i + 1;
+
+ /* Goal is to draw as long of a contiguous triangle
+ array as possible, so draw when we hit either an
+ invisible triangle or at the end of the array */
+ if(!draw || i == tottri - 1 || mf[actualFace].mat_nr != mf[next_actualFace].mat_nr) {
+ if(prevstart != i)
+ /* Add one to the length (via `draw')
+ if we're drawing at the end of the array */
+ glDrawArrays(GL_TRIANGLES,prevstart*3, (i-prevstart+draw)*3);
+ prevstart = i + 1;
+ }
}
}
+
glShadeModel(GL_FLAT);
}
GPU_buffer_unbind();