Disable depth buffer writes while rendering smoke in the viewport.
authorAlexander Gavrilov <angavrilov@gmail.com>
Mon, 8 Aug 2016 10:48:03 +0000 (13:48 +0300)
committerAlexander Gavrilov <angavrilov@gmail.com>
Mon, 8 Aug 2016 10:48:59 +0000 (13:48 +0300)
Depth buffer values are used by the viewport pan and zoom code to
adjust response scaling factors between mouse and viewport movement.
Letting smoke write to the buffer confuses it and causes the camera
to get stuck and move very slowly inside smoke domains, because it
thinks it is very close to an object.

source/blender/editors/space_view3d/drawvolume.c

index e93d840edddbe2131105c4c29a3344926b3301ea..8dbc27887442a0dabae231f21aa5d044de35d7ff 100644 (file)
@@ -379,11 +379,13 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
 
        /* setup buffer and draw */
 
 
        /* setup buffer and draw */
 
-       int gl_depth = 0, gl_blend = 0;
+       int gl_depth = 0, gl_blend = 0, gl_depth_write = 0;
        glGetBooleanv(GL_BLEND, (GLboolean *)&gl_blend);
        glGetBooleanv(GL_DEPTH_TEST, (GLboolean *)&gl_depth);
        glGetBooleanv(GL_BLEND, (GLboolean *)&gl_blend);
        glGetBooleanv(GL_DEPTH_TEST, (GLboolean *)&gl_depth);
+       glGetBooleanv(GL_DEPTH_WRITEMASK, (GLboolean *)&gl_depth_write);
 
        glEnable(GL_DEPTH_TEST);
 
        glEnable(GL_DEPTH_TEST);
+       glDepthMask(GL_FALSE);
        glEnable(GL_BLEND);
        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
        glEnable(GL_BLEND);
        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
@@ -422,6 +424,8 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
 
        GPU_shader_unbind();
 
 
        GPU_shader_unbind();
 
+       glDepthMask(gl_depth_write);
+
        if (!gl_blend) {
                glDisable(GL_BLEND);
        }
        if (!gl_blend) {
                glDisable(GL_BLEND);
        }