diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2018-11-27 21:58:00 -0500 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2018-11-28 05:03:24 -0500 |
commit | cb01268562a47e6a1c32559f58fbadd46e52d304 (patch) | |
tree | 8466e05cbf670863759899e0fd7d67d6a44ca1cb /scene | |
parent | aa08ef2bed34510cfb18ce3e1e5cdd9c009981be (diff) |
Fix many errors found by PVS-Studio
Fix errors 2, 3, 4, 6, 8, 9, 11, 12, 13, 14, and 15.
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/cpu_particles.cpp | 8 | ||||
-rw-r--r-- | scene/3d/soft_body.cpp | 2 | ||||
-rw-r--r-- | scene/resources/texture.cpp | 22 |
3 files changed, 17 insertions, 15 deletions
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp index 8b4d201083..1269cef7c2 100644 --- a/scene/3d/cpu_particles.cpp +++ b/scene/3d/cpu_particles.cpp @@ -691,7 +691,7 @@ void CPUParticles::_particles_process(float p_delta) { if (flags[FLAG_DISABLE_Z]) { p.velocity.z = 0.0; - p.velocity.z = 0.0; + p.transform.origin.z = 0.0; } } else if (!p.active) { @@ -757,15 +757,15 @@ void CPUParticles::_particles_process(float p_delta) { } Vector3 force = gravity; - Vector3 pos = p.transform.origin; + Vector3 position = p.transform.origin; if (flags[FLAG_DISABLE_Z]) { - pos.z = 0.0; + position.z = 0.0; } //apply linear acceleration force += p.velocity.length() > 0.0 ? p.velocity.normalized() * (parameters[PARAM_LINEAR_ACCEL] + tex_linear_accel) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_LINEAR_ACCEL]) : Vector3(); //apply radial acceleration Vector3 org = emission_xform.origin; - Vector3 diff = pos - org; + Vector3 diff = position - org; force += diff.length() > 0.0 ? diff.normalized() * (parameters[PARAM_RADIAL_ACCEL] + tex_radial_accel) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_RADIAL_ACCEL]) : Vector3(); //apply tangential acceleration; if (flags[FLAG_DISABLE_Z]) { diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body.cpp index 1e730d0b3d..835a874323 100644 --- a/scene/3d/soft_body.cpp +++ b/scene/3d/soft_body.cpp @@ -401,7 +401,7 @@ String SoftBody::get_configuration_warning() const { } Transform t = get_transform(); - if ((ABS(t.basis.get_axis(0).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(1).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(0).length() - 1.0) > 0.05)) { + if ((ABS(t.basis.get_axis(0).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(1).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(2).length() - 1.0) > 0.05)) { if (!warning.empty()) warning += "\n\n"; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 682bfebdd2..4f4d375481 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -994,11 +994,11 @@ void AtlasTexture::_bind_methods() { void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { - Rect2 rc = region; - if (!atlas.is_valid()) return; + Rect2 rc = region; + if (rc.size.width == 0) { rc.size.width = atlas->get_width(); } @@ -1013,11 +1013,11 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { - Rect2 rc = region; - if (!atlas.is_valid()) return; + Rect2 rc = region; + if (rc.size.width == 0) { rc.size.width = atlas->get_width(); } @@ -1048,11 +1048,11 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const { - Rect2 rc = region; - if (!atlas.is_valid()) return false; + Rect2 rc = region; + Rect2 src = p_src_rect; if (src.size == Size2()) { src.size = rc.size; @@ -1084,11 +1084,13 @@ bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, bool AtlasTexture::is_pixel_opaque(int p_x, int p_y) const { - if (atlas.is_valid()) { - return atlas->is_pixel_opaque(p_x + region.position.x + margin.position.x, p_x + region.position.y + margin.position.y); - } + if (!atlas.is_valid()) + return true; - return true; + int x = p_x + region.position.x + margin.position.x; + int y = p_y + region.position.y + margin.position.y; + + return atlas->is_pixel_opaque(x, y); } AtlasTexture::AtlasTexture() { |