diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-07-20 12:00:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-20 12:00:13 +0200 |
commit | d15cf7b672ac9911b4e82fed52b4c5e8d4312b0d (patch) | |
tree | 68ab08fafd7e14710ce245a47f3bb518ebf03307 /drivers | |
parent | 700938bff772924941c4e1ea61bbfd2abe34d8d2 (diff) | |
parent | 6cbaf7662f5ee3ca1d02c0ebc85854fceee057af (diff) |
Merge pull request #30576 from qarmin/lgtm_coverage
Changed some code reported by LGTM and Coverity
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles2/rasterizer_scene_gles2.cpp | 18 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_storage_gles2.cpp | 7 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 15 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 9 |
4 files changed, 19 insertions, 30 deletions
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index c8ceca8d97..aea89ddaa1 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -880,7 +880,11 @@ RID RasterizerSceneGLES2::light_instance_create(RID p_light) { light_instance->light_index = 0xFFFF; - ERR_FAIL_COND_V(!light_instance->light_ptr, RID()); + if (!light_instance->light_ptr) { + memdelete(light_instance); + ERR_EXPLAIN("Condition ' !light_instance->light_ptr ' is true."); + ERR_FAIL_V(RID()); + } light_instance->self = light_instance_owner.make_rid(light_instance); @@ -1963,9 +1967,7 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado width /= 2; height /= 2; - if (k == 0) { - - } else if (k == 1) { + if (k == 1) { x += width; } else if (k == 2) { y += height; @@ -1978,9 +1980,7 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado height /= 2; - if (k == 0) { - - } else { + if (k != 0) { y += height; } } @@ -3171,9 +3171,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ width /= 2; height /= 2; - if (p_pass == 0) { - - } else if (p_pass == 1) { + if (p_pass == 1) { x += width; } else if (p_pass == 2) { y += height; diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index c591db4f3d..a0188da4f6 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -3976,20 +3976,19 @@ AABB RasterizerStorageGLES2::light_get_aabb(RID p_light) const { float len = light->param[VS::LIGHT_PARAM_RANGE]; float size = Math::tan(Math::deg2rad(light->param[VS::LIGHT_PARAM_SPOT_ANGLE])) * len; return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); - } break; + }; case VS::LIGHT_OMNI: { float r = light->param[VS::LIGHT_PARAM_RANGE]; return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2); - } break; + }; case VS::LIGHT_DIRECTIONAL: { return AABB(); - } break; + }; } ERR_FAIL_V(AABB()); - return AABB(); } /* PROBE API */ diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index fb3d154a7a..812e3711c5 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1008,7 +1008,8 @@ RID RasterizerSceneGLES3::light_instance_create(RID p_light) { if (!light_instance->light_ptr) { memdelete(light_instance); - ERR_FAIL_COND_V(!light_instance->light_ptr, RID()); + ERR_EXPLAIN("Condition ' !light_instance->light_ptr ' is true."); + ERR_FAIL_V(RID()); } light_instance->self = light_instance_owner.make_rid(light_instance); @@ -2763,9 +2764,7 @@ void RasterizerSceneGLES3::_setup_directional_light(int p_index, const Transform width /= 2; height /= 2; - if (j == 0) { - - } else if (j == 1) { + if (j == 1) { x += width; } else if (j == 2) { y += height; @@ -2778,9 +2777,7 @@ void RasterizerSceneGLES3::_setup_directional_light(int p_index, const Transform height /= 2; - if (j == 0) { - - } else { + if (j != 0) { y += height; } } @@ -4741,9 +4738,7 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_ width /= 2; height /= 2; - if (p_pass == 0) { - - } else if (p_pass == 1) { + if (p_pass == 1) { x += width; } else if (p_pass == 2) { y += height; diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 994ed25f01..57b4c198eb 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -5471,22 +5471,19 @@ AABB RasterizerStorageGLES3::light_get_aabb(RID p_light) const { float len = light->param[VS::LIGHT_PARAM_RANGE]; float size = Math::tan(Math::deg2rad(light->param[VS::LIGHT_PARAM_SPOT_ANGLE])) * len; return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); - } break; + }; case VS::LIGHT_OMNI: { float r = light->param[VS::LIGHT_PARAM_RANGE]; return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2); - } break; + }; case VS::LIGHT_DIRECTIONAL: { return AABB(); - } break; - default: { - } + }; } ERR_FAIL_V(AABB()); - return AABB(); } /* PROBE API */ |