[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32307] trunk/blender/source/blender/ blenkernel/intern/cdderivedmesh.c: bugfix [#24133] r32303, Mirror Modifier + EditMode + VBO's Problem.
Campbell Barton
ideasman42 at gmail.com
Mon Oct 4 21:01:25 CEST 2010
Revision: 32307
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32307
Author: campbellbarton
Date: 2010-10-04 21:01:25 +0200 (Mon, 04 Oct 2010)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
Modified: trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2010-10-04 15:59:35 UTC (rev 32306)
+++ trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2010-10-04 19:01:25 UTC (rev 32307)
@@ -872,34 +872,51 @@
if( !GPU_buffer_legacy(dm) ) {
int tottri = dm->drawObject->nelements/3;
glShadeModel(GL_SMOOTH);
+
+ 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;
- 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(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;
+
+ /* 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;
+ }
}
- 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;
- }
- }
glShadeModel(GL_FLAT);
}
GPU_buffer_unbind();
More information about the Bf-blender-cvs
mailing list