diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-22 19:36:36 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-22 19:36:36 +0300 |
commit | c080c096ce38ffd7aca46f97174612fe8773bb08 (patch) | |
tree | f9524a6ff7cc7f824d9adce9e354886acc48d93b /source/blender/blenkernel | |
parent | 6e8d4bcd0189b4776614f4fef357e68fe1aed388 (diff) |
Fix crash when HDR images are missing
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/studiolight.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index a8861a90fd0..f4884c49271 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -188,6 +188,9 @@ static void studiolight_calculate_irradiance(StudioLight *sl, float color[3], co /* back */ radiance_buffer = sl->radiance_buffers[STUDIOLIGHT_Y_POS]; + if (radiance_buffer == NULL) { + goto fail; + } radiance_color = radiance_buffer->rect_float; for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) { for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) { @@ -206,6 +209,9 @@ static void studiolight_calculate_irradiance(StudioLight *sl, float color[3], co /* front */ radiance_buffer = sl->radiance_buffers[STUDIOLIGHT_Y_NEG]; + if (radiance_buffer == NULL) { + goto fail; + } radiance_color = radiance_buffer->rect_float; for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) { for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) { @@ -224,6 +230,9 @@ static void studiolight_calculate_irradiance(StudioLight *sl, float color[3], co /* left */ radiance_buffer = sl->radiance_buffers[STUDIOLIGHT_X_POS]; + if (radiance_buffer == NULL) { + goto fail; + } radiance_color = radiance_buffer->rect_float; for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) { for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) { @@ -242,6 +251,9 @@ static void studiolight_calculate_irradiance(StudioLight *sl, float color[3], co /* right */ radiance_buffer = sl->radiance_buffers[STUDIOLIGHT_X_NEG]; + if (radiance_buffer == NULL) { + goto fail; + } radiance_color = radiance_buffer->rect_float; for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) { for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) { @@ -260,6 +272,9 @@ static void studiolight_calculate_irradiance(StudioLight *sl, float color[3], co /* top */ radiance_buffer = sl->radiance_buffers[STUDIOLIGHT_Z_POS]; + if (radiance_buffer == NULL) { + goto fail; + } radiance_color = radiance_buffer->rect_float; for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) { for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) { @@ -278,6 +293,9 @@ static void studiolight_calculate_irradiance(StudioLight *sl, float color[3], co /* bottom */ radiance_buffer = sl->radiance_buffers[STUDIOLIGHT_Z_NEG]; + if (radiance_buffer == NULL) { + goto fail; + } radiance_color = radiance_buffer->rect_float; for (int y = 0; y < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; y ++) { for (int x = 0; x < STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE; x ++) { @@ -295,6 +313,10 @@ static void studiolight_calculate_irradiance(StudioLight *sl, float color[3], co } mul_v3_fl(color, 1.25 / (STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE * STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE)); + +fail: + /* Pink color of failure. */ + ARRAY_SET_ITEMS(color, 1.0f, 0.0f, 1.0f); } static void studiolight_calculate_diffuse_light(StudioLight *sl) |