Disable depth buffer writes while rendering smoke in the viewport.

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.
This commit is contained in:
Alexander Gavrilov 2016-08-08 13:48:03 +03:00
parent 444422120f
commit f1040d7d94
1 changed files with 5 additions and 1 deletions

View File

@ -379,11 +379,13 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
/* 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_DEPTH_WRITEMASK, (GLboolean *)&gl_depth_write);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
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();
glDepthMask(gl_depth_write);
if (!gl_blend) {
glDisable(GL_BLEND);
}