From 1e3057f17779eb6c9fc03ba07a06332984a35cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastia=CC=81n=20Barschkis?= Date: Fri, 11 Sep 2020 16:45:07 +0200 Subject: GPUTexture: Return NULL texture if data grid is NULL too In a recent update to the fluids modifier (rB03c2439d96e8), I introduced a flush call that sets all grids to NULL if the frame is outside of the allowed frame range. This way, the texture creation function must also check if the data grid is NULL before trying to create a texture. Reviewed By: fclem Differential Revision: https://developer.blender.org/D8872 --- source/blender/draw/intern/draw_fluid.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/draw') diff --git a/source/blender/draw/intern/draw_fluid.c b/source/blender/draw/intern/draw_fluid.c index af14f11e6e9..809512bd7dd 100644 --- a/source/blender/draw/intern/draw_fluid.c +++ b/source/blender/draw/intern/draw_fluid.c @@ -183,6 +183,10 @@ static GPUTexture *create_volume_texture(const int dim[3], GPUTexture *tex = NULL; int final_dim[3] = {UNPACK3(dim)}; + if (data == NULL) { + return NULL; + } + while (1) { tex = GPU_texture_create_3d("volume", UNPACK3(final_dim), 1, format, NULL); @@ -292,6 +296,10 @@ static GPUTexture *create_density_texture(FluidDomainSettings *fds, int highres) data = manta_smoke_get_density(fds->fluid); } + if (data == NULL) { + return NULL; + } + GPUTexture *tex = create_volume_texture(dim, GPU_R8, data); swizzle_texture_channel_single(tex); return tex; -- cgit v1.2.3