Merge pull request #24025 from aaronfranke/analyzer-errors
Fix many errors found by PVS-Studio
This commit is contained in:
@@ -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]) {
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
+12
-10
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user