Commit: d346ed3b105f830f5f1862054ca233d27afe28d5
Author: Antony Riakiotakis
Date:   Mon Dec 28 17:54:45 2015 +0100
Branches: master
https://developer.blender.org/rBd346ed3b105f830f5f1862054ca233d27afe28d5

cdderivedmesh fix stippled faces not getting drawn at all

Also rearranged code here to not issue a draw call (explicit flush) per
face and not set shader per face either when stippled drawing is mixed
with regular drawing. Not good at all for performance.

===================================================================

M       source/blender/blenkernel/intern/cdderivedmesh.c

===================================================================

diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c 
b/source/blender/blenkernel/intern/cdderivedmesh.c
index 632403c..24b79c1 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -748,6 +748,8 @@ static void cdDM_drawMappedFaces(
                                draw_option = setMaterial(bufmat->mat_nr + 1, 
NULL);
 
                        if (draw_option != DM_DRAW_OPTION_SKIP) {
+                               DMDrawOption last_draw_option = 
DM_DRAW_OPTION_NORMAL;
+
                                for (i = 0; i < totpoly; i++) {
                                        int actualFace = next_actualFace;
                                        int flush = 0;
@@ -766,17 +768,12 @@ static void cdDM_drawMappedFaces(
                                                }
                                        }
 
-                                       if (draw_option == 
DM_DRAW_OPTION_STIPPLE) {
-                                               
GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR);
-                                               
GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE);
-                                       }
-
                                        /* 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 */
 
                                        /* flush buffer if current triangle 
isn't drawable or it's last triangle... */
-                                       flush = (ELEM(draw_option, 
DM_DRAW_OPTION_SKIP, DM_DRAW_OPTION_STIPPLE)) || (i == totpoly - 1);
+                                       flush = (draw_option != 
last_draw_option) || (i == totpoly - 1);
 
                                        if (!flush && compareDrawOptions) {
                                                flush |= 
compareDrawOptions(userData, actualFace, next_actualFace) == 0;
@@ -786,18 +783,27 @@ static void cdDM_drawMappedFaces(
                                        tot_element += tot_tri_verts;
 
                                        if (flush) {
-                                               if (!ELEM(draw_option, 
DM_DRAW_OPTION_SKIP, DM_DRAW_OPTION_STIPPLE))
+                                               if (draw_option != 
DM_DRAW_OPTION_SKIP) {
                                                        tot_drawn += 
tot_tri_verts;
 
+                                                       if (last_draw_option != 
draw_option) {
+                                                               if (draw_option 
== DM_DRAW_OPTION_STIPPLE) {
+                                                                       
GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR);
+                                                                       
GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE);
+                                                               }
+                                                               else {
+                                                                       
GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
+                                                               }
+                                                       }
+                                               }
+
                                                if (tot_drawn) {
                                                        
GPU_buffer_draw_elements(dm->drawObject->triangles, GL_TRIANGLES, bufmat->start 
+ start_element, tot_drawn);
                                                        tot_drawn = 0;
                                                }
 
+                                               last_draw_option = draw_option;
                                                start_element = tot_element;
-
-                                               if (draw_option == 
DM_DRAW_OPTION_STIPPLE)
-                                                       
GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
                                        }
                                        else {
                                                tot_drawn += tot_tri_verts;
@@ -807,6 +813,7 @@ static void cdDM_drawMappedFaces(
                }
        }
 
+       GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
        glShadeModel(GL_FLAT);
 
        GPU_buffers_unbind();

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to