diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-09-29 12:53:28 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-10-07 11:32:33 +0300 |
commit | 0103af1ddda6a2aa31227965141dd7d3a513e081 (patch) | |
tree | b0965bb65919bc1495ee02204a91e5ed3a9b56a7 /servers | |
parent | 5b7f62af55b7f322192f95258d825b163cbf9dc1 (diff) |
Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4.
Diffstat (limited to 'servers')
-rw-r--r-- | servers/audio/effects/audio_effect_eq.cpp | 6 | ||||
-rw-r--r-- | servers/navigation_server_3d.cpp | 20 | ||||
-rw-r--r-- | servers/physics_2d/godot_area_2d.cpp | 6 | ||||
-rw-r--r-- | servers/physics_2d/godot_body_2d.cpp | 16 | ||||
-rw-r--r-- | servers/physics_2d/godot_joints_2d.cpp | 6 | ||||
-rw-r--r-- | servers/physics_2d/godot_shape_2d.cpp | 66 | ||||
-rw-r--r-- | servers/physics_3d/godot_area_3d.cpp | 6 | ||||
-rw-r--r-- | servers/physics_3d/godot_body_3d.cpp | 30 | ||||
-rw-r--r-- | servers/physics_3d/godot_shape_3d.cpp | 76 | ||||
-rw-r--r-- | servers/rendering/renderer_canvas_cull.cpp | 32 | ||||
-rw-r--r-- | servers/rendering/renderer_canvas_cull.h | 4 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/renderer_scene_render_rd.cpp | 10 | ||||
-rw-r--r-- | servers/rendering/rendering_device_binds.h | 4 | ||||
-rw-r--r-- | servers/rendering/shader_compiler.cpp | 6 |
14 files changed, 139 insertions, 149 deletions
diff --git a/servers/audio/effects/audio_effect_eq.cpp b/servers/audio/effects/audio_effect_eq.cpp index 14ece8d93e..8a71ef0be7 100644 --- a/servers/audio/effects/audio_effect_eq.cpp +++ b/servers/audio/effects/audio_effect_eq.cpp @@ -128,8 +128,8 @@ AudioEffectEQ::AudioEffectEQ(EQ::Preset p_preset) { gain.resize(eq.get_band_count()); for (int i = 0; i < gain.size(); i++) { gain.write[i] = 0.0; - String name = "band_db/" + itos(eq.get_band_frequency(i)) + "_hz"; - prop_band_map[name] = i; - band_names.push_back(name); + String band_name = "band_db/" + itos(eq.get_band_frequency(i)) + "_hz"; + prop_band_map[band_name] = i; + band_names.push_back(band_name); } } diff --git a/servers/navigation_server_3d.cpp b/servers/navigation_server_3d.cpp index 783d32641e..cab8816747 100644 --- a/servers/navigation_server_3d.cpp +++ b/servers/navigation_server_3d.cpp @@ -190,12 +190,10 @@ Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_geometry_face_m bool enabled_geometry_face_random_color = get_debug_navigation_enable_geometry_face_random_color(); - Color debug_navigation_geometry_face_color = get_debug_navigation_geometry_face_color(); - Ref<StandardMaterial3D> face_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); face_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); face_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); - face_material->set_albedo(debug_navigation_geometry_face_color); + face_material->set_albedo(get_debug_navigation_geometry_face_color()); if (enabled_geometry_face_random_color) { face_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); face_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); @@ -213,11 +211,9 @@ Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_geometry_edge_m bool enabled_edge_lines_xray = get_debug_navigation_enable_edge_lines_xray(); - Color debug_navigation_geometry_edge_color = get_debug_navigation_geometry_edge_color(); - Ref<StandardMaterial3D> line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - line_material->set_albedo(debug_navigation_geometry_edge_color); + line_material->set_albedo(get_debug_navigation_geometry_edge_color()); if (enabled_edge_lines_xray) { line_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); } @@ -232,12 +228,10 @@ Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_geometry_face_d return debug_navigation_geometry_face_disabled_material; } - Color debug_navigation_geometry_face_disabled_color = get_debug_navigation_geometry_face_disabled_color(); - Ref<StandardMaterial3D> face_disabled_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); face_disabled_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); face_disabled_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); - face_disabled_material->set_albedo(debug_navigation_geometry_face_disabled_color); + face_disabled_material->set_albedo(get_debug_navigation_geometry_face_disabled_color()); debug_navigation_geometry_face_disabled_material = face_disabled_material; @@ -251,11 +245,9 @@ Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_geometry_edge_d bool enabled_edge_lines_xray = get_debug_navigation_enable_edge_lines_xray(); - Color debug_navigation_geometry_edge_disabled_color = get_debug_navigation_geometry_edge_disabled_color(); - Ref<StandardMaterial3D> line_disabled_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); line_disabled_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - line_disabled_material->set_albedo(debug_navigation_geometry_edge_disabled_color); + line_disabled_material->set_albedo(get_debug_navigation_geometry_edge_disabled_color()); if (enabled_edge_lines_xray) { line_disabled_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); } @@ -272,11 +264,9 @@ Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_edge_connection bool enabled_edge_connections_xray = get_debug_navigation_enable_edge_connections_xray(); - Color debug_navigation_edge_connection_color = get_debug_navigation_edge_connection_color(); - Ref<StandardMaterial3D> edge_connections_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); edge_connections_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - edge_connections_material->set_albedo(debug_navigation_edge_connection_color); + edge_connections_material->set_albedo(get_debug_navigation_edge_connection_color()); if (enabled_edge_connections_xray) { edge_connections_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); } diff --git a/servers/physics_2d/godot_area_2d.cpp b/servers/physics_2d/godot_area_2d.cpp index af90f96438..3fe062de57 100644 --- a/servers/physics_2d/godot_area_2d.cpp +++ b/servers/physics_2d/godot_area_2d.cpp @@ -304,12 +304,12 @@ void GodotArea2D::call_queries() { void GodotArea2D::compute_gravity(const Vector2 &p_position, Vector2 &r_gravity) const { if (is_gravity_point()) { - const real_t gravity_distance_scale = get_gravity_distance_scale(); + const real_t gr_distance_scale = get_gravity_distance_scale(); Vector2 v = get_transform().xform(get_gravity_vector()) - p_position; - if (gravity_distance_scale > 0) { + if (gr_distance_scale > 0) { const real_t v_length = v.length(); if (v_length > 0) { - const real_t v_scaled = v_length * gravity_distance_scale; + const real_t v_scaled = v_length * gr_distance_scale; r_gravity = (v.normalized() * (get_gravity() / (v_scaled * v_scaled))); } else { r_gravity = Vector2(); diff --git a/servers/physics_2d/godot_body_2d.cpp b/servers/physics_2d/godot_body_2d.cpp index 90124cd991..4422be959a 100644 --- a/servers/physics_2d/godot_body_2d.cpp +++ b/servers/physics_2d/godot_body_2d.cpp @@ -65,10 +65,10 @@ void GodotBody2D::update_mass_properties() { real_t area = get_shape_aabb(i).get_area(); - real_t mass = area * this->mass / total_area; + real_t mass_new = area * mass / total_area; // NOTE: we assume that the shape origin is also its center of mass. - center_of_mass_local += mass * get_shape_transform(i).get_origin(); + center_of_mass_local += mass_new * get_shape_transform(i).get_origin(); } center_of_mass_local /= mass; @@ -90,12 +90,12 @@ void GodotBody2D::update_mass_properties() { continue; } - real_t mass = area * this->mass / total_area; + real_t mass_new = area * mass / total_area; Transform2D mtx = get_shape_transform(i); Vector2 scale = mtx.get_scale(); Vector2 shape_origin = mtx.get_origin() - center_of_mass_local; - inertia += shape->get_moment_of_inertia(mass, scale) + mass * shape_origin.length_squared(); + inertia += shape->get_moment_of_inertia(mass_new, scale) + mass_new * shape_origin.length_squared(); } } @@ -578,14 +578,14 @@ void GodotBody2D::integrate_forces(real_t p_step) { damp = 0; } - real_t angular_damp = 1.0 - p_step * total_angular_damp; + real_t angular_damp_new = 1.0 - p_step * total_angular_damp; - if (angular_damp < 0) { // reached zero in the given time - angular_damp = 0; + if (angular_damp_new < 0) { // reached zero in the given time + angular_damp_new = 0; } linear_velocity *= damp; - angular_velocity *= angular_damp; + angular_velocity *= angular_damp_new; linear_velocity += _inv_mass * force * p_step; angular_velocity += _inv_inertia * torque * p_step; diff --git a/servers/physics_2d/godot_joints_2d.cpp b/servers/physics_2d/godot_joints_2d.cpp index 0c21b08ea9..34eb66500d 100644 --- a/servers/physics_2d/godot_joints_2d.cpp +++ b/servers/physics_2d/godot_joints_2d.cpp @@ -436,13 +436,13 @@ void GodotDampedSpringJoint2D::solve(real_t p_step) { // not 100% certain this is derived correctly, though it makes sense real_t v_damp = -vrn * v_coef; target_vrn = vrn + v_damp; - Vector2 j = n * v_damp * n_mass; + Vector2 j_new = n * v_damp * n_mass; if (dynamic_A) { - A->apply_impulse(-j, rA); + A->apply_impulse(-j_new, rA); } if (dynamic_B) { - B->apply_impulse(j, rB); + B->apply_impulse(j_new, rB); } } diff --git a/servers/physics_2d/godot_shape_2d.cpp b/servers/physics_2d/godot_shape_2d.cpp index 72ade3757b..da414ae233 100644 --- a/servers/physics_2d/godot_shape_2d.cpp +++ b/servers/physics_2d/godot_shape_2d.cpp @@ -225,16 +225,16 @@ void GodotSegmentShape2D::set_data(const Variant &p_data) { b = r.size; n = (b - a).orthogonal(); - Rect2 aabb; - aabb.position = a; - aabb.expand_to(b); - if (aabb.size.x == 0) { - aabb.size.x = 0.001; + Rect2 aabb_new; + aabb_new.position = a; + aabb_new.expand_to(b); + if (aabb_new.size.x == 0) { + aabb_new.size.x = 0.001; } - if (aabb.size.y == 0) { - aabb.size.y = 0.001; + if (aabb_new.size.y == 0) { + aabb_new.size.y = 0.001; } - configure(aabb); + configure(aabb_new); } Variant GodotSegmentShape2D::get_data() const { @@ -564,13 +564,13 @@ bool GodotConvexPolygonShape2D::intersect_segment(const Vector2 &p_begin, const real_t GodotConvexPolygonShape2D::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const { ERR_FAIL_COND_V_MSG(point_count == 0, 0, "Convex polygon shape has no points."); - Rect2 aabb; - aabb.position = points[0].pos * p_scale; + Rect2 aabb_new; + aabb_new.position = points[0].pos * p_scale; for (int i = 0; i < point_count; i++) { - aabb.expand_to(points[i].pos * p_scale); + aabb_new.expand_to(points[i].pos * p_scale); } - return p_mass * aabb.size.dot(aabb.size) / 12.0; + return p_mass * aabb_new.size.dot(aabb_new.size) / 12.0; } void GodotConvexPolygonShape2D::set_data(const Variant &p_data) { @@ -620,13 +620,13 @@ void GodotConvexPolygonShape2D::set_data(const Variant &p_data) { } ERR_FAIL_COND(point_count == 0); - Rect2 aabb; - aabb.position = points[0].pos; + Rect2 aabb_new; + aabb_new.position = points[0].pos; for (int i = 1; i < point_count; i++) { - aabb.expand_to(points[i].pos); + aabb_new.expand_to(points[i].pos); } - configure(aabb); + configure(aabb_new); } Variant GodotConvexPolygonShape2D::get_data() const { @@ -705,18 +705,18 @@ bool GodotConcavePolygonShape2D::intersect_segment(const Vector2 &p_begin, const stack[0] = 0; while (true) { uint32_t node = stack[level] & NODE_IDX_MASK; - const BVH &bvh = bvhptr[node]; + const BVH &bvh2 = bvhptr[node]; bool done = false; switch (stack[level] >> VISITED_BIT_SHIFT) { case TEST_AABB_BIT: { - bool valid = bvh.aabb.intersects_segment(p_begin, p_end); + bool valid = bvh2.aabb.intersects_segment(p_begin, p_end); if (!valid) { stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node; } else { - if (bvh.left < 0) { - const Segment &s = segmentptr[bvh.right]; + if (bvh2.left < 0) { + const Segment &s = segmentptr[bvh2.right]; Vector2 a = pointptr[s.points[0]]; Vector2 b = pointptr[s.points[1]]; @@ -742,13 +742,13 @@ bool GodotConcavePolygonShape2D::intersect_segment(const Vector2 &p_begin, const continue; case VISIT_LEFT_BIT: { stack[level] = (VISIT_RIGHT_BIT << VISITED_BIT_SHIFT) | node; - stack[level + 1] = bvh.left | TEST_AABB_BIT; + stack[level + 1] = bvh2.left | TEST_AABB_BIT; level++; } continue; case VISIT_RIGHT_BIT: { stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node; - stack[level + 1] = bvh.right | TEST_AABB_BIT; + stack[level + 1] = bvh2.right | TEST_AABB_BIT; level++; } continue; @@ -822,7 +822,7 @@ void GodotConcavePolygonShape2D::set_data(const Variant &p_data) { ERR_FAIL_COND(p_data.get_type() != Variant::PACKED_VECTOR2_ARRAY && p_data.get_type() != Variant::PACKED_FLOAT32_ARRAY); #endif - Rect2 aabb; + Rect2 aabb_new; if (p_data.get_type() == Variant::PACKED_VECTOR2_ARRAY) { Vector<Vector2> p2arr = p_data; @@ -835,7 +835,7 @@ void GodotConcavePolygonShape2D::set_data(const Variant &p_data) { bvh_depth = 1; if (len == 0) { - configure(aabb); + configure(aabb_new); return; } @@ -868,9 +868,9 @@ void GodotConcavePolygonShape2D::set_data(const Variant &p_data) { } points.resize(pointmap.size()); - aabb.position = pointmap.begin()->key; + aabb_new.position = pointmap.begin()->key; for (const KeyValue<Point2, int> &E : pointmap) { - aabb.expand_to(E.key); + aabb_new.expand_to(E.key); points.write[E.value] = E.key; } @@ -889,7 +889,7 @@ void GodotConcavePolygonShape2D::set_data(const Variant &p_data) { //dictionary with arrays } - configure(aabb); + configure(aabb_new); } Variant GodotConcavePolygonShape2D::get_data() const { @@ -937,17 +937,17 @@ void GodotConcavePolygonShape2D::cull(const Rect2 &p_local_aabb, QueryCallback p stack[0] = 0; while (true) { uint32_t node = stack[level] & NODE_IDX_MASK; - const BVH &bvh = bvhptr[node]; + const BVH &bvh2 = bvhptr[node]; switch (stack[level] >> VISITED_BIT_SHIFT) { case TEST_AABB_BIT: { - bool valid = p_local_aabb.intersects(bvh.aabb); + bool valid = p_local_aabb.intersects(bvh2.aabb); if (!valid) { stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node; } else { - if (bvh.left < 0) { - const Segment &s = segmentptr[bvh.right]; + if (bvh2.left < 0) { + const Segment &s = segmentptr[bvh2.right]; Vector2 a = pointptr[s.points[0]]; Vector2 b = pointptr[s.points[1]]; @@ -966,13 +966,13 @@ void GodotConcavePolygonShape2D::cull(const Rect2 &p_local_aabb, QueryCallback p continue; case VISIT_LEFT_BIT: { stack[level] = (VISIT_RIGHT_BIT << VISITED_BIT_SHIFT) | node; - stack[level + 1] = bvh.left | TEST_AABB_BIT; + stack[level + 1] = bvh2.left | TEST_AABB_BIT; level++; } continue; case VISIT_RIGHT_BIT: { stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node; - stack[level + 1] = bvh.right | TEST_AABB_BIT; + stack[level + 1] = bvh2.right | TEST_AABB_BIT; level++; } continue; diff --git a/servers/physics_3d/godot_area_3d.cpp b/servers/physics_3d/godot_area_3d.cpp index 9765d0bf58..d4d3b3e6aa 100644 --- a/servers/physics_3d/godot_area_3d.cpp +++ b/servers/physics_3d/godot_area_3d.cpp @@ -333,12 +333,12 @@ void GodotArea3D::call_queries() { void GodotArea3D::compute_gravity(const Vector3 &p_position, Vector3 &r_gravity) const { if (is_gravity_point()) { - const real_t gravity_distance_scale = get_gravity_distance_scale(); + const real_t gr_distance_scale = get_gravity_distance_scale(); Vector3 v = get_transform().xform(get_gravity_vector()) - p_position; - if (gravity_distance_scale > 0) { + if (gr_distance_scale > 0) { const real_t v_length = v.length(); if (v_length > 0) { - const real_t v_scaled = v_length * gravity_distance_scale; + const real_t v_scaled = v_length * gr_distance_scale; r_gravity = (v.normalized() * (get_gravity() / (v_scaled * v_scaled))); } else { r_gravity = Vector3(); diff --git a/servers/physics_3d/godot_body_3d.cpp b/servers/physics_3d/godot_body_3d.cpp index 19f065c319..cec233d95b 100644 --- a/servers/physics_3d/godot_body_3d.cpp +++ b/servers/physics_3d/godot_body_3d.cpp @@ -78,10 +78,10 @@ void GodotBody3D::update_mass_properties() { real_t area = get_shape_area(i); - real_t mass = area * this->mass / total_area; + real_t mass_new = area * mass / total_area; // NOTE: we assume that the shape origin is also its center of mass. - center_of_mass_local += mass * get_shape_transform(i).origin; + center_of_mass_local += mass_new * get_shape_transform(i).origin; } center_of_mass_local /= mass; @@ -108,9 +108,9 @@ void GodotBody3D::update_mass_properties() { const GodotShape3D *shape = get_shape(i); - real_t mass = area * this->mass / total_area; + real_t mass_new = area * mass / total_area; - Basis shape_inertia_tensor = Basis::from_scale(shape->get_moment_of_inertia(mass)); + Basis shape_inertia_tensor = Basis::from_scale(shape->get_moment_of_inertia(mass_new)); Transform3D shape_transform = get_shape_transform(i); Basis shape_basis = shape_transform.basis.orthonormalized(); @@ -637,14 +637,14 @@ void GodotBody3D::integrate_forces(real_t p_step) { damp = 0; } - real_t angular_damp = 1.0 - p_step * total_angular_damp; + real_t angular_damp_new = 1.0 - p_step * total_angular_damp; - if (angular_damp < 0) { // reached zero in the given time - angular_damp = 0; + if (angular_damp_new < 0) { // reached zero in the given time + angular_damp_new = 0; } linear_velocity *= damp; - angular_velocity *= angular_damp; + angular_velocity *= angular_damp_new; linear_velocity += _inv_mass * force * p_step; angular_velocity += _inv_inertia_tensor.xform(torque) * p_step; @@ -707,27 +707,27 @@ void GodotBody3D::integrate_velocities(real_t p_step) { Vector3 total_angular_velocity = angular_velocity + biased_angular_velocity; real_t ang_vel = total_angular_velocity.length(); - Transform3D transform = get_transform(); + Transform3D transform_new = get_transform(); if (!Math::is_zero_approx(ang_vel)) { Vector3 ang_vel_axis = total_angular_velocity / ang_vel; Basis rot(ang_vel_axis, ang_vel * p_step); Basis identity3(1, 0, 0, 0, 1, 0, 0, 0, 1); - transform.origin += ((identity3 - rot) * transform.basis).xform(center_of_mass_local); - transform.basis = rot * transform.basis; - transform.orthonormalize(); + transform_new.origin += ((identity3 - rot) * transform_new.basis).xform(center_of_mass_local); + transform_new.basis = rot * transform_new.basis; + transform_new.orthonormalize(); } Vector3 total_linear_velocity = linear_velocity + biased_linear_velocity; /*for(int i=0;i<3;i++) { if (axis_lock&(1<<i)) { - transform.origin[i]=0.0; + transform_new.origin[i]=0.0; } }*/ - transform.origin += total_linear_velocity * p_step; + transform_new.origin += total_linear_velocity * p_step; - _set_transform(transform); + _set_transform(transform_new); _set_inv_transform(get_transform().inverse()); _update_transform_dependent(); diff --git a/servers/physics_3d/godot_shape_3d.cpp b/servers/physics_3d/godot_shape_3d.cpp index 5574be20b7..e051c688fa 100644 --- a/servers/physics_3d/godot_shape_3d.cpp +++ b/servers/physics_3d/godot_shape_3d.cpp @@ -411,9 +411,9 @@ void GodotBoxShape3D::get_supports(const Vector3 &p_normal, int p_max, Vector3 * } bool GodotBoxShape3D::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal, bool p_hit_back_faces) const { - AABB aabb(-half_extents, half_extents * 2.0); + AABB aabb_ext(-half_extents, half_extents * 2.0); - return aabb.intersects_segment(p_begin, p_end, &r_result, &r_normal); + return aabb_ext.intersects_segment(p_begin, p_end, &r_result, &r_normal); } bool GodotBoxShape3D::intersect_point(const Vector3 &p_point) const { @@ -1259,14 +1259,14 @@ Vector3 GodotConcavePolygonShape3D::get_support(const Vector3 &p_normal) const { } void GodotConcavePolygonShape3D::_cull_segment(int p_idx, _SegmentCullParams *p_params) const { - const BVH *bvh = &p_params->bvh[p_idx]; + const BVH *params_bvh = &p_params->bvh[p_idx]; - if (!bvh->aabb.intersects_segment(p_params->from, p_params->to)) { + if (!params_bvh->aabb.intersects_segment(p_params->from, p_params->to)) { return; } - if (bvh->face_index >= 0) { - const Face *f = &p_params->faces[bvh->face_index]; + if (params_bvh->face_index >= 0) { + const Face *f = &p_params->faces[params_bvh->face_index]; GodotFaceShape3D *face = p_params->face; face->normal = f->normal; face->vertex[0] = p_params->vertices[f->indices[0]]; @@ -1285,11 +1285,11 @@ void GodotConcavePolygonShape3D::_cull_segment(int p_idx, _SegmentCullParams *p_ } } } else { - if (bvh->left >= 0) { - _cull_segment(bvh->left, p_params); + if (params_bvh->left >= 0) { + _cull_segment(params_bvh->left, p_params); } - if (bvh->right >= 0) { - _cull_segment(bvh->right, p_params); + if (params_bvh->right >= 0) { + _cull_segment(params_bvh->right, p_params); } } } @@ -1339,14 +1339,14 @@ Vector3 GodotConcavePolygonShape3D::get_closest_point_to(const Vector3 &p_point) } bool GodotConcavePolygonShape3D::_cull(int p_idx, _CullParams *p_params) const { - const BVH *bvh = &p_params->bvh[p_idx]; + const BVH *params_bvh = &p_params->bvh[p_idx]; - if (!p_params->aabb.intersects(bvh->aabb)) { + if (!p_params->aabb.intersects(params_bvh->aabb)) { return false; } - if (bvh->face_index >= 0) { - const Face *f = &p_params->faces[bvh->face_index]; + if (params_bvh->face_index >= 0) { + const Face *f = &p_params->faces[params_bvh->face_index]; GodotFaceShape3D *face = p_params->face; face->normal = f->normal; face->vertex[0] = p_params->vertices[f->indices[0]]; @@ -1356,14 +1356,14 @@ bool GodotConcavePolygonShape3D::_cull(int p_idx, _CullParams *p_params) const { return true; } } else { - if (bvh->left >= 0) { - if (_cull(bvh->left, p_params)) { + if (params_bvh->left >= 0) { + if (_cull(params_bvh->left, p_params)) { return true; } } - if (bvh->right >= 0) { - if (_cull(bvh->right, p_params)) { + if (params_bvh->right >= 0) { + if (_cull(params_bvh->right, p_params)) { return true; } } @@ -1919,14 +1919,14 @@ Vector3 GodotHeightMapShape3D::get_closest_point_to(const Vector3 &p_point) cons } void GodotHeightMapShape3D::_get_cell(const Vector3 &p_point, int &r_x, int &r_y, int &r_z) const { - const AABB &aabb = get_aabb(); + const AABB &shape_aabb = get_aabb(); - Vector3 pos_local = aabb.position + local_origin; + Vector3 pos_local = shape_aabb.position + local_origin; Vector3 clamped_point(p_point); - clamped_point.x = CLAMP(p_point.x, pos_local.x, pos_local.x + aabb.size.x); - clamped_point.y = CLAMP(p_point.y, pos_local.y, pos_local.y + aabb.size.y); - clamped_point.z = CLAMP(p_point.z, pos_local.z, pos_local.x + aabb.size.z); + clamped_point.x = CLAMP(p_point.x, pos_local.x, pos_local.x + shape_aabb.size.x); + clamped_point.y = CLAMP(p_point.y, pos_local.y, pos_local.y + shape_aabb.size.y); + clamped_point.z = CLAMP(p_point.z, pos_local.z, pos_local.x + shape_aabb.size.z); r_x = (clamped_point.x < 0.0) ? (clamped_point.x - 0.5) : (clamped_point.x + 0.5); r_y = (clamped_point.y < 0.0) ? (clamped_point.y - 0.5) : (clamped_point.y + 0.5); @@ -2070,19 +2070,19 @@ void GodotHeightMapShape3D::_setup(const Vector<real_t> &p_heights, int p_width, depth = p_depth; // Initialize aabb. - AABB aabb; - aabb.position = Vector3(0.0, p_min_height, 0.0); - aabb.size = Vector3(p_width - 1, p_max_height - p_min_height, p_depth - 1); + AABB aabb_new; + aabb_new.position = Vector3(0.0, p_min_height, 0.0); + aabb_new.size = Vector3(p_width - 1, p_max_height - p_min_height, p_depth - 1); // Initialize origin as the aabb center. - local_origin = aabb.position + 0.5 * aabb.size; + local_origin = aabb_new.position + 0.5 * aabb_new.size; local_origin.y = 0.0; - aabb.position -= local_origin; + aabb_new.position -= local_origin; _build_accelerator(); - configure(aabb); + configure(aabb_new); } void GodotHeightMapShape3D::set_data(const Variant &p_data) { @@ -2093,11 +2093,11 @@ void GodotHeightMapShape3D::set_data(const Variant &p_data) { ERR_FAIL_COND(!d.has("depth")); ERR_FAIL_COND(!d.has("heights")); - int width = d["width"]; - int depth = d["depth"]; + int width_new = d["width"]; + int depth_new = d["depth"]; - ERR_FAIL_COND(width <= 0.0); - ERR_FAIL_COND(depth <= 0.0); + ERR_FAIL_COND(width_new <= 0.0); + ERR_FAIL_COND(depth_new <= 0.0); Variant heights_variant = d["heights"]; Vector<real_t> heights_buffer; @@ -2151,10 +2151,10 @@ void GodotHeightMapShape3D::set_data(const Variant &p_data) { ERR_FAIL_COND(min_height > max_height); - ERR_FAIL_COND(heights_buffer.size() != (width * depth)); + ERR_FAIL_COND(heights_buffer.size() != (width_new * depth_new)); // If specified, min and max height will be used as precomputed values. - _setup(heights_buffer, width, depth, min_height, max_height); + _setup(heights_buffer, width_new, depth_new, min_height, max_height); } Variant GodotHeightMapShape3D::get_data() const { @@ -2162,9 +2162,9 @@ Variant GodotHeightMapShape3D::get_data() const { d["width"] = width; d["depth"] = depth; - const AABB &aabb = get_aabb(); - d["min_height"] = aabb.position.y; - d["max_height"] = aabb.position.y + aabb.size.y; + const AABB &shape_aabb = get_aabb(); + d["min_height"] = shape_aabb.position.y; + d["max_height"] = shape_aabb.position.y + shape_aabb.size.y; d["heights"] = heights; diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp index c5818d9290..ffd8f695c6 100644 --- a/servers/rendering/renderer_canvas_cull.cpp +++ b/servers/rendering/renderer_canvas_cull.cpp @@ -114,16 +114,16 @@ void _mark_ysort_dirty(RendererCanvasCull::Item *ysort_owner, RID_Owner<Renderer } while (ysort_owner && ysort_owner->sort_y); } -void RendererCanvasCull::_attach_canvas_item_for_draw(RendererCanvasCull::Item *ci, RendererCanvasCull::Item *p_canvas_clip, RendererCanvasRender::Item **z_list, RendererCanvasRender::Item **z_last_list, const Transform2D &xform, const Rect2 &p_clip_rect, Rect2 global_rect, const Color &modulate, int p_z, RendererCanvasCull::Item *p_material_owner, bool use_canvas_group, RendererCanvasRender::Item *canvas_group_from, const Transform2D &p_xform) { +void RendererCanvasCull::_attach_canvas_item_for_draw(RendererCanvasCull::Item *ci, RendererCanvasCull::Item *p_canvas_clip, RendererCanvasRender::Item **r_z_list, RendererCanvasRender::Item **r_z_last_list, const Transform2D &xform, const Rect2 &p_clip_rect, Rect2 global_rect, const Color &modulate, int p_z, RendererCanvasCull::Item *p_material_owner, bool p_use_canvas_group, RendererCanvasRender::Item *canvas_group_from, const Transform2D &p_xform) { if (ci->copy_back_buffer) { ci->copy_back_buffer->screen_rect = xform.xform(ci->copy_back_buffer->rect).intersection(p_clip_rect); } - if (use_canvas_group) { + if (p_use_canvas_group) { int zidx = p_z - RS::CANVAS_ITEM_Z_MIN; if (canvas_group_from == nullptr) { // no list before processing this item, means must put stuff in group from the beginning of list. - canvas_group_from = z_list[zidx]; + canvas_group_from = r_z_list[zidx]; } else { // there was a list before processing, so begin group from this one. canvas_group_from = canvas_group_from->next; @@ -198,13 +198,13 @@ void RendererCanvasCull::_attach_canvas_item_for_draw(RendererCanvasCull::Item * int zidx = p_z - RS::CANVAS_ITEM_Z_MIN; - if (z_last_list[zidx]) { - z_last_list[zidx]->next = ci; - z_last_list[zidx] = ci; + if (r_z_last_list[zidx]) { + r_z_last_list[zidx]->next = ci; + r_z_last_list[zidx] = ci; } else { - z_list[zidx] = ci; - z_last_list[zidx] = ci; + r_z_list[zidx] = ci; + r_z_last_list[zidx] = ci; } ci->z_final = p_z; @@ -223,7 +223,7 @@ void RendererCanvasCull::_attach_canvas_item_for_draw(RendererCanvasCull::Item * } } -void RendererCanvasCull::_cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RendererCanvasRender::Item **z_list, RendererCanvasRender::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner, bool allow_y_sort) { +void RendererCanvasCull::_cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RendererCanvasRender::Item **r_z_list, RendererCanvasRender::Item **r_z_last_list, Item *p_canvas_clip, Item *p_material_owner, bool allow_y_sort) { Item *ci = p_canvas_item; if (!ci->visible) { @@ -313,38 +313,38 @@ void RendererCanvasCull::_cull_canvas_item(Item *p_canvas_item, const Transform2 sorter.sort(child_items, child_item_count); for (i = 0; i < child_item_count; i++) { - _cull_canvas_item(child_items[i], xform * child_items[i]->ysort_xform, p_clip_rect, modulate, child_items[i]->ysort_parent_abs_z_index, z_list, z_last_list, (Item *)ci->final_clip_owner, (Item *)child_items[i]->material_owner, false); + _cull_canvas_item(child_items[i], xform * child_items[i]->ysort_xform, p_clip_rect, modulate, child_items[i]->ysort_parent_abs_z_index, r_z_list, r_z_last_list, (Item *)ci->final_clip_owner, (Item *)child_items[i]->material_owner, false); } } else { RendererCanvasRender::Item *canvas_group_from = nullptr; bool use_canvas_group = ci->canvas_group != nullptr && (ci->canvas_group->fit_empty || ci->commands != nullptr); if (use_canvas_group) { int zidx = p_z - RS::CANVAS_ITEM_Z_MIN; - canvas_group_from = z_last_list[zidx]; + canvas_group_from = r_z_last_list[zidx]; } - _attach_canvas_item_for_draw(ci, p_canvas_clip, z_list, z_last_list, xform, p_clip_rect, global_rect, modulate, p_z, p_material_owner, use_canvas_group, canvas_group_from, xform); + _attach_canvas_item_for_draw(ci, p_canvas_clip, r_z_list, r_z_last_list, xform, p_clip_rect, global_rect, modulate, p_z, p_material_owner, use_canvas_group, canvas_group_from, xform); } } else { RendererCanvasRender::Item *canvas_group_from = nullptr; bool use_canvas_group = ci->canvas_group != nullptr && (ci->canvas_group->fit_empty || ci->commands != nullptr); if (use_canvas_group) { int zidx = p_z - RS::CANVAS_ITEM_Z_MIN; - canvas_group_from = z_last_list[zidx]; + canvas_group_from = r_z_last_list[zidx]; } for (int i = 0; i < child_item_count; i++) { if (!child_items[i]->behind && !use_canvas_group) { continue; } - _cull_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, p_material_owner, true); + _cull_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, r_z_list, r_z_last_list, (Item *)ci->final_clip_owner, p_material_owner, true); } - _attach_canvas_item_for_draw(ci, p_canvas_clip, z_list, z_last_list, xform, p_clip_rect, global_rect, modulate, p_z, p_material_owner, use_canvas_group, canvas_group_from, xform); + _attach_canvas_item_for_draw(ci, p_canvas_clip, r_z_list, r_z_last_list, xform, p_clip_rect, global_rect, modulate, p_z, p_material_owner, use_canvas_group, canvas_group_from, xform); for (int i = 0; i < child_item_count; i++) { if (child_items[i]->behind || use_canvas_group) { continue; } - _cull_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, p_material_owner, true); + _cull_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, r_z_list, r_z_last_list, (Item *)ci->final_clip_owner, p_material_owner, true); } } } diff --git a/servers/rendering/renderer_canvas_cull.h b/servers/rendering/renderer_canvas_cull.h index 0d6a4006f8..7a01fad9de 100644 --- a/servers/rendering/renderer_canvas_cull.h +++ b/servers/rendering/renderer_canvas_cull.h @@ -176,11 +176,11 @@ public: PagedAllocator<Item::VisibilityNotifierData> visibility_notifier_allocator; SelfList<Item::VisibilityNotifierData>::List visibility_notifier_list; - _FORCE_INLINE_ void _attach_canvas_item_for_draw(Item *ci, Item *p_canvas_clip, RendererCanvasRender::Item **z_list, RendererCanvasRender::Item **z_last_list, const Transform2D &xform, const Rect2 &p_clip_rect, Rect2 global_rect, const Color &modulate, int p_z, RendererCanvasCull::Item *p_material_owner, bool use_canvas_group, RendererCanvasRender::Item *canvas_group_from, const Transform2D &p_xform); + _FORCE_INLINE_ void _attach_canvas_item_for_draw(Item *ci, Item *p_canvas_clip, RendererCanvasRender::Item **r_z_list, RendererCanvasRender::Item **r_z_last_list, const Transform2D &xform, const Rect2 &p_clip_rect, Rect2 global_rect, const Color &modulate, int p_z, RendererCanvasCull::Item *p_material_owner, bool p_use_canvas_group, RendererCanvasRender::Item *canvas_group_from, const Transform2D &p_xform); private: void _render_canvas_item_tree(RID p_to_render_target, Canvas::ChildItem *p_child_items, int p_child_item_count, Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RendererCanvasRender::Light *p_lights, RendererCanvasRender::Light *p_directional_lights, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel); - void _cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RendererCanvasRender::Item **z_list, RendererCanvasRender::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner, bool allow_y_sort); + void _cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RendererCanvasRender::Item **r_z_list, RendererCanvasRender::Item **r_z_last_list, Item *p_canvas_clip, Item *p_material_owner, bool allow_y_sort); RendererCanvasRender::Item **z_list; RendererCanvasRender::Item **z_last_list; diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index 6157d7d840..061263ef76 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -1279,8 +1279,8 @@ TypedArray<Image> RendererSceneRenderRD::bake_render_uv2(RID p_base, const Typed //RID sampled_light; - RenderGeometryInstance *gi = geometry_instance_create(p_base); - ERR_FAIL_NULL_V(gi, TypedArray<Image>()); + RenderGeometryInstance *gi_inst = geometry_instance_create(p_base); + ERR_FAIL_NULL_V(gi_inst, TypedArray<Image>()); uint32_t sc = RSG::mesh_storage->mesh_get_surface_count(p_base); Vector<RID> materials; @@ -1292,15 +1292,15 @@ TypedArray<Image> RendererSceneRenderRD::bake_render_uv2(RID p_base, const Typed } } - gi->set_surface_materials(materials); + gi_inst->set_surface_materials(materials); if (cull_argument.size() == 0) { cull_argument.push_back(nullptr); } - cull_argument[0] = gi; + cull_argument[0] = gi_inst; _render_uv2(cull_argument, fb, Rect2i(0, 0, p_image_size.width, p_image_size.height)); - geometry_instance_free(gi); + geometry_instance_free(gi_inst); TypedArray<Image> ret; diff --git a/servers/rendering/rendering_device_binds.h b/servers/rendering/rendering_device_binds.h index a56b7eb241..d95b46933c 100644 --- a/servers/rendering/rendering_device_binds.h +++ b/servers/rendering/rendering_device_binds.h @@ -407,10 +407,10 @@ protected: List<Variant> keys; p_versions.get_key_list(&keys); for (const Variant &E : keys) { - StringName name = E; + StringName vname = E; Ref<RDShaderSPIRV> bc = p_versions[E]; ERR_CONTINUE(bc.is_null()); - versions[name] = bc; + versions[vname] = bc; } emit_changed(); diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp index 1d83cc9de7..54cc7a011a 100644 --- a/servers/rendering/shader_compiler.cpp +++ b/servers/rendering/shader_compiler.cpp @@ -1369,11 +1369,11 @@ Error ShaderCompiler::compile(RS::ShaderMode p_mode, const String &p_code, Ident HashMap<String, Vector<String>> includes; includes[""] = Vector<String>(); Vector<String> include_stack; - Vector<String> shader = p_code.split("\n"); + Vector<String> shader_lines = p_code.split("\n"); // Reconstruct the files. - for (int i = 0; i < shader.size(); i++) { - String l = shader[i]; + for (int i = 0; i < shader_lines.size(); i++) { + String l = shader_lines[i]; if (l.begins_with("@@>")) { String inc_path = l.replace_first("@@>", ""); |