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
This commit is contained in:
Sebastián Barschkis
2020-09-11 16:45:07 +02:00
parent ad70d4b095
commit 1e3057f177

View File

@@ -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;