From d35bf3f421fe4166f5275067cc71e92465f1b954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Sun, 25 Sep 2016 00:26:21 +0200 Subject: Fix compile error when building without smoke support. Also fixes possible NULL pointer dereference. Fixes T49445. --- source/blender/editors/space_view3d/drawvolume.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/space_view3d/drawvolume.c') diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index ef4db7ed6b8..79d51093734 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -648,6 +648,20 @@ typedef void (*vector_draw_func)(float(*)[3], float(*)[3], float*, float*, float void draw_smoke_velocity(SmokeDomainSettings *domain, float viewnormal[3]) { +#ifdef WITH_SMOKE + const float *vel_x = smoke_get_velocity_x(domain->fluid); + const float *vel_y = smoke_get_velocity_y(domain->fluid); + const float *vel_z = smoke_get_velocity_z(domain->fluid); +#else + const float *vel_x = NULL; + const float *vel_y = NULL; + const float *vel_z = NULL; +#endif + + if (ELEM(NULL, vel_x, vel_y, vel_z)) { + return; + } + const int *base_res = domain->base_res; const int *res = domain->res; const int *res_min = domain->res_min; @@ -655,10 +669,6 @@ void draw_smoke_velocity(SmokeDomainSettings *domain, float viewnormal[3]) int res_max[3]; copy_v3_v3_int(res_max, domain->res_max); - const float *vel_x = smoke_get_velocity_x(domain->fluid); - const float *vel_y = smoke_get_velocity_y(domain->fluid); - const float *vel_z = smoke_get_velocity_z(domain->fluid); - const float *cell_size = domain->cell_size; const float step_size = ((float)max_iii(base_res[0], base_res[1], base_res[2])) / 16.0f; -- cgit v1.2.3