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
path: root/source
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2015-12-28 19:54:45 +0300
committerAntony Riakiotakis <kalast@gmail.com>2015-12-28 19:55:03 +0300
commitd346ed3b105f830f5f1862054ca233d27afe28d5 (patch)
treef455d23d7c6de1e2f818152e7a70cfb1f924a10a /source
parent1dcae9e309b0656a250c53a807f01c1c69cb8e42 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 632403c5e25..24b79c1e566 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();