diff options
Diffstat (limited to 'scene')
78 files changed, 1178 insertions, 1188 deletions
diff --git a/scene/2d/audio_listener_2d.cpp b/scene/2d/audio_listener_2d.cpp index f7dd20d7c0..3cc64b2170 100644 --- a/scene/2d/audio_listener_2d.cpp +++ b/scene/2d/audio_listener_2d.cpp @@ -103,7 +103,6 @@ bool AudioListener2D::is_current() const { } else { return current; } - return false; } void AudioListener2D::_bind_methods() { diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 23948c2fd3..df75d34e0f 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -36,12 +36,12 @@ void CollisionObject2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - Transform2D global_transform = get_global_transform(); + Transform2D gl_transform = get_global_transform(); if (area) { - PhysicsServer2D::get_singleton()->area_set_transform(rid, global_transform); + PhysicsServer2D::get_singleton()->area_set_transform(rid, gl_transform); } else { - PhysicsServer2D::get_singleton()->body_set_state(rid, PhysicsServer2D::BODY_STATE_TRANSFORM, global_transform); + PhysicsServer2D::get_singleton()->body_set_state(rid, PhysicsServer2D::BODY_STATE_TRANSFORM, gl_transform); } bool disabled = !is_enabled(); @@ -81,12 +81,12 @@ void CollisionObject2D::_notification(int p_what) { return; } - Transform2D global_transform = get_global_transform(); + Transform2D gl_transform = get_global_transform(); if (area) { - PhysicsServer2D::get_singleton()->area_set_transform(rid, global_transform); + PhysicsServer2D::get_singleton()->area_set_transform(rid, gl_transform); } else { - PhysicsServer2D::get_singleton()->body_set_state(rid, PhysicsServer2D::BODY_STATE_TRANSFORM, global_transform); + PhysicsServer2D::get_singleton()->body_set_state(rid, PhysicsServer2D::BODY_STATE_TRANSFORM, gl_transform); } } break; @@ -153,13 +153,13 @@ uint32_t CollisionObject2D::get_collision_mask() const { void CollisionObject2D::set_collision_layer_value(int p_layer_number, bool p_value) { ERR_FAIL_COND_MSG(p_layer_number < 1, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_MSG(p_layer_number > 32, "Collision layer number must be between 1 and 32 inclusive."); - uint32_t collision_layer = get_collision_layer(); + uint32_t collision_layer_new = get_collision_layer(); if (p_value) { - collision_layer |= 1 << (p_layer_number - 1); + collision_layer_new |= 1 << (p_layer_number - 1); } else { - collision_layer &= ~(1 << (p_layer_number - 1)); + collision_layer_new &= ~(1 << (p_layer_number - 1)); } - set_collision_layer(collision_layer); + set_collision_layer(collision_layer_new); } bool CollisionObject2D::get_collision_layer_value(int p_layer_number) const { diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index eece90190b..c6296f4732 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -1162,74 +1162,73 @@ void CPUParticles2D::_notification(int p_what) { } void CPUParticles2D::convert_from_particles(Node *p_particles) { - GPUParticles2D *particles = Object::cast_to<GPUParticles2D>(p_particles); - ERR_FAIL_COND_MSG(!particles, "Only GPUParticles2D nodes can be converted to CPUParticles2D."); - - set_emitting(particles->is_emitting()); - set_amount(particles->get_amount()); - set_lifetime(particles->get_lifetime()); - set_one_shot(particles->get_one_shot()); - set_pre_process_time(particles->get_pre_process_time()); - set_explosiveness_ratio(particles->get_explosiveness_ratio()); - set_randomness_ratio(particles->get_randomness_ratio()); - set_use_local_coordinates(particles->get_use_local_coordinates()); - set_fixed_fps(particles->get_fixed_fps()); - set_fractional_delta(particles->get_fractional_delta()); - set_speed_scale(particles->get_speed_scale()); - set_draw_order(DrawOrder(particles->get_draw_order())); - set_texture(particles->get_texture()); - - Ref<Material> mat = particles->get_material(); + GPUParticles2D *gpu_particles = Object::cast_to<GPUParticles2D>(p_particles); + ERR_FAIL_COND_MSG(!gpu_particles, "Only GPUParticles2D nodes can be converted to CPUParticles2D."); + + set_emitting(gpu_particles->is_emitting()); + set_amount(gpu_particles->get_amount()); + set_lifetime(gpu_particles->get_lifetime()); + set_one_shot(gpu_particles->get_one_shot()); + set_pre_process_time(gpu_particles->get_pre_process_time()); + set_explosiveness_ratio(gpu_particles->get_explosiveness_ratio()); + set_randomness_ratio(gpu_particles->get_randomness_ratio()); + set_use_local_coordinates(gpu_particles->get_use_local_coordinates()); + set_fixed_fps(gpu_particles->get_fixed_fps()); + set_fractional_delta(gpu_particles->get_fractional_delta()); + set_speed_scale(gpu_particles->get_speed_scale()); + set_draw_order(DrawOrder(gpu_particles->get_draw_order())); + set_texture(gpu_particles->get_texture()); + + Ref<Material> mat = gpu_particles->get_material(); if (mat.is_valid()) { set_material(mat); } - Ref<ParticleProcessMaterial> material = particles->get_process_material(); - if (material.is_null()) { + Ref<ParticleProcessMaterial> proc_mat = gpu_particles->get_process_material(); + if (proc_mat.is_null()) { return; } - Vector3 dir = material->get_direction(); + Vector3 dir = proc_mat->get_direction(); set_direction(Vector2(dir.x, dir.y)); - set_spread(material->get_spread()); + set_spread(proc_mat->get_spread()); - set_color(material->get_color()); + set_color(proc_mat->get_color()); - Ref<GradientTexture1D> gt = material->get_color_ramp(); + Ref<GradientTexture1D> gt = proc_mat->get_color_ramp(); if (gt.is_valid()) { set_color_ramp(gt->get_gradient()); } - Ref<GradientTexture1D> gti = material->get_color_initial_ramp(); + Ref<GradientTexture1D> gti = proc_mat->get_color_initial_ramp(); if (gti.is_valid()) { set_color_initial_ramp(gti->get_gradient()); } - set_particle_flag(PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY, material->get_particle_flag(ParticleProcessMaterial::PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY)); + set_particle_flag(PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY, proc_mat->get_particle_flag(ParticleProcessMaterial::PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY)); - set_emission_shape(EmissionShape(material->get_emission_shape())); - set_emission_sphere_radius(material->get_emission_sphere_radius()); - Vector2 rect_extents = Vector2(material->get_emission_box_extents().x, material->get_emission_box_extents().y); + set_emission_shape(EmissionShape(proc_mat->get_emission_shape())); + set_emission_sphere_radius(proc_mat->get_emission_sphere_radius()); + Vector2 rect_extents = Vector2(proc_mat->get_emission_box_extents().x, proc_mat->get_emission_box_extents().y); set_emission_rect_extents(rect_extents); - Ref<CurveXYZTexture> scale3D = material->get_param_texture(ParticleProcessMaterial::PARAM_SCALE); + Ref<CurveXYZTexture> scale3D = proc_mat->get_param_texture(ParticleProcessMaterial::PARAM_SCALE); if (scale3D.is_valid()) { split_scale = true; scale_curve_x = scale3D->get_curve_x(); scale_curve_y = scale3D->get_curve_y(); } - Vector2 gravity = Vector2(material->get_gravity().x, material->get_gravity().y); - set_gravity(gravity); - set_lifetime_randomness(material->get_lifetime_randomness()); + set_gravity(Vector2(proc_mat->get_gravity().x, proc_mat->get_gravity().y)); + set_lifetime_randomness(proc_mat->get_lifetime_randomness()); #define CONVERT_PARAM(m_param) \ - set_param_min(m_param, material->get_param_min(ParticleProcessMaterial::m_param)); \ + set_param_min(m_param, proc_mat->get_param_min(ParticleProcessMaterial::m_param)); \ { \ - Ref<CurveTexture> ctex = material->get_param_texture(ParticleProcessMaterial::m_param); \ + Ref<CurveTexture> ctex = proc_mat->get_param_texture(ParticleProcessMaterial::m_param); \ if (ctex.is_valid()) \ set_param_curve(m_param, ctex->get_curve()); \ } \ - set_param_max(m_param, material->get_param_max(ParticleProcessMaterial::m_param)); + set_param_max(m_param, proc_mat->get_param_max(ParticleProcessMaterial::m_param)); CONVERT_PARAM(PARAM_INITIAL_LINEAR_VELOCITY); CONVERT_PARAM(PARAM_ANGULAR_VELOCITY); diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index 18f709f241..9786b01058 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -353,13 +353,13 @@ void GPUParticles2D::_validate_property(PropertyInfo &p_property) const { } void GPUParticles2D::emit_particle(const Transform2D &p_transform2d, const Vector2 &p_velocity2d, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags) { - Transform3D transform; - transform.basis.set_column(0, Vector3(p_transform2d.columns[0].x, p_transform2d.columns[0].y, 0)); - transform.basis.set_column(1, Vector3(p_transform2d.columns[1].x, p_transform2d.columns[1].y, 0)); - transform.set_origin(Vector3(p_transform2d.get_origin().x, p_transform2d.get_origin().y, 0)); + Transform3D emit_transform; + emit_transform.basis.set_column(0, Vector3(p_transform2d.columns[0].x, p_transform2d.columns[0].y, 0)); + emit_transform.basis.set_column(1, Vector3(p_transform2d.columns[1].x, p_transform2d.columns[1].y, 0)); + emit_transform.set_origin(Vector3(p_transform2d.get_origin().x, p_transform2d.get_origin().y, 0)); Vector3 velocity = Vector3(p_velocity2d.x, p_velocity2d.y, 0); - RS::get_singleton()->particles_emit(particles, transform, velocity, p_color, p_custom, p_emit_flags); + RS::get_singleton()->particles_emit(particles, emit_transform, velocity, p_color, p_custom, p_emit_flags); } void GPUParticles2D::_attach_sub_emitter() { diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp index e46bb79551..cbec4db4c5 100644 --- a/scene/2d/navigation_obstacle_2d.cpp +++ b/scene/2d/navigation_obstacle_2d.cpp @@ -153,7 +153,7 @@ void NavigationObstacle2D::reevaluate_agent_radius() { real_t NavigationObstacle2D::estimate_agent_radius() const { if (parent_node2d && parent_node2d->is_inside_tree()) { // Estimate the radius of this physics body - real_t radius = 0.0; + real_t max_radius = 0.0; for (int i(0); i < parent_node2d->get_child_count(); i++) { // For each collision shape CollisionShape2D *cs = Object::cast_to<CollisionShape2D>(parent_node2d->get_child(i)); @@ -167,17 +167,17 @@ real_t NavigationObstacle2D::estimate_agent_radius() const { Size2 s = cs->get_global_scale(); r *= MAX(s.x, s.y); // Takes the biggest radius - radius = MAX(radius, r); + max_radius = MAX(max_radius, r); } else if (cs && !cs->is_inside_tree()) { WARN_PRINT("A CollisionShape2D of the NavigationObstacle2D parent node was not inside the SceneTree when estimating the obstacle radius." "\nMove the NavigationObstacle2D to a child position below any CollisionShape2D node of the parent node so the CollisionShape2D is already inside the SceneTree."); } } Vector2 s = parent_node2d->get_global_scale(); - radius *= MAX(s.x, s.y); + max_radius *= MAX(s.x, s.y); - if (radius > 0.0) { - return radius; + if (max_radius > 0.0) { + return max_radius; } } return 1.0; // Never a 0 radius diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp index f1a28b7852..b7e6eb8ea5 100644 --- a/scene/2d/parallax_background.cpp +++ b/scene/2d/parallax_background.cpp @@ -71,29 +71,29 @@ void ParallaxBackground::_update_scroll() { return; } - Vector2 ofs = base_offset + offset * base_scale; + Vector2 scroll_ofs = base_offset + offset * base_scale; Size2 vps = get_viewport_size(); - ofs = -ofs; + scroll_ofs = -scroll_ofs; if (limit_begin.x < limit_end.x) { - if (ofs.x < limit_begin.x) { - ofs.x = limit_begin.x; - } else if (ofs.x + vps.x > limit_end.x) { - ofs.x = limit_end.x - vps.x; + if (scroll_ofs.x < limit_begin.x) { + scroll_ofs.x = limit_begin.x; + } else if (scroll_ofs.x + vps.x > limit_end.x) { + scroll_ofs.x = limit_end.x - vps.x; } } if (limit_begin.y < limit_end.y) { - if (ofs.y < limit_begin.y) { - ofs.y = limit_begin.y; - } else if (ofs.y + vps.y > limit_end.y) { - ofs.y = limit_end.y - vps.y; + if (scroll_ofs.y < limit_begin.y) { + scroll_ofs.y = limit_begin.y; + } else if (scroll_ofs.y + vps.y > limit_end.y) { + scroll_ofs.y = limit_end.y - vps.y; } } - ofs = -ofs; + scroll_ofs = -scroll_ofs; - final_offset = ofs; + final_offset = scroll_ofs; for (int i = 0; i < get_child_count(); i++) { ParallaxLayer *l = Object::cast_to<ParallaxLayer>(get_child(i)); @@ -102,9 +102,9 @@ void ParallaxBackground::_update_scroll() { } if (ignore_camera_zoom) { - l->set_base_offset_and_scale((ofs + screen_offset * (scale - 1)) / scale, 1.0); + l->set_base_offset_and_scale((scroll_ofs + screen_offset * (scale - 1)) / scale, 1.0); } else { - l->set_base_offset_and_scale(ofs, scale); + l->set_base_offset_and_scale(scroll_ofs, scale); } } } diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp index 01e4bf19f3..feb1fcd90c 100644 --- a/scene/2d/parallax_layer.cpp +++ b/scene/2d/parallax_layer.cpp @@ -37,9 +37,9 @@ void ParallaxLayer::set_motion_scale(const Size2 &p_scale) { ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent()); if (pb && is_inside_tree()) { - Vector2 ofs = pb->get_final_offset(); - real_t scale = pb->get_scroll_scale(); - set_base_offset_and_scale(ofs, scale); + Vector2 final_ofs = pb->get_final_offset(); + real_t scroll_scale = pb->get_scroll_scale(); + set_base_offset_and_scale(final_ofs, scroll_scale); } } @@ -52,9 +52,9 @@ void ParallaxLayer::set_motion_offset(const Size2 &p_offset) { ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent()); if (pb && is_inside_tree()) { - Vector2 ofs = pb->get_final_offset(); - real_t scale = pb->get_scroll_scale(); - set_base_offset_and_scale(ofs, scale); + Vector2 final_ofs = pb->get_final_offset(); + real_t scroll_scale = pb->get_scroll_scale(); + set_base_offset_and_scale(final_ofs, scroll_scale); } } diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index d0e35c2ea2..0f3e6c7529 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -471,28 +471,28 @@ void RigidBody2D::_body_state_changed(PhysicsDirectBodyState2D *p_state) { //put the ones to add for (int i = 0; i < p_state->get_contact_count(); i++) { - RID rid = p_state->get_contact_collider(i); - ObjectID obj = p_state->get_contact_collider_id(i); + RID col_rid = p_state->get_contact_collider(i); + ObjectID col_obj = p_state->get_contact_collider_id(i); int local_shape = p_state->get_contact_local_shape(i); - int shape = p_state->get_contact_collider_shape(i); + int col_shape = p_state->get_contact_collider_shape(i); - HashMap<ObjectID, BodyState>::Iterator E = contact_monitor->body_map.find(obj); + HashMap<ObjectID, BodyState>::Iterator E = contact_monitor->body_map.find(col_obj); if (!E) { - toadd[toadd_count].rid = rid; + toadd[toadd_count].rid = col_rid; toadd[toadd_count].local_shape = local_shape; - toadd[toadd_count].id = obj; - toadd[toadd_count].shape = shape; + toadd[toadd_count].id = col_obj; + toadd[toadd_count].shape = col_shape; toadd_count++; continue; } - ShapePair sp(shape, local_shape); + ShapePair sp(col_shape, local_shape); int idx = E->value.shapes.find(sp); if (idx == -1) { - toadd[toadd_count].rid = rid; + toadd[toadd_count].rid = col_rid; toadd[toadd_count].local_shape = local_shape; - toadd[toadd_count].id = obj; - toadd[toadd_count].shape = shape; + toadd[toadd_count].id = col_obj; + toadd[toadd_count].shape = col_shape; toadd_count++; continue; } diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp index b5759c54f7..dd016d5e92 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/scene/2d/skeleton_2d.cpp @@ -146,9 +146,9 @@ void Bone2D::_notification(int p_what) { queue_redraw(); if (get_parent()) { - Bone2D *parent_bone = Object::cast_to<Bone2D>(get_parent()); - if (parent_bone) { - parent_bone->queue_redraw(); + Bone2D *p_bone = Object::cast_to<Bone2D>(get_parent()); + if (p_bone) { + p_bone->queue_redraw(); } } #endif // TOOLS_ENABLED diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 5acf661425..26627a4fca 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -43,10 +43,10 @@ HashMap<Vector2i, TileSet::CellNeighbor> TileMap::TerrainConstraint::get_overlap ERR_FAIL_COND_V(is_center_bit(), output); - Ref<TileSet> tile_set = tile_map->get_tileset(); - ERR_FAIL_COND_V(!tile_set.is_valid(), output); + Ref<TileSet> ts = tile_map->get_tileset(); + ERR_FAIL_COND_V(!ts.is_valid(), output); - TileSet::TileShape shape = tile_set->get_tile_shape(); + TileSet::TileShape shape = ts->get_tile_shape(); if (shape == TileSet::TILE_SHAPE_SQUARE) { switch (bit) { case 1: @@ -87,7 +87,7 @@ HashMap<Vector2i, TileSet::CellNeighbor> TileMap::TerrainConstraint::get_overlap } } else { // Half offset shapes. - TileSet::TileOffsetAxis offset_axis = tile_set->get_tile_offset_axis(); + TileSet::TileOffsetAxis offset_axis = ts->get_tile_offset_axis(); if (offset_axis == TileSet::TILE_OFFSET_AXIS_HORIZONTAL) { switch (bit) { case 1: @@ -150,8 +150,8 @@ HashMap<Vector2i, TileSet::CellNeighbor> TileMap::TerrainConstraint::get_overlap TileMap::TerrainConstraint::TerrainConstraint(const TileMap *p_tile_map, const Vector2i &p_position, int p_terrain) { tile_map = p_tile_map; - Ref<TileSet> tile_set = tile_map->get_tileset(); - ERR_FAIL_COND(!tile_set.is_valid()); + Ref<TileSet> ts = tile_map->get_tileset(); + ERR_FAIL_COND(!ts.is_valid()); bit = 0; base_cell_coords = p_position; @@ -162,10 +162,10 @@ TileMap::TerrainConstraint::TerrainConstraint(const TileMap *p_tile_map, const V // The way we build the constraint make it easy to detect conflicting constraints. tile_map = p_tile_map; - Ref<TileSet> tile_set = tile_map->get_tileset(); - ERR_FAIL_COND(!tile_set.is_valid()); + Ref<TileSet> ts = tile_map->get_tileset(); + ERR_FAIL_COND(!ts.is_valid()); - TileSet::TileShape shape = tile_set->get_tile_shape(); + TileSet::TileShape shape = ts->get_tile_shape(); if (shape == TileSet::TILE_SHAPE_SQUARE) { switch (p_bit) { case TileSet::CELL_NEIGHBOR_RIGHT_SIDE: @@ -244,7 +244,7 @@ TileMap::TerrainConstraint::TerrainConstraint(const TileMap *p_tile_map, const V } } else { // Half-offset shapes - TileSet::TileOffsetAxis offset_axis = tile_set->get_tile_offset_axis(); + TileSet::TileOffsetAxis offset_axis = ts->get_tile_offset_axis(); if (offset_axis == TileSet::TILE_OFFSET_AXIS_HORIZONTAL) { switch (p_bit) { case TileSet::CELL_NEIGHBOR_RIGHT_SIDE: @@ -758,12 +758,12 @@ void TileMap::set_y_sort_enabled(bool p_enable) { } Vector2i TileMap::_coords_to_quadrant_coords(int p_layer, const Vector2i &p_coords) const { - int quadrant_size = get_effective_quadrant_size(p_layer); + int quad_size = get_effective_quadrant_size(p_layer); // Rounding down, instead of simply rounding towards zero (truncating) return Vector2i( - p_coords.x > 0 ? p_coords.x / quadrant_size : (p_coords.x - (quadrant_size - 1)) / quadrant_size, - p_coords.y > 0 ? p_coords.y / quadrant_size : (p_coords.y - (quadrant_size - 1)) / quadrant_size); + p_coords.x > 0 ? p_coords.x / quad_size : (p_coords.x - (quad_size - 1)) / quad_size, + p_coords.y > 0 ? p_coords.y / quad_size : (p_coords.y - (quad_size - 1)) / quad_size); } HashMap<Vector2i, TileMapQuadrant>::Iterator TileMap::_create_quadrant(int p_layer, const Vector2i &p_qk) { @@ -1008,7 +1008,7 @@ void TileMap::_recompute_rect_cache() { void TileMap::_rendering_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_CANVAS: { - bool visible = is_visible_in_tree(); + bool node_visible = is_visible_in_tree(); for (int layer = 0; layer < (int)layers.size(); layer++) { for (KeyValue<Vector2i, TileMapQuadrant> &E_quadrant : layers[layer].quadrant_map) { TileMapQuadrant &q = E_quadrant.value; @@ -1017,14 +1017,14 @@ void TileMap::_rendering_notification(int p_what) { xform.set_origin(map_to_local(kv.key)); RS::get_singleton()->canvas_light_occluder_attach_to_canvas(kv.value, get_canvas()); RS::get_singleton()->canvas_light_occluder_set_transform(kv.value, get_global_transform() * xform); - RS::get_singleton()->canvas_light_occluder_set_enabled(kv.value, visible); + RS::get_singleton()->canvas_light_occluder_set_enabled(kv.value, node_visible); } } } } break; case NOTIFICATION_VISIBILITY_CHANGED: { - bool visible = is_visible_in_tree(); + bool node_visible = is_visible_in_tree(); for (int layer = 0; layer < (int)layers.size(); layer++) { for (KeyValue<Vector2i, TileMapQuadrant> &E_quadrant : layers[layer].quadrant_map) { TileMapQuadrant &q = E_quadrant.value; @@ -1034,7 +1034,7 @@ void TileMap::_rendering_notification(int p_what) { Transform2D xform; xform.set_origin(E_cell.key); for (const KeyValue<Vector2i, RID> &kv : q.occluders) { - RS::get_singleton()->canvas_light_occluder_set_enabled(kv.value, visible); + RS::get_singleton()->canvas_light_occluder_set_enabled(kv.value, node_visible); } } } @@ -1116,7 +1116,7 @@ void TileMap::_rendering_update_dirty_quadrants(SelfList<TileMapQuadrant>::List ERR_FAIL_COND(!is_inside_tree()); ERR_FAIL_COND(!tile_set.is_valid()); - bool visible = is_visible_in_tree(); + bool node_visible = is_visible_in_tree(); SelfList<TileMapQuadrant> *q_list_element = r_dirty_quadrant_list.first(); while (q_list_element) { @@ -1139,18 +1139,18 @@ void TileMap::_rendering_update_dirty_quadrants(SelfList<TileMapQuadrant>::List // Those allow to group cell per material or z-index. Ref<Material> prev_material; int prev_z_index = 0; - RID prev_canvas_item; + RID prev_ci; - Color modulate = get_self_modulate(); - modulate *= get_layer_modulate(q.layer); + Color tile_modulate = get_self_modulate(); + tile_modulate *= get_layer_modulate(q.layer); if (selected_layer >= 0) { int z1 = get_layer_z_index(q.layer); int z2 = get_layer_z_index(selected_layer); if (z1 < z2 || (z1 == z2 && q.layer < selected_layer)) { - modulate = modulate.darkened(0.5); + tile_modulate = tile_modulate.darkened(0.5); } else if (z1 > z2 || (z1 == z2 && q.layer > selected_layer)) { - modulate = modulate.darkened(0.5); - modulate.a *= 0.3; + tile_modulate = tile_modulate.darkened(0.5); + tile_modulate.a *= 0.3; } } @@ -1177,53 +1177,53 @@ void TileMap::_rendering_update_dirty_quadrants(SelfList<TileMapQuadrant>::List } Ref<Material> mat = tile_data->get_material(); - int z_index = tile_data->get_z_index(); + int tile_z_index = tile_data->get_z_index(); // Quandrant pos. - Vector2 position = map_to_local(q.coords * get_effective_quadrant_size(q.layer)); + Vector2 tile_position = map_to_local(q.coords * get_effective_quadrant_size(q.layer)); if (is_y_sort_enabled() && layers[q.layer].y_sort_enabled) { // When Y-sorting, the quandrant size is sure to be 1, we can thus offset the CanvasItem. - position.y += layers[q.layer].y_sort_origin + tile_data->get_y_sort_origin(); + tile_position.y += layers[q.layer].y_sort_origin + tile_data->get_y_sort_origin(); } // --- CanvasItems --- // Create two canvas items, for rendering and debug. - RID canvas_item; + RID ci; // Check if the material or the z_index changed. - if (prev_canvas_item == RID() || prev_material != mat || prev_z_index != z_index) { + if (prev_ci == RID() || prev_material != mat || prev_z_index != tile_z_index) { // If so, create a new CanvasItem. - canvas_item = rs->canvas_item_create(); + ci = rs->canvas_item_create(); if (mat.is_valid()) { - rs->canvas_item_set_material(canvas_item, mat->get_rid()); + rs->canvas_item_set_material(ci, mat->get_rid()); } - rs->canvas_item_set_parent(canvas_item, layers[q.layer].canvas_item); - rs->canvas_item_set_use_parent_material(canvas_item, get_use_parent_material() || get_material().is_valid()); + rs->canvas_item_set_parent(ci, layers[q.layer].canvas_item); + rs->canvas_item_set_use_parent_material(ci, get_use_parent_material() || get_material().is_valid()); Transform2D xform; - xform.set_origin(position); - rs->canvas_item_set_transform(canvas_item, xform); + xform.set_origin(tile_position); + rs->canvas_item_set_transform(ci, xform); - rs->canvas_item_set_light_mask(canvas_item, get_light_mask()); - rs->canvas_item_set_z_as_relative_to_parent(canvas_item, true); - rs->canvas_item_set_z_index(canvas_item, z_index); + rs->canvas_item_set_light_mask(ci, get_light_mask()); + rs->canvas_item_set_z_as_relative_to_parent(ci, true); + rs->canvas_item_set_z_index(ci, tile_z_index); - rs->canvas_item_set_default_texture_filter(canvas_item, RS::CanvasItemTextureFilter(get_texture_filter())); - rs->canvas_item_set_default_texture_repeat(canvas_item, RS::CanvasItemTextureRepeat(get_texture_repeat())); + rs->canvas_item_set_default_texture_filter(ci, RS::CanvasItemTextureFilter(get_texture_filter())); + rs->canvas_item_set_default_texture_repeat(ci, RS::CanvasItemTextureRepeat(get_texture_repeat())); - q.canvas_items.push_back(canvas_item); + q.canvas_items.push_back(ci); - prev_canvas_item = canvas_item; + prev_ci = ci; prev_material = mat; - prev_z_index = z_index; + prev_z_index = tile_z_index; } else { // Keep the same canvas_item to draw on. - canvas_item = prev_canvas_item; + ci = prev_ci; } // Drawing the tile in the canvas item. - draw_tile(canvas_item, E_cell.key - position, tile_set, c.source_id, c.get_atlas_coords(), c.alternative_tile, -1, modulate, tile_data); + draw_tile(ci, E_cell.key - tile_position, tile_set, c.source_id, c.get_atlas_coords(), c.alternative_tile, -1, tile_modulate, tile_data); // --- Occluders --- for (int i = 0; i < tile_set->get_occlusion_layers_count(); i++) { @@ -1231,7 +1231,7 @@ void TileMap::_rendering_update_dirty_quadrants(SelfList<TileMapQuadrant>::List xform.set_origin(E_cell.key); if (tile_data->get_occluder(i).is_valid()) { RID occluder_id = rs->canvas_light_occluder_create(); - rs->canvas_light_occluder_set_enabled(occluder_id, visible); + rs->canvas_light_occluder_set_enabled(occluder_id, node_visible); rs->canvas_light_occluder_set_transform(occluder_id, get_global_transform() * xform); rs->canvas_light_occluder_set_polygon(occluder_id, tile_data->get_occluder(i)->get_rid()); rs->canvas_light_occluder_attach_to_canvas(occluder_id, get_canvas()); @@ -1445,7 +1445,7 @@ void TileMap::_physics_notification(int p_what) { #endif if (is_inside_tree() && (!collision_animatable || in_editor)) { // Update the new transform directly if we are not in animatable mode. - Transform2D global_transform = get_global_transform(); + Transform2D gl_transform = get_global_transform(); for (int layer = 0; layer < (int)layers.size(); layer++) { for (KeyValue<Vector2i, TileMapQuadrant> &E : layers[layer].quadrant_map) { TileMapQuadrant &q = E.value; @@ -1453,7 +1453,7 @@ void TileMap::_physics_notification(int p_what) { for (RID body : q.bodies) { Transform2D xform; xform.set_origin(map_to_local(bodies_coords[body])); - xform = global_transform * xform; + xform = gl_transform * xform; PhysicsServer2D::get_singleton()->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform); } } @@ -1496,9 +1496,9 @@ void TileMap::_physics_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r ERR_FAIL_COND(!is_inside_tree()); ERR_FAIL_COND(!tile_set.is_valid()); - Transform2D global_transform = get_global_transform(); - last_valid_transform = global_transform; - new_transform = global_transform; + Transform2D gl_transform = get_global_transform(); + last_valid_transform = gl_transform; + new_transform = gl_transform; PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); RID space = get_world_2d()->get_space(); @@ -1546,7 +1546,7 @@ void TileMap::_physics_update_dirty_quadrants(SelfList<TileMapQuadrant>::List &r Transform2D xform; xform.set_origin(map_to_local(E_cell)); - xform = global_transform * xform; + xform = gl_transform * xform; ps->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform); ps->body_attach_object_instance_id(body, get_instance_id()); @@ -2819,9 +2819,9 @@ Vector<int> TileMap::_get_tile_data(int p_layer) const { // Export tile data to raw format const HashMap<Vector2i, TileMapCell> &tile_map = layers[p_layer].tile_map; - Vector<int> data; - data.resize(tile_map.size() * 3); - int *w = data.ptrw(); + Vector<int> tile_data; + tile_data.resize(tile_map.size() * 3); + int *w = tile_data.ptrw(); // Save in highest format @@ -2837,7 +2837,7 @@ Vector<int> TileMap::_get_tile_data(int p_layer) const { idx += 3; } - return data; + return tile_data; } void TileMap::_build_runtime_update_tile_data(SelfList<TileMapQuadrant>::List &r_dirty_quadrant_list) { diff --git a/scene/3d/audio_listener_3d.cpp b/scene/3d/audio_listener_3d.cpp index 4f3f403ab7..8836244f3b 100644 --- a/scene/3d/audio_listener_3d.cpp +++ b/scene/3d/audio_listener_3d.cpp @@ -138,8 +138,6 @@ bool AudioListener3D::is_current() const { } else { return current; } - - return false; } void AudioListener3D::_bind_methods() { diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index c3c1c8ba36..a98be62dfa 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -150,13 +150,13 @@ uint32_t CollisionObject3D::get_collision_mask() const { void CollisionObject3D::set_collision_layer_value(int p_layer_number, bool p_value) { ERR_FAIL_COND_MSG(p_layer_number < 1, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_MSG(p_layer_number > 32, "Collision layer number must be between 1 and 32 inclusive."); - uint32_t collision_layer = get_collision_layer(); + uint32_t collision_layer_new = get_collision_layer(); if (p_value) { - collision_layer |= 1 << (p_layer_number - 1); + collision_layer_new |= 1 << (p_layer_number - 1); } else { - collision_layer &= ~(1 << (p_layer_number - 1)); + collision_layer_new &= ~(1 << (p_layer_number - 1)); } - set_collision_layer(collision_layer); + set_collision_layer(collision_layer_new); } bool CollisionObject3D::get_collision_layer_value(int p_layer_number) const { @@ -339,9 +339,9 @@ void CollisionObject3D::_update_shape_data(uint32_t p_owner) { void CollisionObject3D::_shape_changed(const Ref<Shape3D> &p_shape) { for (KeyValue<uint32_t, ShapeData> &E : shapes) { ShapeData &shapedata = E.value; - ShapeData::ShapeBase *shapes = shapedata.shapes.ptrw(); + ShapeData::ShapeBase *shape_bases = shapedata.shapes.ptrw(); for (int i = 0; i < shapedata.shapes.size(); i++) { - ShapeData::ShapeBase &s = shapes[i]; + ShapeData::ShapeBase &s = shape_bases[i]; if (s.shape == p_shape && s.debug_shape.is_valid()) { Ref<Mesh> mesh = s.shape->get_debug_mesh(); RS::get_singleton()->instance_set_base(s.debug_shape, mesh->get_rid()); @@ -359,9 +359,9 @@ void CollisionObject3D::_update_debug_shapes() { for (const uint32_t &shapedata_idx : debug_shapes_to_update) { if (shapes.has(shapedata_idx)) { ShapeData &shapedata = shapes[shapedata_idx]; - ShapeData::ShapeBase *shapes = shapedata.shapes.ptrw(); + ShapeData::ShapeBase *shape_bases = shapedata.shapes.ptrw(); for (int i = 0; i < shapedata.shapes.size(); i++) { - ShapeData::ShapeBase &s = shapes[i]; + ShapeData::ShapeBase &s = shape_bases[i]; if (s.shape.is_null() || shapedata.disabled) { if (s.debug_shape.is_valid()) { RS::get_singleton()->free(s.debug_shape); @@ -394,9 +394,9 @@ void CollisionObject3D::_update_debug_shapes() { void CollisionObject3D::_clear_debug_shapes() { for (KeyValue<uint32_t, ShapeData> &E : shapes) { ShapeData &shapedata = E.value; - ShapeData::ShapeBase *shapes = shapedata.shapes.ptrw(); + ShapeData::ShapeBase *shape_bases = shapedata.shapes.ptrw(); for (int i = 0; i < shapedata.shapes.size(); i++) { - ShapeData::ShapeBase &s = shapes[i]; + ShapeData::ShapeBase &s = shape_bases[i]; if (s.debug_shape.is_valid()) { RS::get_singleton()->free(s.debug_shape); s.debug_shape = RID(); @@ -417,9 +417,9 @@ void CollisionObject3D::_on_transform_changed() { if (shapedata.disabled) { continue; // If disabled then there are no debug shapes to update. } - const ShapeData::ShapeBase *shapes = shapedata.shapes.ptr(); + const ShapeData::ShapeBase *shape_bases = shapedata.shapes.ptr(); for (int i = 0; i < shapedata.shapes.size(); i++) { - RS::get_singleton()->instance_set_transform(shapes[i].debug_shape, debug_shape_old_transform * shapedata.xform); + RS::get_singleton()->instance_set_transform(shape_bases[i].debug_shape, debug_shape_old_transform * shapedata.xform); } } } diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp index 7a0001bc6f..ef381641ab 100644 --- a/scene/3d/collision_shape_3d.cpp +++ b/scene/3d/collision_shape_3d.cpp @@ -62,9 +62,9 @@ void CollisionShape3D::make_convex_from_siblings() { } } - Ref<ConvexPolygonShape3D> shape = memnew(ConvexPolygonShape3D); - shape->set_points(vertices); - set_shape(shape); + Ref<ConvexPolygonShape3D> shape_new = memnew(ConvexPolygonShape3D); + shape_new->set_points(vertices); + set_shape(shape_new); } void CollisionShape3D::_update_in_shape_owner(bool p_xform_only) { diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index ef373cf9ca..7de685b469 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -1326,24 +1326,24 @@ void CPUParticles3D::_notification(int p_what) { } void CPUParticles3D::convert_from_particles(Node *p_particles) { - GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_particles); - ERR_FAIL_COND_MSG(!particles, "Only GPUParticles3D nodes can be converted to CPUParticles3D."); - - set_emitting(particles->is_emitting()); - set_amount(particles->get_amount()); - set_lifetime(particles->get_lifetime()); - set_one_shot(particles->get_one_shot()); - set_pre_process_time(particles->get_pre_process_time()); - set_explosiveness_ratio(particles->get_explosiveness_ratio()); - set_randomness_ratio(particles->get_randomness_ratio()); - set_use_local_coordinates(particles->get_use_local_coordinates()); - set_fixed_fps(particles->get_fixed_fps()); - set_fractional_delta(particles->get_fractional_delta()); - set_speed_scale(particles->get_speed_scale()); - set_draw_order(DrawOrder(particles->get_draw_order())); - set_mesh(particles->get_draw_pass_mesh(0)); - - Ref<ParticleProcessMaterial> material = particles->get_process_material(); + GPUParticles3D *gpu_particles = Object::cast_to<GPUParticles3D>(p_particles); + ERR_FAIL_COND_MSG(!gpu_particles, "Only GPUParticles3D nodes can be converted to CPUParticles3D."); + + set_emitting(gpu_particles->is_emitting()); + set_amount(gpu_particles->get_amount()); + set_lifetime(gpu_particles->get_lifetime()); + set_one_shot(gpu_particles->get_one_shot()); + set_pre_process_time(gpu_particles->get_pre_process_time()); + set_explosiveness_ratio(gpu_particles->get_explosiveness_ratio()); + set_randomness_ratio(gpu_particles->get_randomness_ratio()); + set_use_local_coordinates(gpu_particles->get_use_local_coordinates()); + set_fixed_fps(gpu_particles->get_fixed_fps()); + set_fractional_delta(gpu_particles->get_fractional_delta()); + set_speed_scale(gpu_particles->get_speed_scale()); + set_draw_order(DrawOrder(gpu_particles->get_draw_order())); + set_mesh(gpu_particles->get_draw_pass_mesh(0)); + + Ref<ParticleProcessMaterial> material = gpu_particles->get_process_material(); if (material.is_null()) { return; } diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp index d3f53d9c0d..b3437c4810 100644 --- a/scene/3d/gpu_particles_collision_3d.cpp +++ b/scene/3d/gpu_particles_collision_3d.cpp @@ -225,23 +225,23 @@ static _FORCE_INLINE_ real_t Vector3_dot2(const Vector3 &p_vec3) { return p_vec3.dot(p_vec3); } -void GPUParticlesCollisionSDF3D::_find_closest_distance(const Vector3 &p_pos, const BVH *bvh, uint32_t p_bvh_cell, const Face3 *triangles, float thickness, float &closest_distance) { +void GPUParticlesCollisionSDF3D::_find_closest_distance(const Vector3 &p_pos, const BVH *p_bvh, uint32_t p_bvh_cell, const Face3 *p_triangles, float p_thickness, float &r_closest_distance) { if (p_bvh_cell & BVH::LEAF_BIT) { p_bvh_cell &= BVH::LEAF_MASK; //remove bit Vector3 point = p_pos; - Plane p = triangles[p_bvh_cell].get_plane(); + Plane p = p_triangles[p_bvh_cell].get_plane(); float d = p.distance_to(point); float inside_d = 1e20; - if (d < 0 && d > -thickness) { + if (d < 0 && d > -p_thickness) { //inside planes, do this in 2D - Vector3 x_axis = (triangles[p_bvh_cell].vertex[0] - triangles[p_bvh_cell].vertex[1]).normalized(); + Vector3 x_axis = (p_triangles[p_bvh_cell].vertex[0] - p_triangles[p_bvh_cell].vertex[1]).normalized(); Vector3 y_axis = p.normal.cross(x_axis).normalized(); Vector2 points[3]; for (int i = 0; i < 3; i++) { - points[i] = Vector2(x_axis.dot(triangles[p_bvh_cell].vertex[i]), y_axis.dot(triangles[p_bvh_cell].vertex[i])); + points[i] = Vector2(x_axis.dot(p_triangles[p_bvh_cell].vertex[i]), y_axis.dot(p_triangles[p_bvh_cell].vertex[i])); } Vector2 p2d = Vector2(x_axis.dot(point), y_axis.dot(point)); @@ -270,19 +270,19 @@ void GPUParticlesCollisionSDF3D::_find_closest_distance(const Vector3 &p_pos, co //make sure distance to planes is not shorter if inside if (inside_d < 0) { inside_d = MAX(inside_d, d); - inside_d = MAX(inside_d, -(thickness + d)); + inside_d = MAX(inside_d, -(p_thickness + d)); } - closest_distance = MIN(closest_distance, inside_d); + r_closest_distance = MIN(r_closest_distance, inside_d); } else { if (d < 0) { - point -= p.normal * thickness; //flatten + point -= p.normal * p_thickness; //flatten } // https://iquilezles.org/www/articles/distfunctions/distfunctions.htm - Vector3 a = triangles[p_bvh_cell].vertex[0]; - Vector3 b = triangles[p_bvh_cell].vertex[1]; - Vector3 c = triangles[p_bvh_cell].vertex[2]; + Vector3 a = p_triangles[p_bvh_cell].vertex[0]; + Vector3 b = p_triangles[p_bvh_cell].vertex[1]; + Vector3 c = p_triangles[p_bvh_cell].vertex[2]; Vector3 ba = b - a; Vector3 pa = point - a; @@ -300,28 +300,28 @@ void GPUParticlesCollisionSDF3D::_find_closest_distance(const Vector3 &p_pos, co Vector3_dot2(ac * CLAMP(ac.dot(pc) / Vector3_dot2(ac), 0.0, 1.0) - pc)) : nor.dot(pa) * nor.dot(pa) / Vector3_dot2(nor)); - closest_distance = MIN(closest_distance, inside_d); + r_closest_distance = MIN(r_closest_distance, inside_d); } } else { bool pass = true; - if (!bvh[p_bvh_cell].bounds.has_point(p_pos)) { + if (!p_bvh[p_bvh_cell].bounds.has_point(p_pos)) { //outside, find closest point - Vector3 he = bvh[p_bvh_cell].bounds.size * 0.5; - Vector3 center = bvh[p_bvh_cell].bounds.position + he; + Vector3 he = p_bvh[p_bvh_cell].bounds.size * 0.5; + Vector3 center = p_bvh[p_bvh_cell].bounds.position + he; Vector3 rel = (p_pos - center).abs(); Vector3 closest(MIN(rel.x, he.x), MIN(rel.y, he.y), MIN(rel.z, he.z)); float d = rel.distance_to(closest); - if (d >= closest_distance) { + if (d >= r_closest_distance) { pass = false; //already closer than this aabb, discard } } if (pass) { - _find_closest_distance(p_pos, bvh, bvh[p_bvh_cell].children[0], triangles, thickness, closest_distance); - _find_closest_distance(p_pos, bvh, bvh[p_bvh_cell].children[1], triangles, thickness, closest_distance); + _find_closest_distance(p_pos, p_bvh, p_bvh[p_bvh_cell].children[0], p_triangles, p_thickness, r_closest_distance); + _find_closest_distance(p_pos, p_bvh, p_bvh[p_bvh_cell].children[1], p_triangles, p_thickness, r_closest_distance); } } } @@ -473,15 +473,15 @@ Ref<Image> GPUParticlesCollisionSDF3D::bake() { _create_bvh(bvh, face_pos.ptr(), face_pos.size(), faces.ptr(), th); - Vector<uint8_t> data; - data.resize(sdf_size.z * sdf_size.y * sdf_size.x * (int)sizeof(float)); + Vector<uint8_t> cells_data; + cells_data.resize(sdf_size.z * sdf_size.y * sdf_size.x * (int)sizeof(float)); if (bake_step_function) { bake_step_function(0, "Baking SDF"); } ComputeSDFParams params; - params.cells = (float *)data.ptrw(); + params.cells = (float *)cells_data.ptrw(); params.size = sdf_size; params.cell_size = cell_size; params.cell_offset = aabb.position + Vector3(cell_size * 0.5, cell_size * 0.5, cell_size * 0.5); @@ -492,7 +492,7 @@ Ref<Image> GPUParticlesCollisionSDF3D::bake() { Ref<Image> ret; ret.instantiate(); - ret->create(sdf_size.x, sdf_size.y * sdf_size.z, false, Image::FORMAT_RF, data); + ret->create(sdf_size.x, sdf_size.y * sdf_size.z, false, Image::FORMAT_RF, cells_data); ret->convert(Image::FORMAT_RH); //convert to half, save space ret->set_meta("depth", sdf_size.z); //hack, make sure to add to the docs of this function diff --git a/scene/3d/gpu_particles_collision_3d.h b/scene/3d/gpu_particles_collision_3d.h index 548552bb70..25b111c8ff 100644 --- a/scene/3d/gpu_particles_collision_3d.h +++ b/scene/3d/gpu_particles_collision_3d.h @@ -154,7 +154,7 @@ private: float thickness = 0.0; }; - void _find_closest_distance(const Vector3 &p_pos, const BVH *bvh, uint32_t p_bvh_cell, const Face3 *triangles, float thickness, float &closest_distance); + void _find_closest_distance(const Vector3 &p_pos, const BVH *p_bvh, uint32_t p_bvh_cell, const Face3 *p_triangles, float p_thickness, float &r_closest_distance); void _compute_sdf_z(uint32_t p_z, ComputeSDFParams *params); void _compute_sdf(ComputeSDFParams *params); diff --git a/scene/3d/label_3d.cpp b/scene/3d/label_3d.cpp index d977874911..262dc0db37 100644 --- a/scene/3d/label_3d.cpp +++ b/scene/3d/label_3d.cpp @@ -283,14 +283,14 @@ Ref<TriangleMesh> Label3D::generate_triangle_mesh() const { return Ref<TriangleMesh>(); } - real_t pixel_size = get_pixel_size(); + real_t px_size = get_pixel_size(); Vector2 vertices[4] = { - (final_rect.position + Vector2(0, -final_rect.size.y)) * pixel_size, - (final_rect.position + Vector2(final_rect.size.x, -final_rect.size.y)) * pixel_size, - (final_rect.position + Vector2(final_rect.size.x, 0)) * pixel_size, - final_rect.position * pixel_size, + (final_rect.position + Vector2(0, -final_rect.size.y)) * px_size, + (final_rect.position + Vector2(final_rect.size.x, -final_rect.size.y)) * px_size, + (final_rect.position + Vector2(final_rect.size.x, 0)) * px_size, + final_rect.position * px_size, }; @@ -436,17 +436,17 @@ void Label3D::_shape() { TS->shaped_text_clear(text_rid); TS->shaped_text_set_direction(text_rid, text_direction); - String text = (uppercase) ? TS->string_to_upper(xl_text, language) : xl_text; - TS->shaped_text_add_string(text_rid, text, font->get_rids(), font_size, font->get_opentype_features(), language); + String txt = (uppercase) ? TS->string_to_upper(xl_text, language) : xl_text; + TS->shaped_text_add_string(text_rid, txt, font->get_rids(), font_size, font->get_opentype_features(), language); for (int i = 0; i < TextServer::SPACING_MAX; i++) { TS->shaped_text_set_spacing(text_rid, TextServer::SpacingType(i), font->get_spacing(TextServer::SpacingType(i))); } TypedArray<Vector2i> stt; if (st_parser == TextServer::STRUCTURED_TEXT_CUSTOM) { - GDVIRTUAL_CALL(_structured_text_parser, st_args, text, stt); + GDVIRTUAL_CALL(_structured_text_parser, st_args, txt, stt); } else { - stt = TS->parse_structured_text(st_parser, st_args, text); + stt = TS->parse_structured_text(st_parser, st_args, txt); } TS->shaped_text_set_bidi_override(text_rid, stt); diff --git a/scene/3d/lightmap_gi.cpp b/scene/3d/lightmap_gi.cpp index cbcbac7b83..3ea1de57cd 100644 --- a/scene/3d/lightmap_gi.cpp +++ b/scene/3d/lightmap_gi.cpp @@ -1081,13 +1081,13 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa /* POSTBAKE: Save Light Data */ - Ref<LightmapGIData> data; + Ref<LightmapGIData> gi_data; if (get_light_data().is_valid()) { - data = get_light_data(); + gi_data = get_light_data(); set_light_data(Ref<LightmapGIData>()); //clear - data->clear(); + gi_data->clear(); } else { - data.instantiate(); + gi_data.instantiate(); } Ref<Texture2DArray> texture; @@ -1101,8 +1101,8 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa texture->create_from_images(images); } - data->set_light_texture(texture); - data->set_uses_spherical_harmonics(directional); + gi_data->set_light_texture(texture); + gi_data->set_uses_spherical_harmonics(directional); for (int i = 0; i < lightmapper->get_bake_mesh_count(); i++) { Dictionary d = lightmapper->get_bake_mesh_userdata(i); @@ -1114,7 +1114,7 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa Rect2 uv_scale = lightmapper->get_bake_mesh_uv_scale(i); int slice_index = lightmapper->get_bake_mesh_texture_slice(i); - data->add_user(np, uv_scale, slice_index, subindex); + gi_data->add_user(np, uv_scale, slice_index, subindex); } { @@ -1247,18 +1247,18 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa /* Obtain the colors from the images, they will be re-created as cubemaps on the server, depending on the driver */ - data->set_capture_data(bounds, interior, points, sh, tetrahedrons, bsp_array, exposure_normalization); + gi_data->set_capture_data(bounds, interior, points, sh, tetrahedrons, bsp_array, exposure_normalization); /* Compute a BSP tree of the simplices, so it's easy to find the exact one */ } - data->set_path(p_image_data_path); - Error err = ResourceSaver::save(data); + gi_data->set_path(p_image_data_path); + Error err = ResourceSaver::save(gi_data); if (err != OK) { return BAKE_ERROR_CANT_CREATE_IMAGE; } - set_light_data(data); + set_light_data(gi_data); return BAKE_ERROR_OK; } @@ -1286,9 +1286,9 @@ void LightmapGI::_assign_lightmaps() { Node *node = get_node(light_data->get_user_path(i)); int instance_idx = light_data->get_user_sub_instance(i); if (instance_idx >= 0) { - RID instance = node->call("get_bake_mesh_instance", instance_idx); - if (instance.is_valid()) { - RS::get_singleton()->instance_geometry_set_lightmap(instance, get_instance(), light_data->get_user_lightmap_uv_scale(i), light_data->get_user_lightmap_slice_index(i)); + RID instance_id = node->call("get_bake_mesh_instance", instance_idx); + if (instance_id.is_valid()) { + RS::get_singleton()->instance_geometry_set_lightmap(instance_id, get_instance(), light_data->get_user_lightmap_uv_scale(i), light_data->get_user_lightmap_slice_index(i)); } } else { VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(node); @@ -1304,9 +1304,9 @@ void LightmapGI::_clear_lightmaps() { Node *node = get_node(light_data->get_user_path(i)); int instance_idx = light_data->get_user_sub_instance(i); if (instance_idx >= 0) { - RID instance = node->call("get_bake_mesh_instance", instance_idx); - if (instance.is_valid()) { - RS::get_singleton()->instance_geometry_set_lightmap(instance, RID(), Rect2(), 0); + RID instance_id = node->call("get_bake_mesh_instance", instance_idx); + if (instance_id.is_valid()) { + RS::get_singleton()->instance_geometry_set_lightmap(instance_id, RID(), Rect2(), 0); } } else { VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(node); diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index b0503c9c02..d4f60503c2 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -346,9 +346,9 @@ Ref<Material> MeshInstance3D::get_surface_override_material(int p_surface) const } Ref<Material> MeshInstance3D::get_active_material(int p_surface) const { - Ref<Material> material_override = get_material_override(); - if (material_override.is_valid()) { - return material_override; + Ref<Material> mat_override = get_material_override(); + if (mat_override.is_valid()) { + return mat_override; } Ref<Material> surface_material = get_surface_override_material(p_surface); @@ -356,9 +356,9 @@ Ref<Material> MeshInstance3D::get_active_material(int p_surface) const { return surface_material; } - Ref<Mesh> mesh = get_mesh(); - if (mesh.is_valid()) { - return mesh->surface_get_material(p_surface); + Ref<Mesh> m = get_mesh(); + if (m.is_valid()) { + return m->surface_get_material(p_surface); } return Ref<Material>(); @@ -394,13 +394,13 @@ MeshInstance3D *MeshInstance3D::create_debug_tangents_node() { Vector<Vector3> lines; Vector<Color> colors; - Ref<Mesh> mesh = get_mesh(); - if (!mesh.is_valid()) { + Ref<Mesh> m = get_mesh(); + if (!m.is_valid()) { return nullptr; } - for (int i = 0; i < mesh->get_surface_count(); i++) { - Array arrays = mesh->surface_get_arrays(i); + for (int i = 0; i < m->get_surface_count(); i++) { + Array arrays = m->surface_get_arrays(i); ERR_CONTINUE(arrays.size() != Mesh::ARRAY_MAX); Vector<Vector3> verts = arrays[Mesh::ARRAY_VERTEX]; diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp index 07d8cd9289..f241d65649 100644 --- a/scene/3d/navigation_obstacle_3d.cpp +++ b/scene/3d/navigation_obstacle_3d.cpp @@ -159,7 +159,7 @@ void NavigationObstacle3D::reevaluate_agent_radius() { real_t NavigationObstacle3D::estimate_agent_radius() const { if (parent_node3d && parent_node3d->is_inside_tree()) { // Estimate the radius of this physics body - real_t radius = 0.0; + real_t max_radius = 0.0; for (int i(0); i < parent_node3d->get_child_count(); i++) { // For each collision shape CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(parent_node3d->get_child(i)); @@ -173,7 +173,7 @@ real_t NavigationObstacle3D::estimate_agent_radius() const { Vector3 s = cs->get_global_transform().basis.get_scale(); r *= MAX(s.x, MAX(s.y, s.z)); // Takes the biggest radius - radius = MAX(radius, r); + max_radius = MAX(max_radius, r); } else if (cs && !cs->is_inside_tree()) { WARN_PRINT("A CollisionShape3D of the NavigationObstacle3D parent node was not inside the SceneTree when estimating the obstacle radius." "\nMove the NavigationObstacle3D to a child position below any CollisionShape3D node of the parent node so the CollisionShape3D is already inside the SceneTree."); @@ -181,10 +181,10 @@ real_t NavigationObstacle3D::estimate_agent_radius() const { } Vector3 s = parent_node3d->get_global_transform().basis.get_scale(); - radius *= MAX(s.x, MAX(s.y, s.z)); + max_radius *= MAX(s.x, MAX(s.y, s.z)); - if (radius > 0.0) { - return radius; + if (max_radius > 0.0) { + return max_radius; } } return 1.0; // Never a 0 radius diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp index 123a044b84..ab4cba86fb 100644 --- a/scene/3d/path_3d.cpp +++ b/scene/3d/path_3d.cpp @@ -348,8 +348,8 @@ PackedStringArray PathFollow3D::get_configuration_warnings() const { if (!Object::cast_to<Path3D>(get_parent())) { warnings.push_back(RTR("PathFollow3D only works when set as a child of a Path3D node.")); } else { - Path3D *path = Object::cast_to<Path3D>(get_parent()); - if (path->get_curve().is_valid() && !path->get_curve()->is_up_vector_enabled() && rotation_mode == ROTATION_ORIENTED) { + Path3D *p = Object::cast_to<Path3D>(get_parent()); + if (p->get_curve().is_valid() && !p->get_curve()->is_up_vector_enabled() && rotation_mode == ROTATION_ORIENTED) { warnings.push_back(RTR("PathFollow3D's ROTATION_ORIENTED requires \"Up Vector\" to be enabled in its parent Path3D's Curve resource.")); } } diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 91f58b3976..d9fa37ce74 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -522,28 +522,28 @@ void RigidBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) { //put the ones to add for (int i = 0; i < p_state->get_contact_count(); i++) { - RID rid = p_state->get_contact_collider(i); - ObjectID obj = p_state->get_contact_collider_id(i); + RID col_rid = p_state->get_contact_collider(i); + ObjectID col_obj = p_state->get_contact_collider_id(i); int local_shape = p_state->get_contact_local_shape(i); - int shape = p_state->get_contact_collider_shape(i); + int col_shape = p_state->get_contact_collider_shape(i); - HashMap<ObjectID, BodyState>::Iterator E = contact_monitor->body_map.find(obj); + HashMap<ObjectID, BodyState>::Iterator E = contact_monitor->body_map.find(col_obj); if (!E) { - toadd[toadd_count].rid = rid; + toadd[toadd_count].rid = col_rid; toadd[toadd_count].local_shape = local_shape; - toadd[toadd_count].id = obj; - toadd[toadd_count].shape = shape; + toadd[toadd_count].id = col_obj; + toadd[toadd_count].shape = col_shape; toadd_count++; continue; } - ShapePair sp(shape, local_shape); + ShapePair sp(col_shape, local_shape); int idx = E->value.shapes.find(sp); if (idx == -1) { - toadd[toadd_count].rid = rid; + toadd[toadd_count].rid = col_rid; toadd[toadd_count].local_shape = local_shape; - toadd[toadd_count].id = obj; - toadd[toadd_count].shape = shape; + toadd[toadd_count].id = col_obj; + toadd[toadd_count].shape = col_shape; toadd_count++; continue; } diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp index 2466b71aea..83e3369423 100644 --- a/scene/3d/soft_body_3d.cpp +++ b/scene/3d/soft_body_3d.cpp @@ -523,13 +523,13 @@ uint32_t SoftBody3D::get_collision_layer() const { void SoftBody3D::set_collision_layer_value(int p_layer_number, bool p_value) { ERR_FAIL_COND_MSG(p_layer_number < 1, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_MSG(p_layer_number > 32, "Collision layer number must be between 1 and 32 inclusive."); - uint32_t collision_layer = get_collision_layer(); + uint32_t collision_layer_new = get_collision_layer(); if (p_value) { - collision_layer |= 1 << (p_layer_number - 1); + collision_layer_new |= 1 << (p_layer_number - 1); } else { - collision_layer &= ~(1 << (p_layer_number - 1)); + collision_layer_new &= ~(1 << (p_layer_number - 1)); } - set_collision_layer(collision_layer); + set_collision_layer(collision_layer_new); } bool SoftBody3D::get_collision_layer_value(int p_layer_number) const { diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 4b83bcdfc4..cc69a1cc51 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -118,14 +118,14 @@ void SpriteBase3D::draw_texture_rect(Ref<Texture2D> p_texture, Rect2 p_dst_rect, Color color = _get_color_accum(); - real_t pixel_size = get_pixel_size(); + real_t px_size = get_pixel_size(); // (2) Order vertices (0123) bottom-top in 2D / top-bottom in 3D. Vector2 vertices[4] = { - (final_rect.position + Vector2(0, final_rect.size.y)) * pixel_size, - (final_rect.position + final_rect.size) * pixel_size, - (final_rect.position + Vector2(final_rect.size.x, 0)) * pixel_size, - final_rect.position * pixel_size, + (final_rect.position + Vector2(0, final_rect.size.y)) * px_size, + (final_rect.position + final_rect.size) * px_size, + (final_rect.position + Vector2(final_rect.size.x, 0)) * px_size, + final_rect.position * px_size, }; Vector2 src_tsize = p_texture->get_size(); @@ -156,34 +156,34 @@ void SpriteBase3D::draw_texture_rect(Ref<Texture2D> p_texture, Rect2 p_dst_rect, } Vector3 normal; - int axis = get_axis(); - normal[axis] = 1.0; + int ax = get_axis(); + normal[ax] = 1.0; Plane tangent; - if (axis == Vector3::AXIS_X) { + if (ax == Vector3::AXIS_X) { tangent = Plane(0, 0, -1, 1); } else { tangent = Plane(1, 0, 0, 1); } - int x_axis = ((axis + 1) % 3); - int y_axis = ((axis + 2) % 3); + int x_axis = ((ax + 1) % 3); + int y_axis = ((ax + 2) % 3); - if (axis != Vector3::AXIS_Z) { + if (ax != Vector3::AXIS_Z) { SWAP(x_axis, y_axis); for (int i = 0; i < 4; i++) { //uvs[i] = Vector2(1.0,1.0)-uvs[i]; //SWAP(vertices[i].x,vertices[i].y); - if (axis == Vector3::AXIS_Y) { + if (ax == Vector3::AXIS_Y) { vertices[i].y = -vertices[i].y; - } else if (axis == Vector3::AXIS_X) { + } else if (ax == Vector3::AXIS_X) { vertices[i].x = -vertices[i].x; } } } - AABB aabb; + AABB aabb_new; // Everything except position and UV is compressed. uint8_t *vertex_write_buffer = vertex_buffer.ptrw(); @@ -223,10 +223,10 @@ void SpriteBase3D::draw_texture_rect(Ref<Texture2D> p_texture, Rect2 p_dst_rect, vtx[x_axis] = vertices[i][0]; vtx[y_axis] = vertices[i][1]; if (i == 0) { - aabb.position = vtx; - aabb.size = Vector3(); + aabb_new.position = vtx; + aabb_new.size = Vector3(); } else { - aabb.expand_to(vtx); + aabb_new.expand_to(vtx); } float v_uv[2] = { (float)uvs[i].x, (float)uvs[i].y }; @@ -240,12 +240,12 @@ void SpriteBase3D::draw_texture_rect(Ref<Texture2D> p_texture, Rect2 p_dst_rect, memcpy(&attribute_write_buffer[i * attrib_stride + mesh_surface_offsets[RS::ARRAY_COLOR]], v_color, 4); } - RID mesh = get_mesh(); - RS::get_singleton()->mesh_surface_update_vertex_region(mesh, 0, 0, vertex_buffer); - RS::get_singleton()->mesh_surface_update_attribute_region(mesh, 0, 0, attribute_buffer); + RID mesh_new = get_mesh(); + RS::get_singleton()->mesh_surface_update_vertex_region(mesh_new, 0, 0, vertex_buffer); + RS::get_singleton()->mesh_surface_update_attribute_region(mesh_new, 0, 0, attribute_buffer); - RS::get_singleton()->mesh_set_custom_aabb(mesh, aabb); - set_aabb(aabb); + RS::get_singleton()->mesh_set_custom_aabb(mesh_new, aabb_new); + set_aabb(aabb_new); RID shader_rid; StandardMaterial3D::get_material_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == StandardMaterial3D::BILLBOARD_ENABLED, get_billboard_mode() == StandardMaterial3D::BILLBOARD_FIXED_Y, false, get_draw_flag(FLAG_DISABLE_DEPTH_TEST), get_draw_flag(FLAG_FIXED_SIZE), get_texture_filter(), &shader_rid); @@ -378,14 +378,14 @@ Ref<TriangleMesh> SpriteBase3D::generate_triangle_mesh() const { return Ref<TriangleMesh>(); } - real_t pixel_size = get_pixel_size(); + real_t px_size = get_pixel_size(); Vector2 vertices[4] = { - (final_rect.position + Vector2(0, final_rect.size.y)) * pixel_size, - (final_rect.position + final_rect.size) * pixel_size, - (final_rect.position + Vector2(final_rect.size.x, 0)) * pixel_size, - final_rect.position * pixel_size, + (final_rect.position + Vector2(0, final_rect.size.y)) * px_size, + (final_rect.position + final_rect.size) * px_size, + (final_rect.position + Vector2(final_rect.size.x, 0)) * px_size, + final_rect.position * px_size, }; diff --git a/scene/3d/visible_on_screen_notifier_3d.cpp b/scene/3d/visible_on_screen_notifier_3d.cpp index bcf294e216..2013a93e26 100644 --- a/scene/3d/visible_on_screen_notifier_3d.cpp +++ b/scene/3d/visible_on_screen_notifier_3d.cpp @@ -95,10 +95,11 @@ VisibleOnScreenNotifier3D::VisibleOnScreenNotifier3D() { RS::get_singleton()->visibility_notifier_set_callbacks(notifier, callable_mp(this, &VisibleOnScreenNotifier3D::_visibility_enter), callable_mp(this, &VisibleOnScreenNotifier3D::_visibility_exit)); set_base(notifier); } + VisibleOnScreenNotifier3D::~VisibleOnScreenNotifier3D() { - RID base = get_base(); + RID base_old = get_base(); set_base(RID()); - RS::get_singleton()->free(base); + RS::get_singleton()->free(base_old); } ////////////////////////////////////// diff --git a/scene/3d/voxel_gi.cpp b/scene/3d/voxel_gi.cpp index c2728960ee..3dba0221bb 100644 --- a/scene/3d/voxel_gi.cpp +++ b/scene/3d/voxel_gi.cpp @@ -46,8 +46,8 @@ void VoxelGIData::_set_data(const Dictionary &p_data) { ERR_FAIL_COND(!p_data.has("level_counts")); ERR_FAIL_COND(!p_data.has("to_cell_xform")); - AABB bounds = p_data["bounds"]; - Vector3 octree_size = p_data["octree_size"]; + AABB bounds_new = p_data["bounds"]; + Vector3 octree_size_new = p_data["octree_size"]; Vector<uint8_t> octree_cells = p_data["octree_cells"]; Vector<uint8_t> octree_data = p_data["octree_data"]; @@ -64,9 +64,9 @@ void VoxelGIData::_set_data(const Dictionary &p_data) { octree_df = img->get_data(); } Vector<int> octree_levels = p_data["level_counts"]; - Transform3D to_cell_xform = p_data["to_cell_xform"]; + Transform3D to_cell_xform_new = p_data["to_cell_xform"]; - allocate(to_cell_xform, bounds, octree_size, octree_cells, octree_data, octree_df, octree_levels); + allocate(to_cell_xform_new, bounds_new, octree_size_new, octree_cells, octree_data, octree_df, octree_levels); } Dictionary VoxelGIData::_get_data() const { @@ -435,10 +435,10 @@ void VoxelGI::bake(Node *p_from_node, bool p_create_visual_debug) { #endif } else { - Ref<VoxelGIData> probe_data = get_probe_data(); + Ref<VoxelGIData> probe_data_new = get_probe_data(); - if (probe_data.is_null()) { - probe_data.instantiate(); + if (probe_data_new.is_null()) { + probe_data_new.instantiate(); } if (bake_step_function) { @@ -447,13 +447,13 @@ void VoxelGI::bake(Node *p_from_node, bool p_create_visual_debug) { Vector<uint8_t> df = baker.get_sdf_3d_image(); - RS::get_singleton()->voxel_gi_set_baked_exposure_normalization(probe_data->get_rid(), exposure_normalization); + RS::get_singleton()->voxel_gi_set_baked_exposure_normalization(probe_data_new->get_rid(), exposure_normalization); - probe_data->allocate(baker.get_to_cell_space_xform(), AABB(-extents, extents * 2.0), baker.get_voxel_gi_octree_size(), baker.get_voxel_gi_octree_cells(), baker.get_voxel_gi_data_cells(), df, baker.get_voxel_gi_level_cell_count()); + probe_data_new->allocate(baker.get_to_cell_space_xform(), AABB(-extents, extents * 2.0), baker.get_voxel_gi_octree_size(), baker.get_voxel_gi_octree_cells(), baker.get_voxel_gi_data_cells(), df, baker.get_voxel_gi_level_cell_count()); - set_probe_data(probe_data); + set_probe_data(probe_data_new); #ifdef TOOLS_ENABLED - probe_data->set_edited(true); //so it gets saved + probe_data_new->set_edited(true); //so it gets saved #endif } diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp index 2dc61efb94..0d8b7ba8f7 100644 --- a/scene/animation/animation_blend_space_2d.cpp +++ b/scene/animation/animation_blend_space_2d.cpp @@ -343,10 +343,10 @@ void AnimationNodeBlendSpace2D::_update_triangles() { points.write[i] = blend_points[i].position; } - Vector<Delaunay2D::Triangle> triangles = Delaunay2D::triangulate(points); + Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(points); - for (int i = 0; i < triangles.size(); i++) { - add_triangle(triangles[i].points[0], triangles[i].points[1], triangles[i].points[2]); + for (int i = 0; i < tr.size(); i++) { + add_triangle(tr[i].points[0], tr[i].points[1], tr[i].points[2]); } emit_signal(SNAME("triangles_updated")); } @@ -376,9 +376,9 @@ Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) { points[j], points[(j + 1) % 3] }; - Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, s); - if (first || closest.distance_to(p_point) < best_point.distance_to(p_point)) { - best_point = closest; + Vector2 closest_point = Geometry2D::get_closest_point_to_segment(p_point, s); + if (first || closest_point.distance_to(p_point) < best_point.distance_to(p_point)) { + best_point = closest_point; first = false; } } @@ -436,8 +436,8 @@ double AnimationNodeBlendSpace2D::process(double p_time, bool p_seek, bool p_see _update_triangles(); Vector2 blend_pos = get_parameter(blend_position); - int closest = get_parameter(this->closest); - double length_internal = get_parameter(this->length_internal); + int cur_closest = get_parameter(closest); + double cur_length_internal = get_parameter(length_internal); double mind = 0.0; //time of min distance point if (blend_mode == BLEND_MODE_INTERPOLATED) { @@ -528,37 +528,37 @@ double AnimationNodeBlendSpace2D::process(double p_time, bool p_seek, bool p_see } } - if (new_closest != closest && new_closest != -1) { + if (new_closest != cur_closest && new_closest != -1) { double from = 0.0; - if (blend_mode == BLEND_MODE_DISCRETE_CARRY && closest != -1) { + if (blend_mode == BLEND_MODE_DISCRETE_CARRY && cur_closest != -1) { //for ping-pong loop - Ref<AnimationNodeAnimation> na_c = static_cast<Ref<AnimationNodeAnimation>>(blend_points[closest].node); + Ref<AnimationNodeAnimation> na_c = static_cast<Ref<AnimationNodeAnimation>>(blend_points[cur_closest].node); Ref<AnimationNodeAnimation> na_n = static_cast<Ref<AnimationNodeAnimation>>(blend_points[new_closest].node); if (!na_c.is_null() && !na_n.is_null()) { na_n->set_backward(na_c->is_backward()); } //see how much animation remains - from = length_internal - blend_node(blend_points[closest].name, blend_points[closest].node, p_time, false, p_seek_root, 0.0, FILTER_IGNORE, true); + from = cur_length_internal - blend_node(blend_points[cur_closest].name, blend_points[cur_closest].node, p_time, false, p_seek_root, 0.0, FILTER_IGNORE, true); } mind = blend_node(blend_points[new_closest].name, blend_points[new_closest].node, from, true, p_seek_root, 1.0, FILTER_IGNORE, true); - length_internal = from + mind; + cur_length_internal = from + mind; - closest = new_closest; + cur_closest = new_closest; } else { - mind = blend_node(blend_points[closest].name, blend_points[closest].node, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, true); + mind = blend_node(blend_points[cur_closest].name, blend_points[cur_closest].node, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, true); } for (int i = 0; i < blend_points_used; i++) { - if (i != closest) { + if (i != cur_closest) { blend_node(blend_points[i].name, blend_points[i].node, p_time, p_seek, p_seek_root, 0, FILTER_IGNORE, sync); } } } - set_parameter(this->closest, closest); - set_parameter(this->length_internal, length_internal); + set_parameter(this->closest, cur_closest); + set_parameter(this->length_internal, cur_length_internal); return mind; } diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index c063d8f1bf..0c91729a6f 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -68,13 +68,13 @@ double AnimationNodeAnimation::process(double p_time, bool p_seek, bool p_seek_r AnimationPlayer *ap = state->player; ERR_FAIL_COND_V(!ap, 0); - double time = get_parameter(this->time); + double cur_time = get_parameter(time); if (!ap->has_animation(animation)) { AnimationNodeBlendTree *tree = Object::cast_to<AnimationNodeBlendTree>(parent); if (tree) { - String name = tree->get_node_name(Ref<AnimationNodeAnimation>(this)); - make_invalid(vformat(RTR("On BlendTree node '%s', animation not found: '%s'"), name, animation)); + String node_name = tree->get_node_name(Ref<AnimationNodeAnimation>(this)); + make_invalid(vformat(RTR("On BlendTree node '%s', animation not found: '%s'"), node_name, animation)); } else { make_invalid(vformat(RTR("Animation not found: '%s'"), animation)); @@ -86,58 +86,58 @@ double AnimationNodeAnimation::process(double p_time, bool p_seek, bool p_seek_r Ref<Animation> anim = ap->get_animation(animation); double anim_size = (double)anim->get_length(); double step = 0.0; - double prev_time = time; + double prev_time = cur_time; int pingponged = 0; bool current_backward = signbit(p_time); if (p_seek) { - step = p_time - time; - time = p_time; + step = p_time - cur_time; + cur_time = p_time; } else { p_time *= backward ? -1.0 : 1.0; - if (!(time == anim_size && !current_backward) && !(time == 0 && current_backward)) { - time = time + p_time; + if (!(cur_time == anim_size && !current_backward) && !(cur_time == 0 && current_backward)) { + cur_time = cur_time + p_time; step = p_time; } } if (anim->get_loop_mode() == Animation::LOOP_PINGPONG) { if (!Math::is_zero_approx(anim_size)) { - if ((int)Math::floor(abs(time - prev_time) / anim_size) % 2 == 0) { - if (prev_time >= 0 && time < 0) { + if ((int)Math::floor(abs(cur_time - prev_time) / anim_size) % 2 == 0) { + if (prev_time >= 0 && cur_time < 0) { backward = !backward; pingponged = -1; } - if (prev_time <= anim_size && time > anim_size) { + if (prev_time <= anim_size && cur_time > anim_size) { backward = !backward; pingponged = 1; } } - time = Math::pingpong(time, anim_size); + cur_time = Math::pingpong(cur_time, anim_size); } } else { if (anim->get_loop_mode() == Animation::LOOP_LINEAR) { if (!Math::is_zero_approx(anim_size)) { - time = Math::fposmod(time, anim_size); + cur_time = Math::fposmod(cur_time, anim_size); } - } else if (time < 0) { - step += time; - time = 0; - } else if (time > anim_size) { - step += anim_size - time; - time = anim_size; + } else if (cur_time < 0) { + step += cur_time; + cur_time = 0; + } else if (cur_time > anim_size) { + step += anim_size - cur_time; + cur_time = anim_size; } backward = false; } if (play_mode == PLAY_MODE_FORWARD) { - blend_animation(animation, time, step, p_seek, p_seek_root, 1.0, pingponged); + blend_animation(animation, cur_time, step, p_seek, p_seek_root, 1.0, pingponged); } else { - blend_animation(animation, anim_size - time, -step, p_seek, p_seek_root, 1.0, pingponged); + blend_animation(animation, anim_size - cur_time, -step, p_seek, p_seek_root, 1.0, pingponged); } - set_parameter(this->time, time); + set_parameter(time, cur_time); - return anim_size - time; + return anim_size - cur_time; } String AnimationNodeAnimation::get_caption() const { @@ -274,28 +274,28 @@ bool AnimationNodeOneShot::has_filter() const { } double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_seek_root) { - bool active = get_parameter(this->active); - bool prev_active = get_parameter(this->prev_active); - double time = get_parameter(this->time); - double remaining = get_parameter(this->remaining); - double time_to_restart = get_parameter(this->time_to_restart); + bool cur_active = get_parameter(active); + bool cur_prev_active = get_parameter(prev_active); + double cur_time = get_parameter(time); + double cur_remaining = get_parameter(remaining); + double cur_time_to_restart = get_parameter(time_to_restart); - if (!active) { + if (!cur_active) { //make it as if this node doesn't exist, pass input 0 by. - if (prev_active) { - set_parameter(this->prev_active, false); + if (cur_prev_active) { + set_parameter(prev_active, false); } - if (time_to_restart >= 0.0 && !p_seek) { - time_to_restart -= p_time; - if (time_to_restart < 0) { + if (cur_time_to_restart >= 0.0 && !p_seek) { + cur_time_to_restart -= p_time; + if (cur_time_to_restart < 0) { //restart - set_parameter(this->active, true); - active = true; + set_parameter(active, true); + cur_active = true; } - set_parameter(this->time_to_restart, time_to_restart); + set_parameter(time_to_restart, cur_time_to_restart); } - if (!active) { + if (!cur_active) { return blend_input(0, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, sync); } } @@ -303,27 +303,27 @@ double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_seek_roo bool os_seek = p_seek; if (p_seek) { - time = p_time; + cur_time = p_time; } - bool do_start = !prev_active; + bool do_start = !cur_prev_active; if (do_start) { - time = 0; + cur_time = 0; os_seek = true; - set_parameter(this->prev_active, true); + set_parameter(prev_active, true); } real_t blend; - if (time < fade_in) { + if (cur_time < fade_in) { if (fade_in > 0) { - blend = time / fade_in; + blend = cur_time / fade_in; } else { blend = 0; } - } else if (!do_start && remaining <= fade_out) { + } else if (!do_start && cur_remaining <= fade_out) { if (fade_out > 0) { - blend = (remaining / fade_out); + blend = (cur_remaining / fade_out); } else { blend = 0; } @@ -338,29 +338,29 @@ double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_seek_roo main_rem = blend_input(0, p_time, p_seek, p_seek_root, 1.0 - blend, FILTER_BLEND, sync); } - double os_rem = blend_input(1, os_seek ? time : p_time, os_seek, p_seek_root, blend, FILTER_PASS, true); + double os_rem = blend_input(1, os_seek ? cur_time : p_time, os_seek, p_seek_root, blend, FILTER_PASS, true); if (do_start) { - remaining = os_rem; + cur_remaining = os_rem; } if (!p_seek) { - time += p_time; - remaining = os_rem; - if (remaining <= 0) { - set_parameter(this->active, false); - set_parameter(this->prev_active, false); + cur_time += p_time; + cur_remaining = os_rem; + if (cur_remaining <= 0) { + set_parameter(active, false); + set_parameter(prev_active, false); if (autorestart) { double restart_sec = autorestart_delay + Math::randd() * autorestart_random_delay; - set_parameter(this->time_to_restart, restart_sec); + set_parameter(time_to_restart, restart_sec); } } } - set_parameter(this->time, time); - set_parameter(this->remaining, remaining); + set_parameter(time, cur_time); + set_parameter(remaining, cur_remaining); - return MAX(main_rem, remaining); + return MAX(main_rem, cur_remaining); } void AnimationNodeOneShot::_bind_methods() { @@ -554,11 +554,11 @@ String AnimationNodeTimeScale::get_caption() const { } double AnimationNodeTimeScale::process(double p_time, bool p_seek, bool p_seek_root) { - double scale = get_parameter(this->scale); + double cur_scale = get_parameter(scale); if (p_seek) { return blend_input(0, p_time, true, p_seek_root, 1.0, FILTER_IGNORE, true); } else { - return blend_input(0, p_time * scale, false, p_seek_root, 1.0, FILTER_IGNORE, true); + return blend_input(0, p_time * cur_scale, false, p_seek_root, 1.0, FILTER_IGNORE, true); } } @@ -584,12 +584,12 @@ String AnimationNodeTimeSeek::get_caption() const { } double AnimationNodeTimeSeek::process(double p_time, bool p_seek, bool p_seek_root) { - double seek_pos = get_parameter(this->seek_pos); + double cur_seek_pos = get_parameter(seek_pos); if (p_seek) { return blend_input(0, p_time, true, p_seek_root, 1.0, FILTER_IGNORE, true); - } else if (seek_pos >= 0) { - double ret = blend_input(0, seek_pos, true, true, 1.0, FILTER_IGNORE, true); - set_parameter(this->seek_pos, -1.0); //reset + } else if (cur_seek_pos >= 0) { + double ret = blend_input(0, cur_seek_pos, true, true, 1.0, FILTER_IGNORE, true); + set_parameter(seek_pos, -1.0); //reset return ret; } else { return blend_input(0, p_time, false, p_seek_root, 1.0, FILTER_IGNORE, true); @@ -701,80 +701,80 @@ bool AnimationNodeTransition::is_from_start() const { } double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_seek_root) { - int current = get_parameter(this->current); - int prev = get_parameter(this->prev); - int prev_current = get_parameter(this->prev_current); + int cur_current = get_parameter(current); + int cur_prev = get_parameter(prev); + int cur_prev_current = get_parameter(prev_current); - double time = get_parameter(this->time); - double prev_xfading = get_parameter(this->prev_xfading); + double cur_time = get_parameter(time); + double cur_prev_xfading = get_parameter(prev_xfading); - bool switched = current != prev_current; + bool switched = cur_current != cur_prev_current; if (switched) { - set_parameter(this->prev_current, current); - set_parameter(this->prev, prev_current); + set_parameter(prev_current, cur_current); + set_parameter(prev, cur_prev_current); - prev = prev_current; - prev_xfading = xfade_time; - time = 0; + cur_prev = cur_prev_current; + cur_prev_xfading = xfade_time; + cur_time = 0; switched = true; } - if (current < 0 || current >= enabled_inputs || prev >= enabled_inputs) { + if (cur_current < 0 || cur_current >= enabled_inputs || cur_prev >= enabled_inputs) { return 0; } double rem = 0.0; for (int i = 0; i < enabled_inputs; i++) { - if (i != current && i != prev) { + if (i != cur_current && i != cur_prev) { blend_input(i, p_time, p_seek, p_seek_root, 0, FILTER_IGNORE, sync); } } - if (prev < 0) { // process current animation, check for transition + if (cur_prev < 0) { // process current animation, check for transition - rem = blend_input(current, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, true); + rem = blend_input(cur_current, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, true); if (p_seek) { - time = p_time; + cur_time = p_time; } else { - time += p_time; + cur_time += p_time; } - if (inputs[current].auto_advance && rem <= xfade_time) { - set_parameter(this->current, (current + 1) % enabled_inputs); + if (inputs[cur_current].auto_advance && rem <= xfade_time) { + set_parameter(current, (cur_current + 1) % enabled_inputs); } } else { // cross-fading from prev to current - real_t blend = xfade_time == 0 ? 0 : (prev_xfading / xfade_time); + real_t blend = xfade_time == 0 ? 0 : (cur_prev_xfading / xfade_time); if (xfade_curve.is_valid()) { blend = xfade_curve->sample(blend); } if (from_start && !p_seek && switched) { //just switched, seek to start of current - rem = blend_input(current, 0, true, p_seek_root, 1.0 - blend, FILTER_IGNORE, true); + rem = blend_input(cur_current, 0, true, p_seek_root, 1.0 - blend, FILTER_IGNORE, true); } else { - rem = blend_input(current, p_time, p_seek, p_seek_root, 1.0 - blend, FILTER_IGNORE, true); + rem = blend_input(cur_current, p_time, p_seek, p_seek_root, 1.0 - blend, FILTER_IGNORE, true); } if (p_seek) { - blend_input(prev, p_time, true, p_seek_root, blend, FILTER_IGNORE, true); - time = p_time; + blend_input(cur_prev, p_time, true, p_seek_root, blend, FILTER_IGNORE, true); + cur_time = p_time; } else { - blend_input(prev, p_time, false, p_seek_root, blend, FILTER_IGNORE, true); - time += p_time; - prev_xfading -= p_time; - if (prev_xfading < 0) { - set_parameter(this->prev, -1); + blend_input(cur_prev, p_time, false, p_seek_root, blend, FILTER_IGNORE, true); + cur_time += p_time; + cur_prev_xfading -= p_time; + if (cur_prev_xfading < 0) { + set_parameter(prev, -1); } } } - set_parameter(this->time, time); - set_parameter(this->prev_xfading, prev_xfading); + set_parameter(time, cur_time); + set_parameter(prev_xfading, cur_prev_xfading); return rem; } @@ -1070,10 +1070,10 @@ Ref<AnimationNode> AnimationNodeBlendTree::get_child_by_name(const StringName &p } bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; - if (name.begins_with("nodes/")) { - String node_name = name.get_slicec('/', 1); - String what = name.get_slicec('/', 2); + String prop_name = p_name; + if (prop_name.begins_with("nodes/")) { + String node_name = prop_name.get_slicec('/', 1); + String what = prop_name.get_slicec('/', 2); if (what == "node") { Ref<AnimationNode> anode = p_value; @@ -1089,7 +1089,7 @@ bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_val } return true; } - } else if (name == "node_connections") { + } else if (prop_name == "node_connections") { Array conns = p_value; ERR_FAIL_COND_V(conns.size() % 3 != 0, false); @@ -1103,10 +1103,10 @@ bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_val } bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; - if (name.begins_with("nodes/")) { - String node_name = name.get_slicec('/', 1); - String what = name.get_slicec('/', 2); + String prop_name = p_name; + if (prop_name.begins_with("nodes/")) { + String node_name = prop_name.get_slicec('/', 1); + String what = prop_name.get_slicec('/', 2); if (what == "node") { if (nodes.has(node_name)) { @@ -1121,7 +1121,7 @@ bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) cons return true; } } - } else if (name == "node_connections") { + } else if (prop_name == "node_connections") { List<NodeConnection> nc; get_node_connections(&nc); Array conns; @@ -1150,11 +1150,11 @@ void AnimationNodeBlendTree::_get_property_list(List<PropertyInfo> *p_list) cons names.sort_custom<StringName::AlphCompare>(); for (const StringName &E : names) { - String name = E; - if (name != "output") { - p_list->push_back(PropertyInfo(Variant::OBJECT, "nodes/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NO_EDITOR)); + String prop_name = E; + if (prop_name != "output") { + p_list->push_back(PropertyInfo(Variant::OBJECT, "nodes/" + prop_name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NO_EDITOR)); } - p_list->push_back(PropertyInfo(Variant::VECTOR2, "nodes/" + name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR)); + p_list->push_back(PropertyInfo(Variant::VECTOR2, "nodes/" + prop_name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR)); } p_list->push_back(PropertyInfo(Variant::ARRAY, "node_connections", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR)); diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index facffb99ee..fa33591e8b 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -728,11 +728,11 @@ void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<Animation ERR_FAIL_COND(p_node.is_null()); ERR_FAIL_COND(String(p_name).contains("/")); - State state; - state.node = p_node; - state.position = p_position; + State state_new; + state_new.node = p_node; + state_new.position = p_position; - states[p_name] = state; + states[p_name] = state_new; Ref<AnimationNodeStateMachine> anodesm = p_node; @@ -960,8 +960,8 @@ bool AnimationNodeStateMachine::_can_connect(const StringName &p_name, Vector<An return true; } - String name = p_name; - Vector<String> path = name.split("/"); + String node_name = p_name; + Vector<String> path = node_name.split("/"); if (path.size() < 2) { return false; @@ -969,12 +969,12 @@ bool AnimationNodeStateMachine::_can_connect(const StringName &p_name, Vector<An if (path[0] == "..") { if (prev_state_machine != nullptr) { - return prev_state_machine->_can_connect(name.replace_first("../", ""), p_parents); + return prev_state_machine->_can_connect(node_name.replace_first("../", ""), p_parents); } } else if (states.has(path[0])) { Ref<AnimationNodeStateMachine> anodesm = states[path[0]].node; if (anodesm.is_valid()) { - return anodesm->_can_connect(name.replace_first(path[0] + "/", ""), p_parents); + return anodesm->_can_connect(node_name.replace_first(path[0] + "/", ""), p_parents); } } @@ -1151,10 +1151,10 @@ Vector2 AnimationNodeStateMachine::get_graph_offset() const { } double AnimationNodeStateMachine::process(double p_time, bool p_seek, bool p_seek_root) { - Ref<AnimationNodeStateMachinePlayback> playback = get_parameter(this->playback); - ERR_FAIL_COND_V(playback.is_null(), 0.0); + Ref<AnimationNodeStateMachinePlayback> playback_new = get_parameter(playback); + ERR_FAIL_COND_V(playback_new.is_null(), 0.0); - return playback->process(this, p_time, p_seek, p_seek_root); + return playback_new->process(this, p_time, p_seek, p_seek_root); } String AnimationNodeStateMachine::get_caption() const { @@ -1178,10 +1178,10 @@ Ref<AnimationNode> AnimationNodeStateMachine::get_child_by_name(const StringName } bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; - if (name.begins_with("states/")) { - String node_name = name.get_slicec('/', 1); - String what = name.get_slicec('/', 2); + String prop_name = p_name; + if (prop_name.begins_with("states/")) { + String node_name = prop_name.get_slicec('/', 1); + String what = prop_name.get_slicec('/', 2); if (what == "node") { Ref<AnimationNode> anode = p_value; @@ -1197,7 +1197,7 @@ bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_ } return true; } - } else if (name == "transitions") { + } else if (prop_name == "transitions") { Array trans = p_value; ERR_FAIL_COND_V(trans.size() % 3 != 0, false); @@ -1205,7 +1205,7 @@ bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_ add_transition(trans[i], trans[i + 1], trans[i + 2]); } return true; - } else if (name == "graph_offset") { + } else if (prop_name == "graph_offset") { set_graph_offset(p_value); return true; } @@ -1214,10 +1214,10 @@ bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_ } bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; - if (name.begins_with("states/")) { - String node_name = name.get_slicec('/', 1); - String what = name.get_slicec('/', 2); + String prop_name = p_name; + if (prop_name.begins_with("states/")) { + String node_name = prop_name.get_slicec('/', 1); + String what = prop_name.get_slicec('/', 2); if (what == "node") { if (states.has(node_name) && can_edit_node(node_name)) { @@ -1232,7 +1232,7 @@ bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) c return true; } } - } else if (name == "transitions") { + } else if (prop_name == "transitions") { Array trans; for (int i = 0; i < transitions.size(); i++) { String from = transitions[i].from; @@ -1249,7 +1249,7 @@ bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) c r_ret = trans; return true; - } else if (name == "graph_offset") { + } else if (prop_name == "graph_offset") { r_ret = get_graph_offset(); return true; } @@ -1264,9 +1264,9 @@ void AnimationNodeStateMachine::_get_property_list(List<PropertyInfo> *p_list) c } names.sort_custom<StringName::AlphCompare>(); - for (const StringName &name : names) { - p_list->push_back(PropertyInfo(Variant::OBJECT, "states/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NO_EDITOR)); - p_list->push_back(PropertyInfo(Variant::VECTOR2, "states/" + name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR)); + for (const StringName &prop_name : names) { + p_list->push_back(PropertyInfo(Variant::OBJECT, "states/" + prop_name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NO_EDITOR)); + p_list->push_back(PropertyInfo(Variant::VECTOR2, "states/" + prop_name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR)); } p_list->push_back(PropertyInfo(Variant::ARRAY, "transitions", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR)); diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 54b10d9d57..fe67c0886f 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1504,9 +1504,9 @@ bool AnimationPlayer::has_animation(const StringName &p_name) const { Ref<Animation> AnimationPlayer::get_animation(const StringName &p_name) const { ERR_FAIL_COND_V_MSG(!animation_set.has(p_name), Ref<Animation>(), vformat("Animation not found: \"%s\".", p_name)); - const AnimationData &data = animation_set[p_name]; + const AnimationData &anim_data = animation_set[p_name]; - return data.animation; + return anim_data.animation; } void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const { @@ -2037,8 +2037,7 @@ Ref<AnimatedValuesBackup> AnimationPlayer::apply_reset(bool p_user_initiated) { aux_player->add_animation_library("", al); aux_player->set_assigned_animation(SceneStringNames::get_singleton()->RESET); // Forcing the use of the original root because the scene where original player belongs may be not the active one - Node *root = get_node(get_root()); - Ref<AnimatedValuesBackup> old_values = aux_player->backup_animated_values(root); + Ref<AnimatedValuesBackup> old_values = aux_player->backup_animated_values(get_node(get_root())); aux_player->seek(0.0f, true); aux_player->queue_delete(); diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 05a4a2d024..4d09fa619c 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -97,8 +97,8 @@ void AnimationNode::blend_animation(const StringName &p_animation, double p_time if (animation.is_null()) { AnimationNodeBlendTree *btree = Object::cast_to<AnimationNodeBlendTree>(parent); if (btree) { - String name = btree->get_node_name(Ref<AnimationNodeAnimation>(this)); - make_invalid(vformat(RTR("In node '%s', invalid animation: '%s'."), name, p_animation)); + String node_name = btree->get_node_name(Ref<AnimationNodeAnimation>(this)); + make_invalid(vformat(RTR("In node '%s', invalid animation: '%s'."), node_name, p_animation)); } else { make_invalid(vformat(RTR("Invalid animation: '%s'."), p_animation)); } @@ -160,8 +160,8 @@ double AnimationNode::blend_input(int p_input, double p_time, bool p_seek, bool StringName node_name = connections[p_input]; if (!blend_tree->has_node(node_name)) { - String name = blend_tree->get_node_name(Ref<AnimationNode>(this)); - make_invalid(vformat(RTR("Nothing connected to input '%s' of node '%s'."), get_input_name(p_input), name)); + String node_name2 = blend_tree->get_node_name(Ref<AnimationNode>(this)); + make_invalid(vformat(RTR("Nothing connected to input '%s' of node '%s'."), get_input_name(p_input), node_name2)); return 0; } diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 4a0f870406..aa58e1044a 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -263,9 +263,9 @@ bool Tween::step(double p_delta) { } if (is_bound) { - Node *bound_node = get_bound_node(); - if (bound_node) { - if (!bound_node->is_inside_tree()) { + Node *node = get_bound_node(); + if (node) { + if (!node->is_inside_tree()) { return true; } } else { @@ -342,9 +342,9 @@ bool Tween::step(double p_delta) { bool Tween::can_process(bool p_tree_paused) const { if (is_bound && pause_mode == TWEEN_PAUSE_BOUND) { - Node *bound_node = get_bound_node(); - if (bound_node) { - return bound_node->is_inside_tree() && bound_node->can_process(); + Node *node = get_bound_node(); + if (node) { + return node->is_inside_tree() && node->can_process(); } } diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 4c5a63e52c..bfc3c25fe6 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -450,9 +450,9 @@ void SceneDebuggerObject::_parse_script_properties(Script *p_script, ScriptInsta for (const KeyValue<StringName, Variant> &E : sc.value) { String script_path = sc.key == p_script ? "" : sc.key->get_path().get_file() + "/"; if (E.value.get_type() == Variant::OBJECT) { - Variant id = ((Object *)E.value)->get_instance_id(); - PropertyInfo pi(id.get_type(), "Constants/" + E.key, PROPERTY_HINT_OBJECT_ID, "Object"); - properties.push_back(SceneDebuggerProperty(pi, id)); + Variant inst_id = ((Object *)E.value)->get_instance_id(); + PropertyInfo pi(inst_id.get_type(), "Constants/" + E.key, PROPERTY_HINT_OBJECT_ID, "Object"); + properties.push_back(SceneDebuggerProperty(pi, inst_id)); } else { PropertyInfo pi(E.value.get_type(), "Constants/" + script_path + E.key); properties.push_back(SceneDebuggerProperty(pi, E.value)); diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index 94d296977b..70707dba11 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -201,7 +201,7 @@ void CodeEdit::_notification(int p_what) { if (caret_visible && !code_hint.is_empty() && (!code_completion_active || (code_completion_below != code_hint_draw_below))) { const int font_height = font->get_height(font_size); Ref<StyleBox> sb = get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel")); - Color font_color = get_theme_color(SNAME("font_color"), SNAME("TooltipLabel")); + Color color = get_theme_color(SNAME("font_color"), SNAME("TooltipLabel")); Vector<String> code_hint_lines = code_hint.split("\n"); int line_count = code_hint_lines.size(); @@ -238,17 +238,17 @@ void CodeEdit::_notification(int p_what) { Point2 round_ofs = hint_ofs + sb->get_offset() + Vector2(0, font->get_ascent(font_size) + font_height * i + yofs); round_ofs = round_ofs.round(); - draw_string(font, round_ofs, line.replace(String::chr(0xFFFF), ""), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_color); + draw_string(font, round_ofs, line.replace(String::chr(0xFFFF), ""), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color); if (end > 0) { // Draw an underline for the currently edited function parameter. const Vector2 b = hint_ofs + sb->get_offset() + Vector2(begin, font_height + font_height * i + yofs); - draw_line(b, b + Vector2(end - begin, 0), font_color, 2); + draw_line(b, b + Vector2(end - begin, 0), color, 2); // Draw a translucent text highlight as well. const Rect2 highlight_rect = Rect2( b - Vector2(0, font_height), Vector2(end - begin, font_height)); - draw_rect(highlight_rect, font_color * Color(1, 1, 1, 0.2)); + draw_rect(highlight_rect, color * Color(1, 1, 1, 0.2)); } yofs += line_spacing; } @@ -2135,15 +2135,15 @@ String CodeEdit::get_text_for_symbol_lookup() { StringBuilder lookup_text; const int text_size = get_line_count(); for (int i = 0; i < text_size; i++) { - String text = get_line(i); + String line_text = get_line(i); if (i == line) { - lookup_text += text.substr(0, col); + lookup_text += line_text.substr(0, col); /* Not unicode, represents the cursor. */ lookup_text += String::chr(0xFFFF); - lookup_text += text.substr(col, text.size()); + lookup_text += line_text.substr(col, line_text.size()); } else { - lookup_text += text; + lookup_text += line_text; } if (i != text_size - 1) { diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 36b770408e..f1e18640e6 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -357,59 +357,59 @@ void ColorPicker::add_mode(ColorMode *p_mode) { } void ColorPicker::create_slider(GridContainer *gc, int idx) { - Label *l = memnew(Label()); - l->set_v_size_flags(SIZE_SHRINK_CENTER); - gc->add_child(l); + Label *lbl = memnew(Label()); + lbl->set_v_size_flags(SIZE_SHRINK_CENTER); + gc->add_child(lbl); - HSlider *s = memnew(HSlider); - s->set_v_size_flags(SIZE_SHRINK_CENTER); - s->set_focus_mode(FOCUS_NONE); - gc->add_child(s); + HSlider *slider = memnew(HSlider); + slider->set_v_size_flags(SIZE_SHRINK_CENTER); + slider->set_focus_mode(FOCUS_NONE); + gc->add_child(slider); - SpinBox *v = memnew(SpinBox); - s->share(v); - gc->add_child(v); + SpinBox *val = memnew(SpinBox); + slider->share(val); + gc->add_child(val); - LineEdit *vle = v->get_line_edit(); + LineEdit *vle = val->get_line_edit(); vle->connect("focus_entered", callable_mp(this, &ColorPicker::_focus_enter), CONNECT_DEFERRED); vle->connect("focus_exited", callable_mp(this, &ColorPicker::_focus_exit)); vle->connect("text_changed", callable_mp(this, &ColorPicker::_text_changed)); vle->connect("gui_input", callable_mp(this, &ColorPicker::_line_edit_input)); vle->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT); - v->connect("gui_input", callable_mp(this, &ColorPicker::_slider_or_spin_input)); + val->connect("gui_input", callable_mp(this, &ColorPicker::_slider_or_spin_input)); - s->set_h_size_flags(SIZE_EXPAND_FILL); + slider->set_h_size_flags(SIZE_EXPAND_FILL); - s->connect("value_changed", callable_mp(this, &ColorPicker::_value_changed)); - s->connect("draw", callable_mp(this, &ColorPicker::_slider_draw).bind(idx)); - s->connect("gui_input", callable_mp(this, &ColorPicker::_slider_or_spin_input)); + slider->connect("value_changed", callable_mp(this, &ColorPicker::_value_changed)); + slider->connect("draw", callable_mp(this, &ColorPicker::_slider_draw).bind(idx)); + slider->connect("gui_input", callable_mp(this, &ColorPicker::_slider_or_spin_input)); if (idx < SLIDER_COUNT) { - sliders[idx] = s; - values[idx] = v; - labels[idx] = l; + sliders[idx] = slider; + values[idx] = val; + labels[idx] = lbl; } else { - alpha_slider = s; - alpha_value = v; - alpha_label = l; + alpha_slider = slider; + alpha_value = val; + alpha_label = lbl; } } -HSlider *ColorPicker::get_slider(int idx) { - if (idx < SLIDER_COUNT) { - return sliders[idx]; +HSlider *ColorPicker::get_slider(int p_idx) { + if (p_idx < SLIDER_COUNT) { + return sliders[p_idx]; } return alpha_slider; } Vector<float> ColorPicker::get_active_slider_values() { - Vector<float> values; + Vector<float> cur_values; for (int i = 0; i < current_slider_count; i++) { - values.push_back(sliders[i]->get_value()); + cur_values.push_back(sliders[i]->get_value()); } - values.push_back(alpha_slider->get_value()); - return values; + cur_values.push_back(alpha_slider->get_value()); + return cur_values; } void ColorPicker::_copy_color_to_hsv() { @@ -629,23 +629,23 @@ inline int ColorPicker::_get_preset_size() { } void ColorPicker::_add_preset_button(int p_size, const Color &p_color) { - ColorPresetButton *btn_preset = memnew(ColorPresetButton(p_color, p_size)); - btn_preset->set_tooltip_text(vformat(RTR("Color: #%s\nLMB: Apply color\nRMB: Remove preset"), p_color.to_html(p_color.a < 1))); - btn_preset->set_drag_forwarding(this); - btn_preset->set_button_group(preset_group); - preset_container->add_child(btn_preset); - btn_preset->set_pressed(true); - btn_preset->connect("gui_input", callable_mp(this, &ColorPicker::_preset_input).bind(p_color)); + ColorPresetButton *btn_preset_new = memnew(ColorPresetButton(p_color, p_size)); + btn_preset_new->set_tooltip_text(vformat(RTR("Color: #%s\nLMB: Apply color\nRMB: Remove preset"), p_color.to_html(p_color.a < 1))); + btn_preset_new->set_drag_forwarding(this); + btn_preset_new->set_button_group(preset_group); + preset_container->add_child(btn_preset_new); + btn_preset_new->set_pressed(true); + btn_preset_new->connect("gui_input", callable_mp(this, &ColorPicker::_preset_input).bind(p_color)); } void ColorPicker::_add_recent_preset_button(int p_size, const Color &p_color) { - ColorPresetButton *btn_preset = memnew(ColorPresetButton(p_color, p_size)); - btn_preset->set_tooltip_text(vformat(RTR("Color: #%s\nLMB: Apply color"), p_color.to_html(p_color.a < 1))); - btn_preset->set_button_group(recent_preset_group); - recent_preset_hbc->add_child(btn_preset); - recent_preset_hbc->move_child(btn_preset, 0); - btn_preset->set_pressed(true); - btn_preset->connect("toggled", callable_mp(this, &ColorPicker::_recent_preset_pressed).bind(btn_preset)); + ColorPresetButton *btn_preset_new = memnew(ColorPresetButton(p_color, p_size)); + btn_preset_new->set_tooltip_text(vformat(RTR("Color: #%s\nLMB: Apply color"), p_color.to_html(p_color.a < 1))); + btn_preset_new->set_button_group(recent_preset_group); + recent_preset_hbc->add_child(btn_preset_new); + recent_preset_hbc->move_child(btn_preset_new, 0); + btn_preset_new->set_pressed(true); + btn_preset_new->connect("toggled", callable_mp(this, &ColorPicker::_recent_preset_pressed).bind(btn_preset_new)); } void ColorPicker::_show_hide_preset(const bool &p_is_btn_pressed, Button *p_btn_preset, Container *p_preset_container) { @@ -904,7 +904,7 @@ bool ColorPicker::is_deferred_mode() const { } void ColorPicker::_update_text_value() { - bool visible = true; + bool text_visible = true; if (text_is_constructor) { String t = "Color(" + String::num(color.r) + ", " + String::num(color.g) + ", " + String::num(color.b); if (edit_alpha && color.a < 1) { @@ -916,13 +916,13 @@ void ColorPicker::_update_text_value() { } if (color.r > 1 || color.g > 1 || color.b > 1 || color.r < 0 || color.g < 0 || color.b < 0) { - visible = false; + text_visible = false; } else if (!text_is_constructor) { c_text->set_text(color.to_html(edit_alpha && color.a < 1)); } - text_type->set_visible(visible); - c_text->set_visible(visible); + text_type->set_visible(text_visible); + c_text->set_visible(text_visible); } void ColorPicker::_sample_input(const Ref<InputEvent> &p_event) { diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index dc9294df6d..2dcae2553c 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1793,7 +1793,7 @@ bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const } } - bool ret; + bool ret = false; if (GDVIRTUAL_CALL(_can_drop_data, p_point, p_data, ret)) { return ret; } diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index f5edaf02d8..bf4dd3d245 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -208,24 +208,24 @@ void AcceptDialog::register_text_enter(Control *p_line_edit) { } void AcceptDialog::_update_child_rects() { - Size2 size = get_size(); + Size2 dlg_size = get_size(); float h_margins = theme_cache.panel_style->get_margin(SIDE_LEFT) + theme_cache.panel_style->get_margin(SIDE_RIGHT); float v_margins = theme_cache.panel_style->get_margin(SIDE_TOP) + theme_cache.panel_style->get_margin(SIDE_BOTTOM); // Fill the entire size of the window with the background. bg_panel->set_position(Point2()); - bg_panel->set_size(size); + bg_panel->set_size(dlg_size); // Place the buttons from the bottom edge to their minimum required size. Size2 buttons_minsize = buttons_hbox->get_combined_minimum_size(); - Size2 buttons_size = Size2(size.x - h_margins, buttons_minsize.y); - Point2 buttons_position = Point2(theme_cache.panel_style->get_margin(SIDE_LEFT), size.y - theme_cache.panel_style->get_margin(SIDE_BOTTOM) - buttons_size.y); + Size2 buttons_size = Size2(dlg_size.x - h_margins, buttons_minsize.y); + Point2 buttons_position = Point2(theme_cache.panel_style->get_margin(SIDE_LEFT), dlg_size.y - theme_cache.panel_style->get_margin(SIDE_BOTTOM) - buttons_size.y); buttons_hbox->set_position(buttons_position); buttons_hbox->set_size(buttons_size); // Place the content from the top to fill the rest of the space (minus the separation). Point2 content_position = Point2(theme_cache.panel_style->get_margin(SIDE_LEFT), theme_cache.panel_style->get_margin(SIDE_TOP)); - Size2 content_size = Size2(size.x - h_margins, size.y - v_margins - buttons_size.y - theme_cache.buttons_separation); + Size2 content_size = Size2(dlg_size.x - h_margins, dlg_size.y - v_margins - buttons_size.y - theme_cache.buttons_separation); for (int i = 0; i < get_child_count(); i++) { Control *c = Object::cast_to<Control>(get_child(i)); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index cf7f439aef..cade65108c 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -743,10 +743,10 @@ void FileDialog::set_current_path(const String &p_path) { if (pos == -1) { set_current_file(p_path); } else { - String dir = p_path.substr(0, pos); - String file = p_path.substr(pos + 1, p_path.length()); - set_current_dir(dir); - set_current_file(file); + String path_dir = p_path.substr(0, pos); + String path_file = p_path.substr(pos + 1, p_path.length()); + set_current_dir(path_dir); + set_current_file(path_file); } } diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 7295ab9e9d..90552c32c2 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -92,8 +92,8 @@ void GraphEditMinimap::update_minimap() { Rect2 GraphEditMinimap::get_camera_rect() { Vector2 camera_center = _convert_from_graph_position(camera_position + camera_size / 2) + minimap_offset; Vector2 camera_viewport = _convert_from_graph_position(camera_size); - Vector2 camera_position = (camera_center - camera_viewport / 2); - return Rect2(camera_position, camera_viewport); + Vector2 camera_pos = (camera_center - camera_viewport / 2); + return Rect2(camera_pos, camera_viewport); } Vector2 GraphEditMinimap::_get_render_size() { @@ -1475,7 +1475,7 @@ void GraphEdit::force_connection_drag_end() { } bool GraphEdit::is_node_hover_valid(const StringName &p_from, const int p_from_port, const StringName &p_to, const int p_to_port) { - bool valid; + bool valid = false; if (GDVIRTUAL_CALL(_is_node_hover_valid, p_from, p_from_port, p_to, p_to_port, valid)) { return valid; } diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 21c0b5a842..5df4c066e4 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -294,14 +294,14 @@ void GraphNode::_resort() { bool GraphNode::has_point(const Point2 &p_point) const { if (comment) { - Ref<StyleBox> comment = get_theme_stylebox(SNAME("comment")); + Ref<StyleBox> comment_sb = get_theme_stylebox(SNAME("comment")); Ref<Texture2D> resizer = get_theme_icon(SNAME("resizer")); if (Rect2(get_size() - resizer->get_size(), resizer->get_size()).has_point(p_point)) { return true; } - if (Rect2(0, 0, get_size().width, comment->get_margin(SIDE_TOP)).has_point(p_point)) { + if (Rect2(0, 0, get_size().width, comment_sb->get_margin(SIDE_TOP)).has_point(p_point)) { return true; } diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 357f2480bd..0dc791f71d 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -1296,9 +1296,9 @@ void ItemList::_notification(int p_what) { draw_rect.size = adj.size; } - Color modulate = items[i].icon_modulate; + Color icon_modulate = items[i].icon_modulate; if (items[i].disabled) { - modulate.a *= 0.5; + icon_modulate.a *= 0.5; } // If the icon is transposed, we have to switch the size so that it is drawn correctly @@ -1313,7 +1313,7 @@ void ItemList::_notification(int p_what) { if (rtl) { draw_rect.position.x = size.width - draw_rect.position.x - draw_rect.size.x; } - draw_texture_rect_region(items[i].icon, draw_rect, region, modulate, items[i].icon_transposed); + draw_texture_rect_region(items[i].icon, draw_rect, region, icon_modulate, items[i].icon_transposed); } if (items[i].tag_icon.is_valid()) { @@ -1336,9 +1336,9 @@ void ItemList::_notification(int p_what) { max_len = size2.x; } - Color modulate = items[i].selected ? theme_cache.font_selected_color : (items[i].custom_fg != Color() ? items[i].custom_fg : theme_cache.font_color); + Color txt_modulate = items[i].selected ? theme_cache.font_selected_color : (items[i].custom_fg != Color() ? items[i].custom_fg : theme_cache.font_color); if (items[i].disabled) { - modulate.a *= 0.5; + txt_modulate.a *= 0.5; } if (icon_mode == ICON_MODE_TOP && max_text_lines > 0) { @@ -1355,7 +1355,7 @@ void ItemList::_notification(int p_what) { items[i].text_buf->draw_outline(get_canvas_item(), text_ofs, theme_cache.font_outline_size, theme_cache.font_outline_color); } - items[i].text_buf->draw(get_canvas_item(), text_ofs, modulate); + items[i].text_buf->draw(get_canvas_item(), text_ofs, txt_modulate); } else { if (fixed_column_width > 0) { size2.x = MIN(size2.x, fixed_column_width); @@ -1387,7 +1387,7 @@ void ItemList::_notification(int p_what) { } if (width - text_ofs.x > 0) { - items[i].text_buf->draw(get_canvas_item(), text_ofs, modulate); + items[i].text_buf->draw(get_canvas_item(), text_ofs, txt_modulate); } } } diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 306ca3d340..bf7c59d1cd 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -102,12 +102,12 @@ void Label::_shape() { const Ref<Font> &font = (settings.is_valid() && settings->get_font().is_valid()) ? settings->get_font() : theme_cache.font; int font_size = settings.is_valid() ? settings->get_font_size() : theme_cache.font_size; ERR_FAIL_COND(font.is_null()); - String text = (uppercase) ? TS->string_to_upper(xl_text, language) : xl_text; + String txt = (uppercase) ? TS->string_to_upper(xl_text, language) : xl_text; if (visible_chars >= 0 && visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) { - text = text.substr(0, visible_chars); + txt = txt.substr(0, visible_chars); } if (dirty) { - TS->shaped_text_add_string(text_rid, text, font->get_rids(), font_size, font->get_opentype_features(), language); + TS->shaped_text_add_string(text_rid, txt, font->get_rids(), font_size, font->get_opentype_features(), language); } else { int spans = TS->shaped_get_span_count(text_rid); for (int i = 0; i < spans; i++) { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index eb34559a14..36e85b5d02 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1058,8 +1058,8 @@ void LineEdit::_notification(int p_what) { if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_IME)) { DisplayServer::get_singleton()->window_set_ime_active(true, get_viewport()->get_window_id()); - Point2 caret_column = Point2(get_caret_column(), 1) * get_minimum_size().height; - DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + caret_column, get_viewport()->get_window_id()); + Point2 column = Point2(get_caret_column(), 1) * get_minimum_size().height; + DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + column, get_viewport()->get_window_id()); } show_virtual_keyboard(); diff --git a/scene/gui/menu_bar.cpp b/scene/gui/menu_bar.cpp index 75592a1b99..742042f65f 100644 --- a/scene/gui/menu_bar.cpp +++ b/scene/gui/menu_bar.cpp @@ -213,19 +213,19 @@ void MenuBar::_popup_visibility_changed(bool p_visible) { } if (switch_on_hover) { - Window *window = Object::cast_to<Window>(get_viewport()); - if (window) { - mouse_pos_adjusted = window->get_position(); - - if (window->is_embedded()) { - Window *window_parent = Object::cast_to<Window>(window->get_parent()->get_viewport()); - while (window_parent) { - if (!window_parent->is_embedded()) { - mouse_pos_adjusted += window_parent->get_position(); + Window *wnd = Object::cast_to<Window>(get_viewport()); + if (wnd) { + mouse_pos_adjusted = wnd->get_position(); + + if (wnd->is_embedded()) { + Window *wnd_parent = Object::cast_to<Window>(wnd->get_parent()->get_viewport()); + while (wnd_parent) { + if (!wnd_parent->is_embedded()) { + mouse_pos_adjusted += wnd_parent->get_position(); break; } - window_parent = Object::cast_to<Window>(window_parent->get_parent()->get_viewport()); + wnd_parent = Object::cast_to<Window>(wnd_parent->get_parent()->get_viewport()); } } diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index fa8df48412..78aeab9457 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -61,19 +61,19 @@ void MenuButton::_popup_visibility_changed(bool p_visible) { } if (switch_on_hover) { - Window *window = Object::cast_to<Window>(get_viewport()); - if (window) { - mouse_pos_adjusted = window->get_position(); - - if (window->is_embedded()) { - Window *window_parent = Object::cast_to<Window>(window->get_parent()->get_viewport()); - while (window_parent) { - if (!window_parent->is_embedded()) { - mouse_pos_adjusted += window_parent->get_position(); + Window *wnd = Object::cast_to<Window>(get_viewport()); + if (wnd) { + mouse_pos_adjusted = wnd->get_position(); + + if (wnd->is_embedded()) { + Window *wnd_parent = Object::cast_to<Window>(wnd->get_parent()->get_viewport()); + while (wnd_parent) { + if (!wnd_parent->is_embedded()) { + mouse_pos_adjusted += wnd_parent->get_position(); break; } - window_parent = Object::cast_to<Window>(window_parent->get_parent()->get_viewport()); + wnd_parent = Object::cast_to<Window>(wnd_parent->get_parent()->get_viewport()); } } diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index ceae3791f3..a6915f9e61 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -128,50 +128,50 @@ void Popup::_bind_methods() { Rect2i Popup::_popup_adjust_rect() const { ERR_FAIL_COND_V(!is_inside_tree(), Rect2()); - Rect2i parent = get_usable_parent_rect(); + Rect2i parent_rect = get_usable_parent_rect(); - if (parent == Rect2i()) { + if (parent_rect == Rect2i()) { return Rect2i(); } Rect2i current(get_position(), get_size()); - if (current.position.x + current.size.x > parent.position.x + parent.size.x) { - current.position.x = parent.position.x + parent.size.x - current.size.x; + if (current.position.x + current.size.x > parent_rect.position.x + parent_rect.size.x) { + current.position.x = parent_rect.position.x + parent_rect.size.x - current.size.x; } - if (current.position.x < parent.position.x) { - current.position.x = parent.position.x; + if (current.position.x < parent_rect.position.x) { + current.position.x = parent_rect.position.x; } - if (current.position.y + current.size.y > parent.position.y + parent.size.y) { - current.position.y = parent.position.y + parent.size.y - current.size.y; + if (current.position.y + current.size.y > parent_rect.position.y + parent_rect.size.y) { + current.position.y = parent_rect.position.y + parent_rect.size.y - current.size.y; } - if (current.position.y < parent.position.y) { - current.position.y = parent.position.y; + if (current.position.y < parent_rect.position.y) { + current.position.y = parent_rect.position.y; } - if (current.size.y > parent.size.y) { - current.size.y = parent.size.y; + if (current.size.y > parent_rect.size.y) { + current.size.y = parent_rect.size.y; } - if (current.size.x > parent.size.x) { - current.size.x = parent.size.x; + if (current.size.x > parent_rect.size.x) { + current.size.x = parent_rect.size.x; } // Early out if max size not set. - Size2i max_size = get_max_size(); - if (max_size <= Size2()) { + Size2i popup_max_size = get_max_size(); + if (popup_max_size <= Size2()) { return current; } - if (current.size.x > max_size.x) { - current.size.x = max_size.x; + if (current.size.x > popup_max_size.x) { + current.size.x = popup_max_size.x; } - if (current.size.y > max_size.y) { - current.size.y = max_size.y; + if (current.size.y > popup_max_size.y) { + current.size.y = popup_max_size.y; } return current; diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 10e13042a7..4cdde5902e 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -58,20 +58,20 @@ Size2 PopupMenu::_get_contents_minimum_size() const { bool has_check = false; for (int i = 0; i < items.size(); i++) { - Size2 size; + Size2 item_size; Size2 icon_size = items[i].get_icon_size(); - size.height = _get_item_height(i); + item_size.height = _get_item_height(i); icon_w = MAX(icon_size.width, icon_w); - size.width += items[i].indent * theme_cache.indent; + item_size.width += items[i].indent * theme_cache.indent; if (items[i].checkable_type && !items[i].separator) { has_check = true; } - size.width += items[i].text_buf->get_size().x; - size.height += theme_cache.v_separation; + item_size.width += items[i].text_buf->get_size().x; + item_size.height += theme_cache.v_separation; if (items[i].accel != Key::NONE || (items[i].shortcut.is_valid() && items[i].shortcut->has_valid_event())) { int accel_w = theme_cache.h_separation * 2; @@ -80,12 +80,12 @@ Size2 PopupMenu::_get_contents_minimum_size() const { } if (!items[i].submenu.is_empty()) { - size.width += theme_cache.submenu->get_width(); + item_size.width += theme_cache.submenu->get_width(); } - max_w = MAX(max_w, size.width); + max_w = MAX(max_w, item_size.width); - minsize.height += size.height; + minsize.height += item_size.height; } int item_side_padding = theme_cache.item_start_padding + theme_cache.item_end_padding; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 7ea46a0b4f..5060bacba5 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -167,17 +167,17 @@ String RichTextLabel::_roman(int p_num, bool p_capitalize) const { }; String s; if (p_capitalize) { - const String M[] = { "", "M", "MM", "MMM" }; - const String C[] = { "", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" }; - const String X[] = { "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" }; - const String I[] = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" }; - s = M[p_num / 1000] + C[(p_num % 1000) / 100] + X[(p_num % 100) / 10] + I[p_num % 10]; + const String roman_M[] = { "", "M", "MM", "MMM" }; + const String roman_C[] = { "", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" }; + const String roman_X[] = { "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" }; + const String roman_I[] = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" }; + s = roman_M[p_num / 1000] + roman_C[(p_num % 1000) / 100] + roman_X[(p_num % 100) / 10] + roman_I[p_num % 10]; } else { - const String M[] = { "", "m", "mm", "mmm" }; - const String C[] = { "", "c", "cc", "ccc", "cd", "d", "dc", "dcc", "dccc", "cm" }; - const String X[] = { "", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc" }; - const String I[] = { "", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix" }; - s = M[p_num / 1000] + C[(p_num % 1000) / 100] + X[(p_num % 100) / 10] + I[p_num % 10]; + const String roman_M[] = { "", "m", "mm", "mmm" }; + const String roman_C[] = { "", "c", "cc", "ccc", "cd", "d", "dc", "dcc", "dccc", "cm" }; + const String roman_X[] = { "", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc" }; + const String roman_I[] = { "", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix" }; + s = roman_M[p_num / 1000] + roman_C[(p_num % 1000) / 100] + roman_X[(p_num % 100) / 10] + roman_I[p_num % 10]; } return s; } @@ -468,7 +468,7 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> } // Shape current paragraph. - String text; + String txt; Item *it_to = (p_line + 1 < (int)p_frame->lines.size()) ? p_frame->lines[p_line + 1].from : nullptr; int remaining_characters = visible_characters - l.char_offset; for (Item *it = l.from; it && it != it_to; it = _get_next_item(it)) { @@ -502,7 +502,7 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> font_size = font_size_it->font_size; } l.text_buf->add_string("\n", font, font_size); - text += "\n"; + txt += "\n"; l.char_count++; remaining_characters--; } break; @@ -532,13 +532,13 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> remaining_characters -= tx.length(); l.text_buf->add_string(tx, font, font_size, lang, (uint64_t)it); - text += tx; + txt += tx; l.char_count += tx.length(); } break; case ITEM_IMAGE: { ItemImage *img = static_cast<ItemImage *>(it); l.text_buf->add_object((uint64_t)it, img->size, img->inline_align, 1); - text += String::chr(0xfffc); + txt += String::chr(0xfffc); l.char_count++; remaining_characters--; } break; @@ -693,15 +693,15 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> } l.text_buf->add_object((uint64_t)it, Size2(table->total_width, table->total_height), table->inline_align, t_char_count); - text += String::chr(0xfffc).repeat(t_char_count); + txt += String::chr(0xfffc).repeat(t_char_count); } break; default: break; } } - //Apply BiDi override. - l.text_buf->set_bidi_override(structured_text_parser(_find_stt(l.from), st_args, text)); + // Apply BiDi override. + l.text_buf->set_bidi_override(structured_text_parser(_find_stt(l.from), st_args, txt)); *r_char_offset = l.char_offset + l.char_count; @@ -987,7 +987,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o font_shadow_color.a = faded_visibility; } - bool visible = (font_outline_color.a != 0) || (font_shadow_color.a != 0); + bool txt_visible = (font_outline_color.a != 0) || (font_shadow_color.a != 0); for (int j = 0; j < fx_stack.size(); j++) { ItemFX *item_fx = fx_stack[j]; @@ -1002,7 +1002,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o if (!custom_effect.is_null()) { charfx->elapsed_time = item_custom->elapsed_time; charfx->range = Vector2i(l.char_offset + glyphs[i].start, l.char_offset + glyphs[i].end); - charfx->visibility = visible; + charfx->visibility = txt_visible; charfx->outline = true; charfx->font = frid; charfx->glyph_index = gl; @@ -1018,7 +1018,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o font_color = charfx->color; frid = charfx->font; gl = charfx->glyph_index; - visible &= charfx->visibility; + txt_visible &= charfx->visibility; } } else if (item_fx->type == ITEM_SHAKE) { ItemShake *item_shake = static_cast<ItemShake *>(item_fx); @@ -1062,7 +1062,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o const Color modulated_outline_color = font_outline_color * Color(1, 1, 1, font_color.a); const Color modulated_shadow_color = font_shadow_color * Color(1, 1, 1, font_color.a); for (int j = 0; j < glyphs[i].repeat; j++) { - if (visible) { + if (txt_visible) { bool skip = (trim_chars && l.char_offset + glyphs[i].end > visible_characters) || (trim_glyphs_ltr && (processed_glyphs_ol >= visible_glyphs)) || (trim_glyphs_rtl && (processed_glyphs_ol < total_glyphs - visible_glyphs)); if (!skip && frid != RID()) { if (modulated_shadow_color.a > 0) { @@ -1205,7 +1205,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o font_color.a = faded_visibility; } - bool visible = (font_color.a != 0); + bool txt_visible = (font_color.a != 0); for (int j = 0; j < fx_stack.size(); j++) { ItemFX *item_fx = fx_stack[j]; @@ -1220,7 +1220,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o if (!custom_effect.is_null()) { charfx->elapsed_time = item_custom->elapsed_time; charfx->range = Vector2i(l.char_offset + glyphs[i].start, l.char_offset + glyphs[i].end); - charfx->visibility = visible; + charfx->visibility = txt_visible; charfx->outline = false; charfx->font = frid; charfx->glyph_index = gl; @@ -1236,7 +1236,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o font_color = charfx->color; frid = charfx->font; gl = charfx->glyph_index; - visible &= charfx->visibility; + txt_visible &= charfx->visibility; } } else if (item_fx->type == ITEM_SHAKE) { ItemShake *item_shake = static_cast<ItemShake *>(item_fx); @@ -1283,7 +1283,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o // Draw glyphs. for (int j = 0; j < glyphs[i].repeat; j++) { bool skip = (trim_chars && l.char_offset + glyphs[i].end > visible_characters) || (trim_glyphs_ltr && (r_processed_glyphs >= visible_glyphs)) || (trim_glyphs_rtl && (r_processed_glyphs < total_glyphs - visible_glyphs)); - if (visible) { + if (txt_visible) { if (!skip) { if (frid != RID()) { TS->font_draw_glyph(frid, ci, glyphs[i].font_size, p_ofs + fx_offset + off, gl, selected ? selection_fg : font_color); @@ -3609,21 +3609,21 @@ void RichTextLabel::append_text(const String &p_bbcode) { brk_pos = p_bbcode.length(); } - String text = brk_pos > pos ? p_bbcode.substr(pos, brk_pos - pos) : ""; + String txt = brk_pos > pos ? p_bbcode.substr(pos, brk_pos - pos) : ""; // Trim the first newline character, it may be added later as needed. if (after_list_close_tag || after_list_open_tag) { - text = text.trim_prefix("\n"); + txt = txt.trim_prefix("\n"); } if (brk_pos == p_bbcode.length()) { // For tags that are not properly closed. - if (text.is_empty() && after_list_open_tag) { - text = "\n"; + if (txt.is_empty() && after_list_open_tag) { + txt = "\n"; } - if (!text.is_empty()) { - add_text(text); + if (!txt.is_empty()) { + add_text(txt); } break; //nothing else to add } @@ -3632,8 +3632,8 @@ void RichTextLabel::append_text(const String &p_bbcode) { if (brk_end == -1) { //no close, add the rest - text += p_bbcode.substr(brk_pos, p_bbcode.length() - brk_pos); - add_text(text); + txt += p_bbcode.substr(brk_pos, p_bbcode.length() - brk_pos); + add_text(txt); break; } @@ -3679,36 +3679,36 @@ void RichTextLabel::append_text(const String &p_bbcode) { } if (!tag_ok) { - text += "[" + tag; - add_text(text); + txt += "[" + tag; + add_text(txt); after_list_open_tag = false; after_list_close_tag = false; pos = brk_end; continue; } - if (text.is_empty() && after_list_open_tag) { - text = "\n"; // Make empty list have at least one item. + if (txt.is_empty() && after_list_open_tag) { + txt = "\n"; // Make empty list have at least one item. } after_list_open_tag = false; if (tag == "/ol" || tag == "/ul") { - if (!text.is_empty()) { + if (!txt.is_empty()) { // Make sure text ends with a newline character, that is, the last item // will wrap at the end of block. - if (!text.ends_with("\n")) { - text += "\n"; + if (!txt.ends_with("\n")) { + txt += "\n"; } } else if (!after_list_close_tag) { - text = "\n"; // Make the innermost list item wrap at the end of lists. + txt = "\n"; // Make the innermost list item wrap at the end of lists. } after_list_close_tag = true; } else { after_list_close_tag = false; } - if (!text.is_empty()) { - add_text(text); + if (!txt.is_empty()) { + add_text(txt); } tag_stack.pop_front(); @@ -3720,15 +3720,15 @@ void RichTextLabel::append_text(const String &p_bbcode) { } if (tag == "ol" || tag.begins_with("ol ") || tag == "ul" || tag.begins_with("ul ")) { - if (text.is_empty() && after_list_open_tag) { - text = "\n"; // Make each list have at least one item at the beginning. + if (txt.is_empty() && after_list_open_tag) { + txt = "\n"; // Make each list have at least one item at the beginning. } after_list_open_tag = true; } else { after_list_open_tag = false; } - if (!text.is_empty()) { - add_text(text); + if (!txt.is_empty()) { + add_text(txt); } after_list_close_tag = false; @@ -3970,7 +3970,7 @@ void RichTextLabel::append_text(const String &p_bbcode) { HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT; Control::TextDirection dir = Control::TEXT_DIRECTION_INHERITED; String lang; - TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT; + TextServer::StructuredTextParser st_parser_type = TextServer::STRUCTURED_TEXT_DEFAULT; for (int i = 0; i < subtag.size(); i++) { Vector<String> subtag_a = subtag[i].split("="); if (subtag_a.size() == 2) { @@ -3996,24 +3996,24 @@ void RichTextLabel::append_text(const String &p_bbcode) { lang = subtag_a[1]; } else if (subtag_a[0] == "st" || subtag_a[0] == "bidi_override") { if (subtag_a[1] == "d" || subtag_a[1] == "default") { - st_parser = TextServer::STRUCTURED_TEXT_DEFAULT; + st_parser_type = TextServer::STRUCTURED_TEXT_DEFAULT; } else if (subtag_a[1] == "u" || subtag_a[1] == "uri") { - st_parser = TextServer::STRUCTURED_TEXT_URI; + st_parser_type = TextServer::STRUCTURED_TEXT_URI; } else if (subtag_a[1] == "f" || subtag_a[1] == "file") { - st_parser = TextServer::STRUCTURED_TEXT_FILE; + st_parser_type = TextServer::STRUCTURED_TEXT_FILE; } else if (subtag_a[1] == "e" || subtag_a[1] == "email") { - st_parser = TextServer::STRUCTURED_TEXT_EMAIL; + st_parser_type = TextServer::STRUCTURED_TEXT_EMAIL; } else if (subtag_a[1] == "l" || subtag_a[1] == "list") { - st_parser = TextServer::STRUCTURED_TEXT_LIST; + st_parser_type = TextServer::STRUCTURED_TEXT_LIST; } else if (subtag_a[1] == "n" || subtag_a[1] == "none") { - st_parser = TextServer::STRUCTURED_TEXT_NONE; + st_parser_type = TextServer::STRUCTURED_TEXT_NONE; } else if (subtag_a[1] == "c" || subtag_a[1] == "custom") { - st_parser = TextServer::STRUCTURED_TEXT_CUSTOM; + st_parser_type = TextServer::STRUCTURED_TEXT_CUSTOM; } } } } - push_paragraph(alignment, dir, lang, st_parser); + push_paragraph(alignment, dir, lang, st_parser_type); pos = brk_end + 1; tag_stack.push_front("p"); } else if (tag == "url") { @@ -4079,9 +4079,9 @@ void RichTextLabel::append_text(const String &p_bbcode) { end = p_bbcode.length(); } - String txt = p_bbcode.substr(brk_end + 1, end - brk_end - 1); + String dc_txt = p_bbcode.substr(brk_end + 1, end - brk_end - 1); - push_dropcap(txt, f, fs, dropcap_margins, color, outline_size, outline_color); + push_dropcap(dc_txt, f, fs, dropcap_margins, color, outline_size, outline_color); pos = end; tag_stack.push_front(bbcode_name); @@ -4668,19 +4668,19 @@ bool RichTextLabel::_search_line(ItemFrame *p_frame, int p_line, const String &p Line &l = p_frame->lines[p_line]; - String text; + String txt; Item *it_to = (p_line + 1 < (int)p_frame->lines.size()) ? p_frame->lines[p_line + 1].from : nullptr; for (Item *it = l.from; it && it != it_to; it = _get_next_item(it)) { switch (it->type) { case ITEM_NEWLINE: { - text += "\n"; + txt += "\n"; } break; case ITEM_TEXT: { ItemText *t = static_cast<ItemText *>(it); - text += t->text; + txt += t->text; } break; case ITEM_IMAGE: { - text += " "; + txt += " "; } break; case ITEM_TABLE: { ItemTable *table = static_cast<ItemTable *>(it); @@ -4696,9 +4696,9 @@ bool RichTextLabel::_search_line(ItemFrame *p_frame, int p_line, const String &p int sp = -1; if (p_reverse_search) { - sp = text.rfindn(p_string, p_char_idx); + sp = txt.rfindn(p_string, p_char_idx); } else { - sp = text.findn(p_string, p_char_idx); + sp = txt.findn(p_string, p_char_idx); } if (sp != -1) { @@ -4802,10 +4802,10 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p } String RichTextLabel::_get_line_text(ItemFrame *p_frame, int p_line, Selection p_selection) const { - String text; + String txt; - ERR_FAIL_COND_V(p_frame == nullptr, text); - ERR_FAIL_COND_V(p_line < 0 || p_line >= (int)p_frame->lines.size(), text); + ERR_FAIL_COND_V(p_frame == nullptr, txt); + ERR_FAIL_COND_V(p_line < 0 || p_line >= (int)p_frame->lines.size(), txt); Line &l = p_frame->lines[p_line]; @@ -4825,7 +4825,7 @@ String RichTextLabel::_get_line_text(ItemFrame *p_frame, int p_line, Selection p ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames. ItemFrame *frame = static_cast<ItemFrame *>(E); for (int i = 0; i < (int)frame->lines.size(); i++) { - text += _get_line_text(frame, i, p_selection); + txt += _get_line_text(frame, i, p_selection); } } } @@ -4837,23 +4837,23 @@ String RichTextLabel::_get_line_text(ItemFrame *p_frame, int p_line, Selection p } if (it->type == ITEM_DROPCAP) { const ItemDropcap *dc = static_cast<ItemDropcap *>(it); - text += dc->text; + txt += dc->text; } else if (it->type == ITEM_TEXT) { const ItemText *t = static_cast<ItemText *>(it); - text += t->text; + txt += t->text; } else if (it->type == ITEM_NEWLINE) { - text += "\n"; + txt += "\n"; } else if (it->type == ITEM_IMAGE) { - text += " "; + txt += " "; } } if ((l.from != nullptr) && (p_frame == p_selection.to_frame) && (p_selection.to_item != nullptr) && (p_selection.to_item->index >= l.from->index) && (p_selection.to_item->index < end_idx)) { - text = text.substr(0, p_selection.to_char); + txt = txt.substr(0, p_selection.to_char); } if ((l.from != nullptr) && (p_frame == p_selection.from_frame) && (p_selection.from_item != nullptr) && (p_selection.from_item->index >= l.from->index) && (p_selection.from_item->index < end_idx)) { - text = text.substr(p_selection.from_char, -1); + txt = txt.substr(p_selection.from_char, -1); } - return text; + return txt; } void RichTextLabel::set_context_menu_enabled(bool p_enabled) { @@ -4887,12 +4887,12 @@ String RichTextLabel::get_selected_text() const { return ""; } - String text; + String txt; int to_line = main->first_invalid_line.load(); for (int i = 0; i < to_line; i++) { - text += _get_line_text(main, i, selection); + txt += _get_line_text(main, i, selection); } - return text; + return txt; } void RichTextLabel::deselect() { @@ -4901,10 +4901,10 @@ void RichTextLabel::deselect() { } void RichTextLabel::selection_copy() { - String text = get_selected_text(); + String txt = get_selected_text(); - if (!text.is_empty()) { - DisplayServer::get_singleton()->clipboard_set(text); + if (!txt.is_empty()) { + DisplayServer::get_singleton()->clipboard_set(txt); } } @@ -5018,25 +5018,25 @@ bool RichTextLabel::is_using_bbcode() const { } String RichTextLabel::get_parsed_text() const { - String text = ""; + String txt = ""; Item *it = main; while (it) { if (it->type == ITEM_DROPCAP) { ItemDropcap *dc = static_cast<ItemDropcap *>(it); - text += dc->text; + txt += dc->text; } else if (it->type == ITEM_TEXT) { ItemText *t = static_cast<ItemText *>(it); - text += t->text; + txt += t->text; } else if (it->type == ITEM_NEWLINE) { - text += "\n"; + txt += "\n"; } else if (it->type == ITEM_IMAGE) { - text += " "; + txt += " "; } else if (it->type == ITEM_INDENT || it->type == ITEM_LIST) { - text += "\t"; + txt += "\t"; } it = _get_next_item(it, true); } - return text; + return txt; } void RichTextLabel::set_text_direction(Control::TextDirection p_text_direction) { diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 71123602ad..73b7676c22 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -301,14 +301,14 @@ private: _current_rng = Math::rand(); } - uint64_t offset_random(int index) { - return (_current_rng >> (index % 64)) | - (_current_rng << (64 - (index % 64))); + uint64_t offset_random(int p_index) { + return (_current_rng >> (p_index % 64)) | + (_current_rng << (64 - (p_index % 64))); } - uint64_t offset_previous_random(int index) { - return (_previous_rng >> (index % 64)) | - (_previous_rng << (64 - (index % 64))); + uint64_t offset_previous_random(int p_index) { + return (_previous_rng >> (p_index % 64)) | + (_previous_rng << (64 - (p_index % 64))); } }; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index b8973df185..f8501f3570 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -151,7 +151,7 @@ void TextEdit::Text::_calculate_line_height() { } void TextEdit::Text::_calculate_max_line_width() { - int width = 0; + int line_width = 0; for (const Line &l : text) { if (l.hidden) { continue; @@ -159,12 +159,12 @@ void TextEdit::Text::_calculate_max_line_width() { // Found another line with the same width...nothing to update. if (l.width == max_width) { - width = max_width; + line_width = max_width; break; } - width = MAX(width, l.width); + line_width = MAX(line_width, l.width); } - max_width = width; + max_width = line_width; } void TextEdit::Text::invalidate_cache(int p_line, int p_column, bool p_text_changed, const String &p_ime_text, const Array &p_bidi_override) { @@ -233,14 +233,14 @@ void TextEdit::Text::invalidate_cache(int p_line, int p_column, bool p_text_chan // Update width. const int old_width = text.write[p_line].width; - int width = get_line_width(p_line); - text.write[p_line].width = width; + int line_width = get_line_width(p_line); + text.write[p_line].width = line_width; // If this line has shrunk, this may no longer the the longest line. - if (old_width == max_width && width < max_width) { + if (old_width == max_width && line_width < max_width) { _calculate_max_line_width(); } else if (!is_hidden(p_line)) { - max_width = MAX(width, max_width); + max_width = MAX(line_width, max_width); } } @@ -698,9 +698,9 @@ void TextEdit::_notification(int p_what) { carets_wrap_index.write[i] = wrap_index; } - int first_visible_line = get_first_visible_line() - 1; + int first_vis_line = get_first_visible_line() - 1; int draw_amount = visible_rows + (smooth_scroll_enabled ? 1 : 0); - draw_amount += draw_placeholder ? placeholder_wraped_rows.size() - 1 : get_line_wrap_count(first_visible_line + 1); + draw_amount += draw_placeholder ? placeholder_wraped_rows.size() - 1 : get_line_wrap_count(first_vis_line + 1); // Draw minimap. if (draw_minimap) { @@ -711,13 +711,13 @@ void TextEdit::_notification(int p_what) { // calculate viewport size and y offset int viewport_height = (draw_amount - 1) * minimap_line_height; int control_height = _get_control_height() - viewport_height; - int viewport_offset_y = round(get_scroll_pos_for_line(first_visible_line + 1) * control_height) / ((v_scroll->get_max() <= minimap_visible_lines) ? (minimap_visible_lines - draw_amount) : (v_scroll->get_max() - draw_amount)); + int viewport_offset_y = round(get_scroll_pos_for_line(first_vis_line + 1) * control_height) / ((v_scroll->get_max() <= minimap_visible_lines) ? (minimap_visible_lines - draw_amount) : (v_scroll->get_max() - draw_amount)); // calculate the first line. int num_lines_before = round((viewport_offset_y) / minimap_line_height); - int minimap_line = (v_scroll->get_max() <= minimap_visible_lines) ? -1 : first_visible_line; + int minimap_line = (v_scroll->get_max() <= minimap_visible_lines) ? -1 : first_vis_line; if (minimap_line >= 0) { - minimap_line -= get_next_visible_line_index_offset_from(first_visible_line, 0, -num_lines_before).x; + minimap_line -= get_next_visible_line_index_offset_from(first_vis_line, 0, -num_lines_before).x; minimap_line -= (minimap_line > 0 && smooth_scroll_enabled ? 1 : 0); } int minimap_draw_amount = minimap_visible_lines + get_line_wrap_count(minimap_line + 1); @@ -885,7 +885,7 @@ void TextEdit::_notification(int p_what) { // Draw main text. line_drawing_cache.clear(); int row_height = draw_placeholder ? placeholder_line_height + line_spacing : get_line_height(); - int line = first_visible_line; + int line = first_vis_line; for (int i = 0; i < draw_amount; i++) { line++; @@ -1012,14 +1012,14 @@ void TextEdit::_notification(int p_what) { switch (gutter.type) { case GUTTER_TYPE_STRING: { - const String &text = get_line_gutter_text(line, g); - if (text.is_empty()) { + const String &txt = get_line_gutter_text(line, g); + if (txt.is_empty()) { break; } Ref<TextLine> tl; tl.instantiate(); - tl->add_string(text, font, font_size); + tl->add_string(txt, font, font_size); int yofs = ofs_y + (row_height - tl->get_size().y) / 2; if (outline_size > 0 && outline_color.a > 0) { @@ -4209,21 +4209,21 @@ int TextEdit::get_minimap_line_at_pos(const Point2i &p_pos) const { // calculate visible lines int minimap_visible_lines = get_minimap_visible_lines(); int visible_rows = get_visible_line_count() + 1; - int first_visible_line = get_first_visible_line() - 1; + int first_vis_line = get_first_visible_line() - 1; int draw_amount = visible_rows + (smooth_scroll_enabled ? 1 : 0); - draw_amount += get_line_wrap_count(first_visible_line + 1); + draw_amount += get_line_wrap_count(first_vis_line + 1); int minimap_line_height = (minimap_char_size.y + minimap_line_spacing); // calculate viewport size and y offset int viewport_height = (draw_amount - 1) * minimap_line_height; int control_height = _get_control_height() - viewport_height; - int viewport_offset_y = round(get_scroll_pos_for_line(first_visible_line + 1) * control_height) / ((v_scroll->get_max() <= minimap_visible_lines) ? (minimap_visible_lines - draw_amount) : (v_scroll->get_max() - draw_amount)); + int viewport_offset_y = round(get_scroll_pos_for_line(first_vis_line + 1) * control_height) / ((v_scroll->get_max() <= minimap_visible_lines) ? (minimap_visible_lines - draw_amount) : (v_scroll->get_max() - draw_amount)); // calculate the first line. int num_lines_before = round((viewport_offset_y) / minimap_line_height); - int minimap_line = (v_scroll->get_max() <= minimap_visible_lines) ? -1 : first_visible_line; - if (first_visible_line > 0 && minimap_line >= 0) { - minimap_line -= get_next_visible_line_index_offset_from(first_visible_line, 0, -num_lines_before).x; + int minimap_line = (v_scroll->get_max() <= minimap_visible_lines) ? -1 : first_vis_line; + if (first_vis_line > 0 && minimap_line >= 0) { + minimap_line -= get_next_visible_line_index_offset_from(first_vis_line, 0, -num_lines_before).x; minimap_line -= (minimap_line > 0 && smooth_scroll_enabled ? 1 : 0); } else { minimap_line = 0; @@ -7340,10 +7340,10 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column, int p_to_line, i idle_detect->start(); } - String text; + String txt; if (undo_enabled) { _clear_redo(); - text = _base_get_text(p_from_line, p_from_column, p_to_line, p_to_column); + txt = _base_get_text(p_from_line, p_from_column, p_to_line, p_to_column); } _base_remove_text(p_from_line, p_from_column, p_to_line, p_to_column); @@ -7359,7 +7359,7 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column, int p_to_line, i op.from_column = p_from_column; op.to_line = p_to_line; op.to_column = p_to_column; - op.text = text; + op.text = txt; op.version = ++version; op.chain_forward = false; op.chain_backward = false; @@ -7376,7 +7376,7 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column, int p_to_line, i // See if it can be merged. if (current_op.from_line == p_to_line && current_op.from_column == p_to_column) { // Backspace or similar. - current_op.text = text + current_op.text; + current_op.text = txt + current_op.text; current_op.from_line = p_from_line; current_op.from_column = p_from_column; current_op.end_carets = carets; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index db7d390b16..acf398305c 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -738,9 +738,9 @@ TreeItem *TreeItem::get_first_child() const { TreeItem *TreeItem::_get_prev_visible(bool p_wrap) { TreeItem *current = this; - TreeItem *prev = current->get_prev(); + TreeItem *prev_item = current->get_prev(); - if (!prev) { + if (!prev_item) { current = current->parent; if (current == tree->root && tree->hide_root) { return nullptr; @@ -757,7 +757,7 @@ TreeItem *TreeItem::_get_prev_visible(bool p_wrap) { } } } else { - current = prev; + current = prev_item; while (!current->collapsed && current->first_child) { //go to the very end @@ -773,16 +773,16 @@ TreeItem *TreeItem::_get_prev_visible(bool p_wrap) { TreeItem *TreeItem::get_prev_visible(bool p_wrap) { TreeItem *loop = this; - TreeItem *prev = this->_get_prev_visible(p_wrap); - while (prev && !prev->is_visible()) { - prev = prev->_get_prev_visible(p_wrap); - if (prev == loop) { + TreeItem *prev_item = this->_get_prev_visible(p_wrap); + while (prev_item && !prev_item->is_visible()) { + prev_item = prev_item->_get_prev_visible(p_wrap); + if (prev_item == loop) { // Check that we haven't looped all the way around to the start. - prev = nullptr; + prev_item = nullptr; break; } } - return prev; + return prev_item; } TreeItem *TreeItem::_get_next_visible(bool p_wrap) { @@ -814,16 +814,16 @@ TreeItem *TreeItem::_get_next_visible(bool p_wrap) { TreeItem *TreeItem::get_next_visible(bool p_wrap) { TreeItem *loop = this; - TreeItem *next = this->_get_next_visible(p_wrap); - while (next && !next->is_visible()) { - next = next->_get_next_visible(p_wrap); - if (next == loop) { + TreeItem *next_item = this->_get_next_visible(p_wrap); + while (next_item && !next_item->is_visible()) { + next_item = next_item->_get_next_visible(p_wrap); + if (next_item == loop) { // Check that we haven't looped all the way around to the start. - next = nullptr; + next_item = nullptr; break; } } - return next; + return next_item; } TreeItem *TreeItem::get_child(int p_idx) { @@ -1317,8 +1317,8 @@ bool TreeItem::is_folding_disabled() const { Size2 TreeItem::get_minimum_size(int p_column) { ERR_FAIL_INDEX_V(p_column, cells.size(), Size2()); - Tree *tree = get_tree(); - ERR_FAIL_COND_V(!tree, Size2()); + Tree *parent_tree = get_tree(); + ERR_FAIL_COND_V(!parent_tree, Size2()); const TreeItem::Cell &cell = cells[p_column]; @@ -1328,7 +1328,7 @@ Size2 TreeItem::get_minimum_size(int p_column) { // Text. if (!cell.text.is_empty()) { if (cell.dirty) { - tree->update_item_cell(this, p_column); + parent_tree->update_item_cell(this, p_column); } Size2 text_size = cell.text_buf->get_size(); size.width += text_size.width; @@ -1337,14 +1337,14 @@ Size2 TreeItem::get_minimum_size(int p_column) { // Icon. if (cell.mode == CELL_MODE_CHECK) { - size.width += tree->theme_cache.checked->get_width() + tree->theme_cache.hseparation; + size.width += parent_tree->theme_cache.checked->get_width() + parent_tree->theme_cache.hseparation; } if (cell.icon.is_valid()) { Size2i icon_size = cell.get_icon_size(); if (cell.icon_max_w > 0 && icon_size.width > cell.icon_max_w) { icon_size.width = cell.icon_max_w; } - size.width += icon_size.width + tree->theme_cache.hseparation; + size.width += icon_size.width + parent_tree->theme_cache.hseparation; size.height = MAX(size.height, icon_size.height); } @@ -1352,13 +1352,13 @@ Size2 TreeItem::get_minimum_size(int p_column) { for (int i = 0; i < cell.buttons.size(); i++) { Ref<Texture2D> texture = cell.buttons[i].texture; if (texture.is_valid()) { - Size2 button_size = texture->get_size() + tree->theme_cache.button_pressed->get_minimum_size(); + Size2 button_size = texture->get_size() + parent_tree->theme_cache.button_pressed->get_minimum_size(); size.width += button_size.width; size.height = MAX(size.height, button_size.height); } } if (cell.buttons.size() >= 2) { - size.width += (cell.buttons.size() - 1) * tree->theme_cache.button_margin; + size.width += (cell.buttons.size() - 1) * parent_tree->theme_cache.button_margin; } cells.write[p_column].cached_minimum_size = size; diff --git a/scene/main/multiplayer_api.cpp b/scene/main/multiplayer_api.cpp index 2d2103f031..7e2c82c88d 100644 --- a/scene/main/multiplayer_api.cpp +++ b/scene/main/multiplayer_api.cpp @@ -372,7 +372,7 @@ Error MultiplayerAPIExtension::rpcp(Object *p_obj, int p_peer_id, const StringNa for (int i = 0; i < p_argcount; i++) { args.push_back(*p_arg[i]); } - int ret; + int ret = FAILED; if (GDVIRTUAL_CALL(_rpc, p_peer_id, p_obj, p_method, args, ret)) { return (Error)ret; } @@ -380,7 +380,7 @@ Error MultiplayerAPIExtension::rpcp(Object *p_obj, int p_peer_id, const StringNa } int MultiplayerAPIExtension::get_remote_sender_id() { - int id; + int id = 0; if (GDVIRTUAL_CALL(_get_remote_sender_id, id)) { return id; } @@ -388,7 +388,7 @@ int MultiplayerAPIExtension::get_remote_sender_id() { } Error MultiplayerAPIExtension::object_configuration_add(Object *p_object, Variant p_config) { - int err; + int err = ERR_UNAVAILABLE; if (GDVIRTUAL_CALL(_object_configuration_add, p_object, p_config, err)) { return (Error)err; } @@ -396,7 +396,7 @@ Error MultiplayerAPIExtension::object_configuration_add(Object *p_object, Varian } Error MultiplayerAPIExtension::object_configuration_remove(Object *p_object, Variant p_config) { - int err; + int err = ERR_UNAVAILABLE; if (GDVIRTUAL_CALL(_object_configuration_remove, p_object, p_config, err)) { return (Error)err; } diff --git a/scene/main/node.cpp b/scene/main/node.cpp index bbdba16cb5..101a63db1b 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1411,14 +1411,14 @@ TypedArray<Node> Node::find_children(const String &p_pattern, const String &p_ty if (cptr[i]->is_class(p_type)) { ret.append(cptr[i]); } else if (cptr[i]->get_script_instance()) { - Ref<Script> script = cptr[i]->get_script_instance()->get_script(); - while (script.is_valid()) { - if ((ScriptServer::is_global_class(p_type) && ScriptServer::get_global_class_path(p_type) == script->get_path()) || p_type == script->get_path()) { + Ref<Script> scr = cptr[i]->get_script_instance()->get_script(); + while (scr.is_valid()) { + if ((ScriptServer::is_global_class(p_type) && ScriptServer::get_global_class_path(p_type) == scr->get_path()) || p_type == scr->get_path()) { ret.append(cptr[i]); break; } - script = script->get_base_script(); + scr = scr->get_base_script(); } } @@ -2121,9 +2121,9 @@ Node *Node::_duplicate(int p_flags, HashMap<const Node *, Node *> *r_duplimap) c if (p_flags & DUPLICATE_SCRIPTS) { bool is_valid = false; - Variant script = N->get()->get(script_property_name, &is_valid); + Variant scr = N->get()->get(script_property_name, &is_valid); if (is_valid) { - current_node->set(script_property_name, script); + current_node->set(script_property_name, scr); } } diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 3f71de1b18..af481749d5 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -105,10 +105,10 @@ bool SceneTreeTimer::is_ignore_time_scale() { } void SceneTreeTimer::release_connections() { - List<Connection> connections; - get_all_signal_connections(&connections); + List<Connection> signal_connections; + get_all_signal_connections(&signal_connections); - for (const Connection &connection : connections) { + for (const Connection &connection : signal_connections) { disconnect(connection.signal.get_name(), connection.callable); } } @@ -207,15 +207,15 @@ void SceneTree::_update_group_order(Group &g, bool p_use_priority) { return; } - Node **nodes = g.nodes.ptrw(); - int node_count = g.nodes.size(); + Node **gr_nodes = g.nodes.ptrw(); + int gr_node_count = g.nodes.size(); if (p_use_priority) { SortArray<Node *, Node::ComparatorWithPriority> node_sort; - node_sort.sort(nodes, node_count); + node_sort.sort(gr_nodes, gr_node_count); } else { SortArray<Node *, Node::Comparator> node_sort; - node_sort.sort(nodes, node_count); + node_sort.sort(gr_nodes, gr_node_count); } g.changed = false; } @@ -253,36 +253,36 @@ void SceneTree::call_group_flagsp(uint32_t p_call_flags, const StringName &p_gro _update_group_order(g); Vector<Node *> nodes_copy = g.nodes; - Node **nodes = nodes_copy.ptrw(); - int node_count = nodes_copy.size(); + Node **gr_nodes = nodes_copy.ptrw(); + int gr_node_count = nodes_copy.size(); call_lock++; if (p_call_flags & GROUP_CALL_REVERSE) { - for (int i = node_count - 1; i >= 0; i--) { - if (call_lock && call_skip.has(nodes[i])) { + for (int i = gr_node_count - 1; i >= 0; i--) { + if (call_lock && call_skip.has(gr_nodes[i])) { continue; } if (!(p_call_flags & GROUP_CALL_DEFERRED)) { Callable::CallError ce; - nodes[i]->callp(p_function, p_args, p_argcount, ce); + gr_nodes[i]->callp(p_function, p_args, p_argcount, ce); } else { - MessageQueue::get_singleton()->push_callp(nodes[i], p_function, p_args, p_argcount); + MessageQueue::get_singleton()->push_callp(gr_nodes[i], p_function, p_args, p_argcount); } } } else { - for (int i = 0; i < node_count; i++) { - if (call_lock && call_skip.has(nodes[i])) { + for (int i = 0; i < gr_node_count; i++) { + if (call_lock && call_skip.has(gr_nodes[i])) { continue; } if (!(p_call_flags & GROUP_CALL_DEFERRED)) { Callable::CallError ce; - nodes[i]->callp(p_function, p_args, p_argcount, ce); + gr_nodes[i]->callp(p_function, p_args, p_argcount, ce); } else { - MessageQueue::get_singleton()->push_callp(nodes[i], p_function, p_args, p_argcount); + MessageQueue::get_singleton()->push_callp(gr_nodes[i], p_function, p_args, p_argcount); } } } @@ -306,34 +306,34 @@ void SceneTree::notify_group_flags(uint32_t p_call_flags, const StringName &p_gr _update_group_order(g); Vector<Node *> nodes_copy = g.nodes; - Node **nodes = nodes_copy.ptrw(); - int node_count = nodes_copy.size(); + Node **gr_nodes = nodes_copy.ptrw(); + int gr_node_count = nodes_copy.size(); call_lock++; if (p_call_flags & GROUP_CALL_REVERSE) { - for (int i = node_count - 1; i >= 0; i--) { - if (call_lock && call_skip.has(nodes[i])) { + for (int i = gr_node_count - 1; i >= 0; i--) { + if (call_lock && call_skip.has(gr_nodes[i])) { continue; } if (!(p_call_flags & GROUP_CALL_DEFERRED)) { - nodes[i]->notification(p_notification); + gr_nodes[i]->notification(p_notification); } else { - MessageQueue::get_singleton()->push_notification(nodes[i], p_notification); + MessageQueue::get_singleton()->push_notification(gr_nodes[i], p_notification); } } } else { - for (int i = 0; i < node_count; i++) { - if (call_lock && call_skip.has(nodes[i])) { + for (int i = 0; i < gr_node_count; i++) { + if (call_lock && call_skip.has(gr_nodes[i])) { continue; } if (!(p_call_flags & GROUP_CALL_DEFERRED)) { - nodes[i]->notification(p_notification); + gr_nodes[i]->notification(p_notification); } else { - MessageQueue::get_singleton()->push_notification(nodes[i], p_notification); + MessageQueue::get_singleton()->push_notification(gr_nodes[i], p_notification); } } } @@ -357,34 +357,34 @@ void SceneTree::set_group_flags(uint32_t p_call_flags, const StringName &p_group _update_group_order(g); Vector<Node *> nodes_copy = g.nodes; - Node **nodes = nodes_copy.ptrw(); - int node_count = nodes_copy.size(); + Node **gr_nodes = nodes_copy.ptrw(); + int gr_node_count = nodes_copy.size(); call_lock++; if (p_call_flags & GROUP_CALL_REVERSE) { - for (int i = node_count - 1; i >= 0; i--) { - if (call_lock && call_skip.has(nodes[i])) { + for (int i = gr_node_count - 1; i >= 0; i--) { + if (call_lock && call_skip.has(gr_nodes[i])) { continue; } if (!(p_call_flags & GROUP_CALL_DEFERRED)) { - nodes[i]->set(p_name, p_value); + gr_nodes[i]->set(p_name, p_value); } else { - MessageQueue::get_singleton()->push_set(nodes[i], p_name, p_value); + MessageQueue::get_singleton()->push_set(gr_nodes[i], p_name, p_value); } } } else { - for (int i = 0; i < node_count; i++) { - if (call_lock && call_skip.has(nodes[i])) { + for (int i = 0; i < gr_node_count; i++) { + if (call_lock && call_skip.has(gr_nodes[i])) { continue; } if (!(p_call_flags & GROUP_CALL_DEFERRED)) { - nodes[i]->set(p_name, p_value); + gr_nodes[i]->set(p_name, p_value); } else { - MessageQueue::get_singleton()->push_set(nodes[i], p_name, p_value); + MessageQueue::get_singleton()->push_set(gr_nodes[i], p_name, p_value); } } } @@ -846,13 +846,13 @@ void SceneTree::_notify_group_pause(const StringName &p_group, int p_notificatio //performance is not lost because only if something is added/removed the vector is copied. Vector<Node *> nodes_copy = g.nodes; - int node_count = nodes_copy.size(); - Node **nodes = nodes_copy.ptrw(); + int gr_node_count = nodes_copy.size(); + Node **gr_nodes = nodes_copy.ptrw(); call_lock++; - for (int i = 0; i < node_count; i++) { - Node *n = nodes[i]; + for (int i = 0; i < gr_node_count; i++) { + Node *n = gr_nodes[i]; if (call_lock && call_skip.has(n)) { continue; } @@ -865,7 +865,7 @@ void SceneTree::_notify_group_pause(const StringName &p_group, int p_notificatio } n->notification(p_notification); - //ERR_FAIL_COND(node_count != g.nodes.size()); + //ERR_FAIL_COND(gr_node_count != g.nodes.size()); } call_lock--; @@ -890,17 +890,17 @@ void SceneTree::_call_input_pause(const StringName &p_group, CallInputType p_cal //performance is not lost because only if something is added/removed the vector is copied. Vector<Node *> nodes_copy = g.nodes; - int node_count = nodes_copy.size(); - Node **nodes = nodes_copy.ptrw(); + int gr_node_count = nodes_copy.size(); + Node **gr_nodes = nodes_copy.ptrw(); call_lock++; - for (int i = node_count - 1; i >= 0; i--) { + for (int i = gr_node_count - 1; i >= 0; i--) { if (p_viewport->is_input_handled()) { break; } - Node *n = nodes[i]; + Node *n = gr_nodes[i]; if (call_lock && call_skip.has(n)) { continue; } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 234cebd821..f7a515dc1d 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -60,8 +60,8 @@ #include "servers/rendering/rendering_server_globals.h" void ViewportTexture::setup_local_to_scene() { - Node *local_scene = get_local_scene(); - if (!local_scene) { + Node *loc_scene = get_local_scene(); + if (!loc_scene) { return; } @@ -71,7 +71,7 @@ void ViewportTexture::setup_local_to_scene() { vp = nullptr; - Node *vpn = local_scene->get_node(path); + Node *vpn = loc_scene->get_node(path); ERR_FAIL_COND_MSG(!vpn, "ViewportTexture: Path to node is invalid."); vp = Object::cast_to<Viewport>(vpn); @@ -635,19 +635,19 @@ void Viewport::_process_picking() { PhysicsDirectSpaceState2D::ShapeResult res[64]; for (const CanvasLayer *E : canvas_layers) { - Transform2D canvas_transform; + Transform2D canvas_layer_transform; ObjectID canvas_layer_id; if (E) { // A descendant CanvasLayer. - canvas_transform = E->get_transform(); + canvas_layer_transform = E->get_transform(); canvas_layer_id = E->get_instance_id(); } else { // This Viewport's builtin canvas. - canvas_transform = get_canvas_transform(); + canvas_layer_transform = get_canvas_transform(); canvas_layer_id = ObjectID(); } - Vector2 point = canvas_transform.affine_inverse().xform(pos); + Vector2 point = canvas_layer_transform.affine_inverse().xform(pos); PhysicsDirectSpaceState2D::PointParameters point_params; point_params.position = point; @@ -4054,16 +4054,10 @@ Viewport::Viewport() { ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/tooltip_delay_sec", PropertyInfo(Variant::FLOAT, "gui/timers/tooltip_delay_sec", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater")); // No negative numbers #ifndef _3D_DISABLED - Viewport::Scaling3DMode scaling_3d_mode = (Viewport::Scaling3DMode)(int)GLOBAL_GET("rendering/scaling_3d/mode"); - set_scaling_3d_mode(scaling_3d_mode); - + set_scaling_3d_mode((Viewport::Scaling3DMode)(int)GLOBAL_GET("rendering/scaling_3d/mode")); set_scaling_3d_scale(GLOBAL_GET("rendering/scaling_3d/scale")); - - float fsr_sharpness = GLOBAL_GET("rendering/scaling_3d/fsr_sharpness"); - set_fsr_sharpness(fsr_sharpness); - - float texture_mipmap_bias = GLOBAL_GET("rendering/textures/default_filters/texture_mipmap_bias"); - set_texture_mipmap_bias(texture_mipmap_bias); + set_fsr_sharpness((float)GLOBAL_GET("rendering/scaling_3d/fsr_sharpness")); + set_texture_mipmap_bias((float)GLOBAL_GET("rendering/textures/default_filters/texture_mipmap_bias")); #endif // _3D_DISABLED set_sdf_oversize(sdf_oversize); // Set to server. diff --git a/scene/main/window.cpp b/scene/main/window.cpp index f7099f3765..7fb3f32d36 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -666,7 +666,7 @@ void Window::_update_viewport_size() { Size2i final_size; Size2i final_size_override; Rect2i attach_to_screen_rect(Point2i(), size); - Transform2D stretch_transform; + Transform2D stretch_transform_new; float font_oversampling = 1.0; if (content_scale_mode == CONTENT_SCALE_MODE_DISABLED || content_scale_size.x == 0 || content_scale_size.y == 0) { @@ -674,8 +674,8 @@ void Window::_update_viewport_size() { final_size = size; final_size_override = Size2(size) / content_scale_factor; - stretch_transform = Transform2D(); - stretch_transform.scale(Size2(content_scale_factor, content_scale_factor)); + stretch_transform_new = Transform2D(); + stretch_transform_new.scale(Size2(content_scale_factor, content_scale_factor)); } else { //actual screen video mode Size2 video_mode = size; @@ -752,7 +752,7 @@ void Window::_update_viewport_size() { font_oversampling = (screen_size.x / viewport_size.x) * content_scale_factor; Size2 scale = Vector2(screen_size) / Vector2(final_size_override); - stretch_transform.scale(scale); + stretch_transform_new.scale(scale); } break; case CONTENT_SCALE_MODE_VIEWPORT: { @@ -764,7 +764,7 @@ void Window::_update_viewport_size() { } bool allocate = is_inside_tree() && visible && (window_id != DisplayServer::INVALID_WINDOW_ID || embedder != nullptr); - _set_size(final_size, final_size_override, attach_to_screen_rect, stretch_transform, allocate); + _set_size(final_size, final_size_override, attach_to_screen_rect, stretch_transform_new, allocate); if (window_id != DisplayServer::INVALID_WINDOW_ID) { RenderingServer::get_singleton()->viewport_attach_to_screen(get_viewport_rid(), attach_to_screen_rect, window_id); @@ -1298,17 +1298,17 @@ bool Window::has_focus() const { Rect2i Window::get_usable_parent_rect() const { ERR_FAIL_COND_V(!is_inside_tree(), Rect2()); - Rect2i parent; + Rect2i parent_rect; if (is_embedded()) { - parent = _get_embedder()->get_visible_rect(); + parent_rect = _get_embedder()->get_visible_rect(); } else { const Window *w = is_visible() ? this : get_parent_visible_window(); //find a parent that can contain us ERR_FAIL_COND_V(!w, Rect2()); - parent = DisplayServer::get_singleton()->screen_get_usable_rect(DisplayServer::get_singleton()->window_get_current_screen(w->get_window_id())); + parent_rect = DisplayServer::get_singleton()->screen_get_usable_rect(DisplayServer::get_singleton()->window_get_current_screen(w->get_window_id())); } - return parent; + return parent_rect; } void Window::add_child_notify(Node *p_child) { @@ -1576,9 +1576,9 @@ Window::LayoutDirection Window::get_layout_direction() const { bool Window::is_layout_rtl() const { if (layout_dir == LAYOUT_DIRECTION_INHERITED) { - Window *parent = Object::cast_to<Window>(get_parent()); - if (parent) { - return parent->is_layout_rtl(); + Window *parent_w = Object::cast_to<Window>(get_parent()); + if (parent_w) { + return parent_w->is_layout_rtl(); } else { if (GLOBAL_GET(SNAME("internationalization/rendering/force_right_to_left_layout_direction"))) { return true; diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index f2ac1c2e58..2bcf569f4e 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -35,7 +35,7 @@ #include "scene/scene_string_names.h" bool Animation::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; + String prop_name = p_name; if (p_name == SNAME("_compression")) { ERR_FAIL_COND_V(tracks.size() > 0, false); //can only set compression if no tracks exist @@ -63,9 +63,9 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) { } compression.enabled = true; return true; - } else if (name.begins_with("tracks/")) { - int track = name.get_slicec('/', 1).to_int(); - String what = name.get_slicec('/', 2); + } else if (prop_name.begins_with("tracks/")) { + int track = prop_name.get_slicec('/', 1).to_int(); + String what = prop_name.get_slicec('/', 2); if (tracks.size() == track && what == "type") { String type = p_value; @@ -431,7 +431,7 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) { } bool Animation::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; + String prop_name = p_name; if (p_name == SNAME("_compression")) { ERR_FAIL_COND_V(!compression.enabled, false); @@ -456,15 +456,15 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const { r_ret = comp; return true; - } else if (name == "length") { + } else if (prop_name == "length") { r_ret = length; - } else if (name == "loop_mode") { + } else if (prop_name == "loop_mode") { r_ret = loop_mode; - } else if (name == "step") { + } else if (prop_name == "step") { r_ret = step; - } else if (name.begins_with("tracks/")) { - int track = name.get_slicec('/', 1).to_int(); - String what = name.get_slicec('/', 2); + } else if (prop_name.begins_with("tracks/")) { + int track = prop_name.get_slicec('/', 1).to_int(); + String what = prop_name.get_slicec('/', 2); ERR_FAIL_INDEX_V(track, tracks.size(), false); if (what == "type") { switch (track_get_type(track)) { diff --git a/scene/resources/audio_stream_wav.cpp b/scene/resources/audio_stream_wav.cpp index 26204583ef..ce68936370 100644 --- a/scene/resources/audio_stream_wav.cpp +++ b/scene/resources/audio_stream_wav.cpp @@ -580,8 +580,8 @@ Error AudioStreamWAV::save_to_wav(const String &p_path) { file->store_32(sub_chunk_2_size); //Subchunk2Size // Add data - Vector<uint8_t> data = get_data(); - const uint8_t *read_data = data.ptr(); + Vector<uint8_t> stream_data = get_data(); + const uint8_t *read_data = stream_data.ptr(); switch (format) { case AudioStreamWAV::FORMAT_8_BITS: for (unsigned int i = 0; i < data_bytes; i++) { diff --git a/scene/resources/capsule_shape_3d.cpp b/scene/resources/capsule_shape_3d.cpp index b0454004a0..f7ed8d98cb 100644 --- a/scene/resources/capsule_shape_3d.cpp +++ b/scene/resources/capsule_shape_3d.cpp @@ -33,17 +33,17 @@ #include "servers/physics_server_3d.h" Vector<Vector3> CapsuleShape3D::get_debug_mesh_lines() const { - float radius = get_radius(); - float height = get_height(); + float c_radius = get_radius(); + float c_height = get_height(); Vector<Vector3> points; - Vector3 d(0, height * 0.5 - radius, 0); + Vector3 d(0, c_height * 0.5 - c_radius, 0); for (int i = 0; i < 360; i++) { float ra = Math::deg_to_rad((float)i); float rb = Math::deg_to_rad((float)i + 1); - Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius; - Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius; + Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * c_radius; + Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * c_radius; points.push_back(Vector3(a.x, 0, a.y) + d); points.push_back(Vector3(b.x, 0, b.y) + d); diff --git a/scene/resources/convex_polygon_shape_3d.cpp b/scene/resources/convex_polygon_shape_3d.cpp index e7960f1ba4..4eaae111a1 100644 --- a/scene/resources/convex_polygon_shape_3d.cpp +++ b/scene/resources/convex_polygon_shape_3d.cpp @@ -33,10 +33,10 @@ #include "servers/physics_server_3d.h" Vector<Vector3> ConvexPolygonShape3D::get_debug_mesh_lines() const { - Vector<Vector3> points = get_points(); + Vector<Vector3> poly_points = get_points(); - if (points.size() > 3) { - Vector<Vector3> varr = Variant(points); + if (poly_points.size() > 3) { + Vector<Vector3> varr = Variant(poly_points); Geometry3D::MeshData md; Error err = ConvexHullComputer::convex_hull(varr, md); if (err == OK) { diff --git a/scene/resources/cylinder_shape_3d.cpp b/scene/resources/cylinder_shape_3d.cpp index a5951db8ea..e5f417cbcc 100644 --- a/scene/resources/cylinder_shape_3d.cpp +++ b/scene/resources/cylinder_shape_3d.cpp @@ -33,17 +33,17 @@ #include "servers/physics_server_3d.h" Vector<Vector3> CylinderShape3D::get_debug_mesh_lines() const { - float radius = get_radius(); - float height = get_height(); + float c_radius = get_radius(); + float c_height = get_height(); Vector<Vector3> points; - Vector3 d(0, height * 0.5, 0); + Vector3 d(0, c_height * 0.5, 0); for (int i = 0; i < 360; i++) { float ra = Math::deg_to_rad((float)i); float rb = Math::deg_to_rad((float)i + 1); - Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius; - Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius; + Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * c_radius; + Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * c_radius; points.push_back(Vector3(a.x, 0, a.y) + d); points.push_back(Vector3(b.x, 0, b.y) + d); diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 6a278f1f39..cbecab62b3 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -1065,12 +1065,12 @@ bool FontFile::_set(const StringName &p_name, const Variant &p_value) { } int chars = len / 9; for (int i = 0; i < chars; i++) { - const int32_t *data = &arr[i * 9]; - char32_t c = data[0]; - set_glyph_texture_idx(0, Vector2i(16, 0), c, data[1]); - set_glyph_uv_rect(0, Vector2i(16, 0), c, Rect2(data[2], data[3], data[4], data[5])); - set_glyph_offset(0, Vector2i(16, 0), c, Size2(data[6], data[7])); - set_glyph_advance(0, 16, c, Vector2(data[8], 0)); + const int32_t *char_data = &arr[i * 9]; + char32_t c = char_data[0]; + set_glyph_texture_idx(0, Vector2i(16, 0), c, char_data[1]); + set_glyph_uv_rect(0, Vector2i(16, 0), c, Rect2(char_data[2], char_data[3], char_data[4], char_data[5])); + set_glyph_offset(0, Vector2i(16, 0), c, Size2(char_data[6], char_data[7])); + set_glyph_advance(0, 16, c, Vector2(char_data[8], 0)); } } else if (tokens.size() == 1 && tokens[0] == "kernings") { // Compatibility, BitmapFont. @@ -1082,8 +1082,8 @@ bool FontFile::_set(const StringName &p_name, const Variant &p_value) { return false; } for (int i = 0; i < len / 3; i++) { - const int32_t *data = &arr[i * 3]; - set_kerning(0, 16, Vector2i(data[0], data[1]), Vector2(data[2], 0)); + const int32_t *kern_data = &arr[i * 3]; + set_kerning(0, 16, Vector2i(kern_data[0], kern_data[1]), Vector2(kern_data[2], 0)); } } else if (tokens.size() == 1 && tokens[0] == "height") { // Compatibility, BitmapFont. @@ -1108,12 +1108,12 @@ bool FontFile::_set(const StringName &p_name, const Variant &p_value) { #endif // DISABLE_DEPRECATED if (tokens.size() == 2 && tokens[0] == "language_support_override") { - String lang = tokens[1]; - set_language_support_override(lang, p_value); + String lang_code = tokens[1]; + set_language_support_override(lang_code, p_value); return true; } else if (tokens.size() == 2 && tokens[0] == "script_support_override") { - String script = tokens[1]; - set_script_support_override(script, p_value); + String script_code = tokens[1]; + set_script_support_override(script_code, p_value); return true; } else if (tokens.size() >= 3 && tokens[0] == "cache") { int cache_index = tokens[1].to_int(); @@ -1187,12 +1187,12 @@ bool FontFile::_set(const StringName &p_name, const Variant &p_value) { bool FontFile::_get(const StringName &p_name, Variant &r_ret) const { Vector<String> tokens = p_name.operator String().split("/"); if (tokens.size() == 2 && tokens[0] == "language_support_override") { - String lang = tokens[1]; - r_ret = get_language_support_override(lang); + String lang_code = tokens[1]; + r_ret = get_language_support_override(lang_code); return true; } else if (tokens.size() == 2 && tokens[0] == "script_support_override") { - String script = tokens[1]; - r_ret = get_script_support_override(script); + String script_code = tokens[1]; + r_ret = get_script_support_override(script_code); return true; } else if (tokens.size() >= 3 && tokens[0] == "cache") { int cache_index = tokens[1].to_int(); @@ -1813,8 +1813,8 @@ Error FontFile::load_bitmap_font(const String &p_path) { Error FontFile::load_dynamic_font(const String &p_path) { reset_state(); - Vector<uint8_t> data = FileAccess::get_file_as_array(p_path); - set_data(data); + Vector<uint8_t> font_data = FileAccess::get_file_as_array(p_path); + set_data(font_data); return OK; } diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp index de3d502102..b728c24e0d 100644 --- a/scene/resources/importer_mesh.cpp +++ b/scene/resources/importer_mesh.cpp @@ -829,9 +829,9 @@ void ImporterMesh::_set_data(const Dictionary &p_data) { ERR_CONTINUE(prim >= Mesh::PRIMITIVE_MAX); Array arr = s["arrays"]; Dictionary lods; - String name; + String surf_name; if (s.has("name")) { - name = s["name"]; + surf_name = s["name"]; } if (s.has("lods")) { lods = s["lods"]; @@ -848,7 +848,7 @@ void ImporterMesh::_set_data(const Dictionary &p_data) { if (s.has("flags")) { flags = s["flags"]; } - add_surface(prim, arr, b_shapes, lods, material, name, flags); + add_surface(prim, arr, b_shapes, lods, material, surf_name, flags); } } } diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index b42e65c8df..03ccae5b74 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -313,11 +313,11 @@ Ref<TriangleMesh> Mesh::generate_surface_triangle_mesh(int p_surface) const { } } - Ref<TriangleMesh> triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh)); - triangle_mesh->create(faces); - surface_triangle_meshes.set(p_surface, triangle_mesh); + Ref<TriangleMesh> tr_mesh = Ref<TriangleMesh>(memnew(TriangleMesh)); + tr_mesh->create(faces); + surface_triangle_meshes.set(p_surface, tr_mesh); - return triangle_mesh; + return tr_mesh; } void Mesh::generate_debug_mesh_lines(Vector<Vector3> &r_lines) { @@ -1251,7 +1251,7 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { index_count = d["index_count"]; } - Vector<uint8_t> blend_shapes; + Vector<uint8_t> blend_shapes_new; if (d.has("blend_shape_data")) { Array blend_shape_data = d["blend_shape_data"]; @@ -1263,7 +1263,7 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { Vector<uint8_t> shape = blend_shape_data[i]; _fix_array_compatibility(shape, old_format, new_format, vertex_count, blend_vertex_array, blend_attribute_array, blend_skin_array); - blend_shapes.append_array(blend_vertex_array); + blend_shapes_new.append_array(blend_vertex_array); } } @@ -1273,7 +1273,7 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { print_verbose("Mesh format post-conversion: " + itos(new_format)); ERR_FAIL_COND_V(!d.has("aabb"), false); - AABB aabb = d["aabb"]; + AABB aabb_new = d["aabb"]; Vector<AABB> bone_aabb; if (d.has("skeleton_aabb")) { @@ -1285,7 +1285,7 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { } } - add_surface(new_format, PrimitiveType(primitive), vertex_array, attribute_array, skin_array, vertex_count, array_index_data, index_count, aabb, blend_shapes, bone_aabb); + add_surface(new_format, PrimitiveType(primitive), vertex_array, attribute_array, skin_array, vertex_count, array_index_data, index_count, aabb_new, blend_shapes_new, bone_aabb); } else { ERR_FAIL_V(false); @@ -1462,9 +1462,9 @@ void ArrayMesh::_set_surfaces(const Array &p_surfaces) { } } - String name; + String surf_name; if (d.has("name")) { - name = d["name"]; + surf_name = d["name"]; } bool _2d = false; @@ -1474,7 +1474,7 @@ void ArrayMesh::_set_surfaces(const Array &p_surfaces) { surface_data.push_back(surface); surface_materials.push_back(material); - surface_names.push_back(name); + surface_names.push_back(surf_name); surface_2d.push_back(_2d); } @@ -1657,17 +1657,17 @@ int ArrayMesh::get_surface_count() const { void ArrayMesh::add_blend_shape(const StringName &p_name) { ERR_FAIL_COND_MSG(surfaces.size(), "Can't add a shape key count if surfaces are already created."); - StringName name = p_name; + StringName shape_name = p_name; - if (blend_shapes.has(name)) { + if (blend_shapes.has(shape_name)) { int count = 2; do { - name = String(p_name) + " " + itos(count); + shape_name = String(p_name) + " " + itos(count); count++; - } while (blend_shapes.has(name)); + } while (blend_shapes.has(shape_name)); } - blend_shapes.push_back(name); + blend_shapes.push_back(shape_name); if (mesh.is_valid()) { RS::get_singleton()->mesh_set_blend_shape_count(mesh, blend_shapes.size()); @@ -1686,17 +1686,17 @@ StringName ArrayMesh::get_blend_shape_name(int p_index) const { void ArrayMesh::set_blend_shape_name(int p_index, const StringName &p_name) { ERR_FAIL_INDEX(p_index, blend_shapes.size()); - StringName name = p_name; - int found = blend_shapes.find(name); + StringName shape_name = p_name; + int found = blend_shapes.find(shape_name); if (found != -1 && found != p_index) { int count = 2; do { - name = String(p_name) + " " + itos(count); + shape_name = String(p_name) + " " + itos(count); count++; - } while (blend_shapes.find(name) != -1); + } while (blend_shapes.find(shape_name) != -1); } - blend_shapes.write[p_index] = name; + blend_shapes.write[p_index] = shape_name; } void ArrayMesh::clear_blend_shapes() { diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp index 2d3f9d9afc..7c78b757c7 100644 --- a/scene/resources/mesh_library.cpp +++ b/scene/resources/mesh_library.cpp @@ -33,10 +33,10 @@ #include "box_shape_3d.h" bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; - if (name.begins_with("item/")) { - int idx = name.get_slicec('/', 1).to_int(); - String what = name.get_slicec('/', 2); + String prop_name = p_name; + if (prop_name.begins_with("item/")) { + int idx = prop_name.get_slicec('/', 1).to_int(); + String what = prop_name.get_slicec('/', 2); if (!item_map.has(idx)) { create_item(idx); } @@ -72,10 +72,10 @@ bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) { } bool MeshLibrary::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; - int idx = name.get_slicec('/', 1).to_int(); + String prop_name = p_name; + int idx = prop_name.get_slicec('/', 1).to_int(); ERR_FAIL_COND_V(!item_map.has(idx), false); - String what = name.get_slicec('/', 2); + String what = prop_name.get_slicec('/', 2); if (what == "name") { r_ret = get_item_name(idx); @@ -100,14 +100,14 @@ bool MeshLibrary::_get(const StringName &p_name, Variant &r_ret) const { void MeshLibrary::_get_property_list(List<PropertyInfo> *p_list) const { for (const KeyValue<int, Item> &E : item_map) { - String name = vformat("%s/%d/", PNAME("item"), E.key); - p_list->push_back(PropertyInfo(Variant::STRING, name + PNAME("name"))); - p_list->push_back(PropertyInfo(Variant::OBJECT, name + PNAME("mesh"), PROPERTY_HINT_RESOURCE_TYPE, "Mesh")); - p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, name + PNAME("mesh_transform"), PROPERTY_HINT_NONE, "suffix:m")); - p_list->push_back(PropertyInfo(Variant::ARRAY, name + PNAME("shapes"))); - p_list->push_back(PropertyInfo(Variant::OBJECT, name + PNAME("navmesh"), PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh")); - p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, name + PNAME("navmesh_transform"), PROPERTY_HINT_NONE, "suffix:m")); - p_list->push_back(PropertyInfo(Variant::OBJECT, name + PNAME("preview"), PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT)); + String prop_name = vformat("%s/%d/", PNAME("item"), E.key); + p_list->push_back(PropertyInfo(Variant::STRING, prop_name + PNAME("name"))); + p_list->push_back(PropertyInfo(Variant::OBJECT, prop_name + PNAME("mesh"), PROPERTY_HINT_RESOURCE_TYPE, "Mesh")); + p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, prop_name + PNAME("mesh_transform"), PROPERTY_HINT_NONE, "suffix:m")); + p_list->push_back(PropertyInfo(Variant::ARRAY, prop_name + PNAME("shapes"))); + p_list->push_back(PropertyInfo(Variant::OBJECT, prop_name + PNAME("navmesh"), PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh")); + p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, prop_name + PNAME("navmesh_transform"), PROPERTY_HINT_NONE, "suffix:m")); + p_list->push_back(PropertyInfo(Variant::OBJECT, prop_name + PNAME("preview"), PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT)); } } diff --git a/scene/resources/navigation_mesh.cpp b/scene/resources/navigation_mesh.cpp index 90ea879012..a93e70ecd4 100644 --- a/scene/resources/navigation_mesh.cpp +++ b/scene/resources/navigation_mesh.cpp @@ -590,16 +590,16 @@ void NavigationMesh::_validate_property(PropertyInfo &p_property) const { #ifndef DISABLE_DEPRECATED bool NavigationMesh::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; - if (name.find("/") != -1) { + String prop_name = p_name; + if (prop_name.find("/") != -1) { // Compatibility with pre-3.5 "category/path" property names. - name = name.replace("/", "_"); - if (name == "sample_partition_type_sample_partition_type") { + prop_name = prop_name.replace("/", "_"); + if (prop_name == "sample_partition_type_sample_partition_type") { set("sample_partition_type", p_value); - } else if (name == "filter_filter_walkable_low_height_spans") { + } else if (prop_name == "filter_filter_walkable_low_height_spans") { set("filter_walkable_low_height_spans", p_value); } else { - set(name, p_value); + set(prop_name, p_value); } return true; @@ -608,16 +608,16 @@ bool NavigationMesh::_set(const StringName &p_name, const Variant &p_value) { } bool NavigationMesh::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; - if (name.find("/") != -1) { + String prop_name = p_name; + if (prop_name.find("/") != -1) { // Compatibility with pre-3.5 "category/path" property names. - name = name.replace("/", "_"); - if (name == "sample_partition_type_sample_partition_type") { + prop_name = prop_name.replace("/", "_"); + if (prop_name == "sample_partition_type_sample_partition_type") { r_ret = get("sample_partition_type"); - } else if (name == "filter_filter_walkable_low_height_spans") { + } else if (prop_name == "filter_filter_walkable_low_height_spans") { r_ret = get("filter_walkable_low_height_spans"); } else { - r_ret = get(name); + r_ret = get(prop_name); } return true; } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index e0bedad595..1f71d583b1 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -150,15 +150,15 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const { } else if (n.instance >= 0) { //instance a scene into this node if (n.instance & FLAG_INSTANCE_IS_PLACEHOLDER) { - String path = props[n.instance & FLAG_MASK]; + String scene_path = props[n.instance & FLAG_MASK]; if (disable_placeholders) { - Ref<PackedScene> sdata = ResourceLoader::load(path, "PackedScene"); + Ref<PackedScene> sdata = ResourceLoader::load(scene_path, "PackedScene"); ERR_FAIL_COND_V(!sdata.is_valid(), nullptr); node = sdata->instantiate(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE); ERR_FAIL_COND_V(!node, nullptr); } else { InstancePlaceholder *ip = memnew(InstancePlaceholder); - ip->set_instance_path(path); + ip->set_instance_path(scene_path); node = ip; } node->set_scene_instance_load_placeholder(true); @@ -938,8 +938,8 @@ Error SceneState::pack(Node *p_scene) { // If using scene inheritance, pack the scene it inherits from. if (scene->get_scene_inherited_state().is_valid()) { - String path = scene->get_scene_inherited_state()->get_path(); - Ref<PackedScene> instance = ResourceLoader::load(path); + String scene_path = scene->get_scene_inherited_state()->get_path(); + Ref<PackedScene> instance = ResourceLoader::load(scene_path); if (instance.is_valid()) { base_scene_idx = _vm_get_variant(instance, variant_map); } diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp index 5e18671c11..2c80e234e9 100644 --- a/scene/resources/polygon_path_finder.cpp +++ b/scene/resources/polygon_path_finder.cpp @@ -441,9 +441,9 @@ Dictionary PolygonPathFinder::_get_data() const { Dictionary d; Vector<Vector2> p; Vector<int> ind; - Array connections; + Array path_connections; p.resize(MAX(0, points.size() - 2)); - connections.resize(MAX(0, points.size() - 2)); + path_connections.resize(MAX(0, points.size() - 2)); ind.resize(edges.size() * 2); Vector<real_t> penalties; penalties.resize(MAX(0, points.size() - 2)); @@ -463,7 +463,7 @@ Dictionary PolygonPathFinder::_get_data() const { cw[idx++] = E; } } - connections[i] = c; + path_connections[i] = c; } } { @@ -478,7 +478,7 @@ Dictionary PolygonPathFinder::_get_data() const { d["bounds"] = bounds; d["points"] = p; d["penalties"] = penalties; - d["connections"] = connections; + d["connections"] = path_connections; d["segments"] = ind; return d; diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index c017c90370..67d4b14b04 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -2443,17 +2443,17 @@ void TextMesh::_create_mesh_array(Array &p_arr) const { TS->shaped_text_clear(text_rid); TS->shaped_text_set_direction(text_rid, text_direction); - String text = (uppercase) ? TS->string_to_upper(xl_text, language) : xl_text; - TS->shaped_text_add_string(text_rid, text, font->get_rids(), font_size, font->get_opentype_features(), language); + String txt = (uppercase) ? TS->string_to_upper(xl_text, language) : xl_text; + TS->shaped_text_add_string(text_rid, txt, font->get_rids(), font_size, font->get_opentype_features(), language); for (int i = 0; i < TextServer::SPACING_MAX; i++) { TS->shaped_text_set_spacing(text_rid, TextServer::SpacingType(i), font->get_spacing(TextServer::SpacingType(i))); } Array stt; if (st_parser == TextServer::STRUCTURED_TEXT_CUSTOM) { - GDVIRTUAL_CALL(_structured_text_parser, st_args, text, stt); + GDVIRTUAL_CALL(_structured_text_parser, st_args, txt, stt); } else { - stt = TS->parse_structured_text(st_parser, st_args, text); + stt = TS->parse_structured_text(st_parser, st_args, txt); } TS->shaped_text_set_bidi_override(text_rid, stt); diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 0d798d2e27..c0d65fb445 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1114,10 +1114,10 @@ Error ResourceLoaderText::save_as_binary(const String &p_path) { //go with external resources DummyReadData dummy_read; - VariantParser::ResourceParser rp; - rp.ext_func = _parse_ext_resource_dummys; - rp.sub_func = _parse_sub_resource_dummys; - rp.userdata = &dummy_read; + VariantParser::ResourceParser rp_new; + rp_new.ext_func = _parse_ext_resource_dummys; + rp_new.sub_func = _parse_sub_resource_dummys; + rp_new.userdata = &dummy_read; while (next_tag.name == "ext_resource") { if (!next_tag.fields.has("path")) { @@ -1161,7 +1161,7 @@ Error ResourceLoaderText::save_as_binary(const String &p_path) { dummy_read.external_resources[dr] = lindex; dummy_read.rev_external_resources[id] = dr; - error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp); + error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp_new); if (error) { _printerr(); @@ -1244,7 +1244,7 @@ Error ResourceLoaderText::save_as_binary(const String &p_path) { String assign; Variant value; - error = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp); + error = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp_new); if (error) { if (main_res && error == ERR_FILE_EOF) { @@ -1288,7 +1288,7 @@ Error ResourceLoaderText::save_as_binary(const String &p_path) { return error; } - Ref<PackedScene> packed_scene = _parse_node_tag(rp); + Ref<PackedScene> packed_scene = _parse_node_tag(rp_new); if (!packed_scene.is_valid()) { return error; @@ -1363,13 +1363,13 @@ Error ResourceLoaderText::get_classes_used(HashSet<StringName> *r_classes) { DummyReadData dummy_read; dummy_read.no_placeholders = true; - VariantParser::ResourceParser rp; - rp.ext_func = _parse_ext_resource_dummys; - rp.sub_func = _parse_sub_resource_dummys; - rp.userdata = &dummy_read; + VariantParser::ResourceParser rp_new; + rp_new.ext_func = _parse_ext_resource_dummys; + rp_new.sub_func = _parse_sub_resource_dummys; + rp_new.userdata = &dummy_read; while (next_tag.name == "ext_resource") { - error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp); + error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp_new); if (error) { _printerr(); @@ -1396,7 +1396,7 @@ Error ResourceLoaderText::get_classes_used(HashSet<StringName> *r_classes) { String assign; Variant value; - error = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp); + error = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp_new); if (error) { if (error == ERR_FILE_EOF) { @@ -1444,7 +1444,7 @@ Error ResourceLoaderText::get_classes_used(HashSet<StringName> *r_classes) { String assign; Variant value; - error = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp); + error = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp_new); if (error) { if (error == ERR_FILE_MISSING_DEPENDENCIES) { diff --git a/scene/resources/skin.cpp b/scene/resources/skin.cpp index 1c04ba0cd4..9d320e0b2c 100644 --- a/scene/resources/skin.cpp +++ b/scene/resources/skin.cpp @@ -86,13 +86,13 @@ void Skin::reset_state() { } bool Skin::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; - if (name == "bind_count") { + String prop_name = p_name; + if (prop_name == "bind_count") { set_bind_count(p_value); return true; - } else if (name.begins_with("bind/")) { - int index = name.get_slicec('/', 1).to_int(); - String what = name.get_slicec('/', 2); + } else if (prop_name.begins_with("bind/")) { + int index = prop_name.get_slicec('/', 1).to_int(); + String what = prop_name.get_slicec('/', 2); if (what == "bone") { set_bind_bone(index, p_value); return true; @@ -108,13 +108,13 @@ bool Skin::_set(const StringName &p_name, const Variant &p_value) { } bool Skin::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; - if (name == "bind_count") { + String prop_name = p_name; + if (prop_name == "bind_count") { r_ret = get_bind_count(); return true; - } else if (name.begins_with("bind/")) { - int index = name.get_slicec('/', 1).to_int(); - String what = name.get_slicec('/', 2); + } else if (prop_name.begins_with("bind/")) { + int index = prop_name.get_slicec('/', 1).to_int(); + String what = prop_name.get_slicec('/', 2); if (what == "bone") { r_ret = get_bind_bone(index); return true; diff --git a/scene/resources/sprite_frames.cpp b/scene/resources/sprite_frames.cpp index 3533e86c3a..838566f696 100644 --- a/scene/resources/sprite_frames.cpp +++ b/scene/resources/sprite_frames.cpp @@ -143,10 +143,10 @@ Array SpriteFrames::_get_animations() const { get_animation_list(&sorted_names); sorted_names.sort_custom<StringName::AlphCompare>(); - for (const StringName &name : sorted_names) { - const Anim &anim = animations[name]; + for (const StringName &anim_name : sorted_names) { + const Anim &anim = animations[anim_name]; Dictionary d; - d["name"] = name; + d["name"] = anim_name; d["speed"] = anim.speed; d["loop"] = anim.loop; Array frames; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 298d7b1ffa..4085aa8ec2 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -1288,15 +1288,15 @@ Error CompressedTexture3D::_load_data(const String &p_path, Vector<Ref<Image>> & f->get_32(); // ignored (data format) f->get_32(); //ignored - int mipmaps = f->get_32(); + int mipmap_count = f->get_32(); f->get_32(); //ignored f->get_32(); //ignored - r_mipmaps = mipmaps != 0; + r_mipmaps = mipmap_count != 0; r_data.clear(); - for (int i = 0; i < (r_depth + mipmaps); i++) { + for (int i = 0; i < (r_depth + mipmap_count); i++) { Ref<Image> image = CompressedTexture2D::load_image_from_file(f, 0); ERR_FAIL_COND_V(image.is_null() || image->is_empty(), ERR_CANT_OPEN); if (i == 0) { diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 3321392821..ed0d5ee688 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -40,20 +40,20 @@ bool Theme::_set(const StringName &p_name, const Variant &p_value) { if (sname.contains("/")) { String type = sname.get_slicec('/', 1); String theme_type = sname.get_slicec('/', 0); - String name = sname.get_slicec('/', 2); + String prop_name = sname.get_slicec('/', 2); if (type == "icons") { - set_icon(name, theme_type, p_value); + set_icon(prop_name, theme_type, p_value); } else if (type == "styles") { - set_stylebox(name, theme_type, p_value); + set_stylebox(prop_name, theme_type, p_value); } else if (type == "fonts") { - set_font(name, theme_type, p_value); + set_font(prop_name, theme_type, p_value); } else if (type == "font_sizes") { - set_font_size(name, theme_type, p_value); + set_font_size(prop_name, theme_type, p_value); } else if (type == "colors") { - set_color(name, theme_type, p_value); + set_color(prop_name, theme_type, p_value); } else if (type == "constants") { - set_constant(name, theme_type, p_value); + set_constant(prop_name, theme_type, p_value); } else if (type == "base_type") { set_type_variation(theme_type, p_value); } else { @@ -72,32 +72,32 @@ bool Theme::_get(const StringName &p_name, Variant &r_ret) const { if (sname.contains("/")) { String type = sname.get_slicec('/', 1); String theme_type = sname.get_slicec('/', 0); - String name = sname.get_slicec('/', 2); + String prop_name = sname.get_slicec('/', 2); if (type == "icons") { - if (!has_icon(name, theme_type)) { + if (!has_icon(prop_name, theme_type)) { r_ret = Ref<Texture2D>(); } else { - r_ret = get_icon(name, theme_type); + r_ret = get_icon(prop_name, theme_type); } } else if (type == "styles") { - if (!has_stylebox(name, theme_type)) { + if (!has_stylebox(prop_name, theme_type)) { r_ret = Ref<StyleBox>(); } else { - r_ret = get_stylebox(name, theme_type); + r_ret = get_stylebox(prop_name, theme_type); } } else if (type == "fonts") { - if (!has_font(name, theme_type)) { + if (!has_font(prop_name, theme_type)) { r_ret = Ref<Font>(); } else { - r_ret = get_font(name, theme_type); + r_ret = get_font(prop_name, theme_type); } } else if (type == "font_sizes") { - r_ret = get_font_size(name, theme_type); + r_ret = get_font_size(prop_name, theme_type); } else if (type == "colors") { - r_ret = get_color(name, theme_type); + r_ret = get_color(prop_name, theme_type); } else if (type == "constants") { - r_ret = get_constant(name, theme_type); + r_ret = get_constant(prop_name, theme_type); } else if (type == "base_type") { r_ret = get_type_variation_base(theme_type); } else { diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 813be773b7..d7d7b5fe31 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -3779,14 +3779,14 @@ bool TileSetAtlasSource::get_use_texture_padding() const { } Vector2i TileSetAtlasSource::get_atlas_grid_size() const { - Ref<Texture2D> texture = get_texture(); - if (!texture.is_valid()) { + Ref<Texture2D> txt = get_texture(); + if (!txt.is_valid()) { return Vector2i(); } ERR_FAIL_COND_V(texture_region_size.x <= 0 || texture_region_size.y <= 0, Vector2i()); - Size2i valid_area = texture->get_size() - margins; + Size2i valid_area = txt->get_size() - margins; // Compute the number of valid tiles in the tiles atlas Size2i grid_size = Size2i(); diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 9174fcd9e3..df9addb6bb 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -1148,7 +1148,7 @@ String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port StringBuilder global_code; StringBuilder global_code_per_node; HashMap<Type, StringBuilder> global_code_per_func; - StringBuilder code; + StringBuilder shader_code; HashSet<StringName> classes; global_code += String() + "shader_type canvas_item;\n"; @@ -1189,69 +1189,69 @@ String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port input_connections.insert(to_key, E); } - code += "\nvoid fragment() {\n"; + shader_code += "\nvoid fragment() {\n"; HashSet<int> processed; - Error err = _write_node(p_type, &global_code, &global_code_per_node, &global_code_per_func, code, default_tex_params, input_connections, output_connections, p_node, processed, true, classes); + Error err = _write_node(p_type, &global_code, &global_code_per_node, &global_code_per_func, shader_code, default_tex_params, input_connections, output_connections, p_node, processed, true, classes); ERR_FAIL_COND_V(err != OK, String()); switch (node->get_output_port_type(p_port)) { case VisualShaderNode::PORT_TYPE_SCALAR: { - code += " COLOR.rgb = vec3(n_out" + itos(p_node) + "p" + itos(p_port) + ");\n"; + shader_code += " COLOR.rgb = vec3(n_out" + itos(p_node) + "p" + itos(p_port) + ");\n"; } break; case VisualShaderNode::PORT_TYPE_SCALAR_INT: { - code += " COLOR.rgb = vec3(float(n_out" + itos(p_node) + "p" + itos(p_port) + "));\n"; + shader_code += " COLOR.rgb = vec3(float(n_out" + itos(p_node) + "p" + itos(p_port) + "));\n"; } break; case VisualShaderNode::PORT_TYPE_BOOLEAN: { - code += " COLOR.rgb = vec3(n_out" + itos(p_node) + "p" + itos(p_port) + " ? 1.0 : 0.0);\n"; + shader_code += " COLOR.rgb = vec3(n_out" + itos(p_node) + "p" + itos(p_port) + " ? 1.0 : 0.0);\n"; } break; case VisualShaderNode::PORT_TYPE_VECTOR_2D: { - code += " COLOR.rgb = vec3(n_out" + itos(p_node) + "p" + itos(p_port) + ", 0.0);\n"; + shader_code += " COLOR.rgb = vec3(n_out" + itos(p_node) + "p" + itos(p_port) + ", 0.0);\n"; } break; case VisualShaderNode::PORT_TYPE_VECTOR_3D: { - code += " COLOR.rgb = n_out" + itos(p_node) + "p" + itos(p_port) + ";\n"; + shader_code += " COLOR.rgb = n_out" + itos(p_node) + "p" + itos(p_port) + ";\n"; } break; case VisualShaderNode::PORT_TYPE_VECTOR_4D: { - code += " COLOR.rgb = n_out" + itos(p_node) + "p" + itos(p_port) + ".xyz;\n"; + shader_code += " COLOR.rgb = n_out" + itos(p_node) + "p" + itos(p_port) + ".xyz;\n"; } break; default: { - code += " COLOR.rgb = vec3(0.0);\n"; + shader_code += " COLOR.rgb = vec3(0.0);\n"; } break; } - code += "}\n"; + shader_code += "}\n"; //set code secretly global_code += "\n\n"; String final_code = global_code; final_code += global_code_per_node; - final_code += code; + final_code += shader_code; return final_code; } String VisualShader::validate_port_name(const String &p_port_name, VisualShaderNode *p_node, int p_port_id, bool p_output) const { - String name = p_port_name; + String port_name = p_port_name; - if (name.is_empty()) { + if (port_name.is_empty()) { return String(); } - while (name.length() && !is_ascii_char(name[0])) { - name = name.substr(1, name.length() - 1); + while (port_name.length() && !is_ascii_char(port_name[0])) { + port_name = port_name.substr(1, port_name.length() - 1); } - if (!name.is_empty()) { + if (!port_name.is_empty()) { String valid_name; - for (int i = 0; i < name.length(); i++) { - if (is_ascii_identifier_char(name[i])) { - valid_name += String::chr(name[i]); - } else if (name[i] == ' ') { + for (int i = 0; i < port_name.length(); i++) { + if (is_ascii_identifier_char(port_name[i])) { + valid_name += String::chr(port_name[i]); + } else if (port_name[i] == ' ') { valid_name += "_"; } } - name = valid_name; + port_name = valid_name; } else { return String(); } @@ -1263,7 +1263,7 @@ String VisualShader::validate_port_name(const String &p_port_name, VisualShaderN if (!p_output && i == p_port_id) { continue; } - if (name == p_node->get_input_port_name(i)) { + if (port_name == p_node->get_input_port_name(i)) { return String(); } } @@ -1271,35 +1271,35 @@ String VisualShader::validate_port_name(const String &p_port_name, VisualShaderN if (p_output && i == p_port_id) { continue; } - if (name == p_node->get_output_port_name(i)) { + if (port_name == p_node->get_output_port_name(i)) { return String(); } } - return name; + return port_name; } String VisualShader::validate_parameter_name(const String &p_name, const Ref<VisualShaderNodeParameter> &p_parameter) const { - String name = p_name; //validate name first - while (name.length() && !is_ascii_char(name[0])) { - name = name.substr(1, name.length() - 1); + String param_name = p_name; //validate name first + while (param_name.length() && !is_ascii_char(param_name[0])) { + param_name = param_name.substr(1, param_name.length() - 1); } - if (!name.is_empty()) { + if (!param_name.is_empty()) { String valid_name; - for (int i = 0; i < name.length(); i++) { - if (is_ascii_identifier_char(name[i])) { - valid_name += String::chr(name[i]); - } else if (name[i] == ' ') { + for (int i = 0; i < param_name.length(); i++) { + if (is_ascii_identifier_char(param_name[i])) { + valid_name += String::chr(param_name[i]); + } else if (param_name[i] == ' ') { valid_name += "_"; } } - name = valid_name; + param_name = valid_name; } - if (name.is_empty()) { - name = p_parameter->get_caption(); + if (param_name.is_empty()) { + param_name = p_parameter->get_caption(); } int attempt = 1; @@ -1312,7 +1312,7 @@ String VisualShader::validate_parameter_name(const String &p_name, const Ref<Vis if (node == p_parameter) { //do not test on self continue; } - if (node.is_valid() && node->get_parameter_name() == name) { + if (node.is_valid() && node->get_parameter_name() == param_name) { exists = true; break; } @@ -1325,17 +1325,17 @@ String VisualShader::validate_parameter_name(const String &p_name, const Ref<Vis if (exists) { //remove numbers, put new and try again attempt++; - while (name.length() && is_digit(name[name.length() - 1])) { - name = name.substr(0, name.length() - 1); + while (param_name.length() && is_digit(param_name[param_name.length() - 1])) { + param_name = param_name.substr(0, param_name.length() - 1); } - ERR_FAIL_COND_V(name.is_empty(), String()); - name += itos(attempt); + ERR_FAIL_COND_V(param_name.is_empty(), String()); + param_name += itos(attempt); } else { break; } } - return name; + return param_name; } static const char *type_string[VisualShader::TYPE_MAX] = { @@ -1352,12 +1352,12 @@ static const char *type_string[VisualShader::TYPE_MAX] = { }; bool VisualShader::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; - if (name == "mode") { + String prop_name = p_name; + if (prop_name == "mode") { set_mode(Shader::Mode(int(p_value))); return true; - } else if (name.begins_with("flags/")) { - StringName flag = name.get_slicec('/', 1); + } else if (prop_name.begins_with("flags/")) { + StringName flag = prop_name.get_slicec('/', 1); bool enable = p_value; if (enable) { flags.insert(flag); @@ -1366,18 +1366,18 @@ bool VisualShader::_set(const StringName &p_name, const Variant &p_value) { } _queue_update(); return true; - } else if (name.begins_with("modes/")) { - String mode = name.get_slicec('/', 1); + } else if (prop_name.begins_with("modes/")) { + String mode_name = prop_name.get_slicec('/', 1); int value = p_value; if (value == 0) { - modes.erase(mode); //means it's default anyway, so don't store it + modes.erase(mode_name); //means it's default anyway, so don't store it } else { - modes[mode] = value; + modes[mode_name] = value; } _queue_update(); return true; - } else if (name.begins_with("varyings/")) { - String var_name = name.get_slicec('/', 1); + } else if (prop_name.begins_with("varyings/")) { + String var_name = prop_name.get_slicec('/', 1); Varying value = Varying(); value.name = var_name; if (value.from_string(p_value) && !varyings.has(var_name)) { @@ -1386,8 +1386,8 @@ bool VisualShader::_set(const StringName &p_name, const Variant &p_value) { } _queue_update(); return true; - } else if (name.begins_with("nodes/")) { - String typestr = name.get_slicec('/', 1); + } else if (prop_name.begins_with("nodes/")) { + String typestr = prop_name.get_slicec('/', 1); Type type = TYPE_VERTEX; for (int i = 0; i < TYPE_MAX; i++) { if (typestr == type_string[i]) { @@ -1396,7 +1396,7 @@ bool VisualShader::_set(const StringName &p_name, const Variant &p_value) { } } - String index = name.get_slicec('/', 2); + String index = prop_name.get_slicec('/', 2); if (index == "connections") { Vector<int> conns = p_value; if (conns.size() % 4 == 0) { @@ -1408,7 +1408,7 @@ bool VisualShader::_set(const StringName &p_name, const Variant &p_value) { } int id = index.to_int(); - String what = name.get_slicec('/', 3); + String what = prop_name.get_slicec('/', 3); if (what == "node") { add_node(type, p_value, Vector2(), id); @@ -1434,32 +1434,32 @@ bool VisualShader::_set(const StringName &p_name, const Variant &p_value) { } bool VisualShader::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; - if (name == "mode") { + String prop_name = p_name; + if (prop_name == "mode") { r_ret = get_mode(); return true; - } else if (name.begins_with("flags/")) { - StringName flag = name.get_slicec('/', 1); + } else if (prop_name.begins_with("flags/")) { + StringName flag = prop_name.get_slicec('/', 1); r_ret = flags.has(flag); return true; - } else if (name.begins_with("modes/")) { - String mode = name.get_slicec('/', 1); - if (modes.has(mode)) { - r_ret = modes[mode]; + } else if (prop_name.begins_with("modes/")) { + String mode_name = prop_name.get_slicec('/', 1); + if (modes.has(mode_name)) { + r_ret = modes[mode_name]; } else { r_ret = 0; } return true; - } else if (name.begins_with("varyings/")) { - String var_name = name.get_slicec('/', 1); + } else if (prop_name.begins_with("varyings/")) { + String var_name = prop_name.get_slicec('/', 1); if (varyings.has(var_name)) { r_ret = varyings[var_name].to_string(); } else { r_ret = String(); } return true; - } else if (name.begins_with("nodes/")) { - String typestr = name.get_slicec('/', 1); + } else if (prop_name.begins_with("nodes/")) { + String typestr = prop_name.get_slicec('/', 1); Type type = TYPE_VERTEX; for (int i = 0; i < TYPE_MAX; i++) { if (typestr == type_string[i]) { @@ -1468,7 +1468,7 @@ bool VisualShader::_get(const StringName &p_name, Variant &r_ret) const { } } - String index = name.get_slicec('/', 2); + String index = prop_name.get_slicec('/', 2); if (index == "connections") { Vector<int> conns; for (const Connection &E : graph[type].connections) { @@ -1483,7 +1483,7 @@ bool VisualShader::_get(const StringName &p_name, Variant &r_ret) const { } int id = index.to_int(); - String what = name.get_slicec('/', 3); + String what = prop_name.get_slicec('/', 3); if (what == "node") { r_ret = get_node(type, id); @@ -1580,12 +1580,12 @@ void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const { } } -Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBuilder *global_code_per_node, HashMap<Type, StringBuilder> *global_code_per_func, StringBuilder &code, Vector<VisualShader::DefaultTextureParam> &def_tex_params, const VMap<ConnectionKey, const List<Connection>::Element *> &input_connections, const VMap<ConnectionKey, const List<Connection>::Element *> &output_connections, int node, HashSet<int> &processed, bool for_preview, HashSet<StringName> &r_classes) const { - const Ref<VisualShaderNode> vsnode = graph[type].nodes[node].node; +Error VisualShader::_write_node(Type type, StringBuilder *p_global_code, StringBuilder *p_global_code_per_node, HashMap<Type, StringBuilder> *p_global_code_per_func, StringBuilder &r_code, Vector<VisualShader::DefaultTextureParam> &r_def_tex_params, const VMap<ConnectionKey, const List<Connection>::Element *> &p_input_connections, const VMap<ConnectionKey, const List<Connection>::Element *> &p_output_connections, int p_node, HashSet<int> &r_processed, bool p_for_preview, HashSet<StringName> &r_classes) const { + const Ref<VisualShaderNode> vsnode = graph[type].nodes[p_node].node; if (vsnode->is_disabled()) { - code += "// " + vsnode->get_caption() + ":" + itos(node) + "\n"; - code += " // Node is disabled and code is not generated.\n"; + r_code += "// " + vsnode->get_caption() + ":" + itos(p_node) + "\n"; + r_code += " // Node is disabled and code is not generated.\n"; return OK; } @@ -1593,16 +1593,16 @@ Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBui int input_count = vsnode->get_input_port_count(); for (int i = 0; i < input_count; i++) { ConnectionKey ck; - ck.node = node; + ck.node = p_node; ck.port = i; - if (input_connections.has(ck)) { - int from_node = input_connections[ck]->get().from_node; - if (processed.has(from_node)) { + if (p_input_connections.has(ck)) { + int from_node = p_input_connections[ck]->get().from_node; + if (r_processed.has(from_node)) { continue; } - Error err = _write_node(type, global_code, global_code_per_node, global_code_per_func, code, def_tex_params, input_connections, output_connections, from_node, processed, for_preview, r_classes); + Error err = _write_node(type, p_global_code, p_global_code_per_node, p_global_code_per_func, r_code, r_def_tex_params, p_input_connections, p_output_connections, from_node, r_processed, p_for_preview, r_classes); if (err) { return err; } @@ -1611,19 +1611,19 @@ Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBui // then this node - Vector<VisualShader::DefaultTextureParam> params = vsnode->get_default_texture_parameters(type, node); + Vector<VisualShader::DefaultTextureParam> params = vsnode->get_default_texture_parameters(type, p_node); for (int i = 0; i < params.size(); i++) { - def_tex_params.push_back(params[i]); + r_def_tex_params.push_back(params[i]); } Ref<VisualShaderNodeInput> input = vsnode; - bool skip_global = input.is_valid() && for_preview; + bool skip_global = input.is_valid() && p_for_preview; if (!skip_global) { Ref<VisualShaderNodeParameter> parameter = vsnode; if (!parameter.is_valid() || !parameter->is_global_code_generated()) { - if (global_code) { - *global_code += vsnode->generate_global(get_mode(), type, node); + if (p_global_code) { + *p_global_code += vsnode->generate_global(get_mode(), type, p_node); } } @@ -1632,12 +1632,12 @@ Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBui class_name = vsnode->get_script_instance()->get_script()->get_path(); } if (!r_classes.has(class_name)) { - if (global_code_per_node) { - *global_code_per_node += vsnode->generate_global_per_node(get_mode(), node); + if (p_global_code_per_node) { + *p_global_code_per_node += vsnode->generate_global_per_node(get_mode(), p_node); } for (int i = 0; i < TYPE_MAX; i++) { - if (global_code_per_func) { - (*global_code_per_func)[Type(i)] += vsnode->generate_global_per_func(get_mode(), Type(i), node); + if (p_global_code_per_func) { + (*p_global_code_per_func)[Type(i)] += vsnode->generate_global_per_func(get_mode(), Type(i), p_node); } } r_classes.insert(class_name); @@ -1645,11 +1645,11 @@ Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBui } if (!vsnode->is_code_generated()) { // just generate globals and ignore locals - processed.insert(node); + r_processed.insert(p_node); return OK; } - String node_name = "// " + vsnode->get_caption() + ":" + itos(node) + "\n"; + String node_name = "// " + vsnode->get_caption() + ":" + itos(p_node) + "\n"; String node_code; Vector<String> input_vars; @@ -1658,18 +1658,18 @@ Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBui for (int i = 0; i < input_count; i++) { ConnectionKey ck; - ck.node = node; + ck.node = p_node; ck.port = i; - if (input_connections.has(ck)) { + if (p_input_connections.has(ck)) { //connected to something, use that output - int from_node = input_connections[ck]->get().from_node; + int from_node = p_input_connections[ck]->get().from_node; if (graph[type].nodes[from_node].node->is_disabled()) { continue; } - int from_port = input_connections[ck]->get().from_port; + int from_port = p_input_connections[ck]->get().from_port; VisualShaderNode::PortType in_type = vsnode->get_input_port_type(i); VisualShaderNode::PortType out_type = graph[type].nodes[from_node].node->get_output_port_type(from_port); @@ -1826,32 +1826,32 @@ Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBui Variant defval = vsnode->get_input_port_default_value(i); if (defval.get_type() == Variant::FLOAT) { float val = defval; - inputs[i] = "n_in" + itos(node) + "p" + itos(i); + inputs[i] = "n_in" + itos(p_node) + "p" + itos(i); node_code += " float " + inputs[i] + " = " + vformat("%.5f", val) + ";\n"; } else if (defval.get_type() == Variant::INT) { int val = defval; - inputs[i] = "n_in" + itos(node) + "p" + itos(i); + inputs[i] = "n_in" + itos(p_node) + "p" + itos(i); node_code += " int " + inputs[i] + " = " + itos(val) + ";\n"; } else if (defval.get_type() == Variant::BOOL) { bool val = defval; - inputs[i] = "n_in" + itos(node) + "p" + itos(i); + inputs[i] = "n_in" + itos(p_node) + "p" + itos(i); node_code += " bool " + inputs[i] + " = " + (val ? "true" : "false") + ";\n"; } else if (defval.get_type() == Variant::VECTOR2) { Vector2 val = defval; - inputs[i] = "n_in" + itos(node) + "p" + itos(i); + inputs[i] = "n_in" + itos(p_node) + "p" + itos(i); node_code += " vec2 " + inputs[i] + " = " + vformat("vec2(%.5f, %.5f);\n", val.x, val.y); } else if (defval.get_type() == Variant::VECTOR3) { Vector3 val = defval; - inputs[i] = "n_in" + itos(node) + "p" + itos(i); + inputs[i] = "n_in" + itos(p_node) + "p" + itos(i); node_code += " vec3 " + inputs[i] + " = " + vformat("vec3(%.5f, %.5f, %.5f);\n", val.x, val.y, val.z); } else if (defval.get_type() == Variant::QUATERNION) { Quaternion val = defval; - inputs[i] = "n_in" + itos(node) + "p" + itos(i); + inputs[i] = "n_in" + itos(p_node) + "p" + itos(i); node_code += " vec4 " + inputs[i] + " = " + vformat("vec4(%.5f, %.5f, %.5f, %.5f);\n", val.x, val.y, val.z, val.w); } else if (defval.get_type() == Variant::TRANSFORM3D) { Transform3D val = defval; val.basis.transpose(); - inputs[i] = "n_in" + itos(node) + "p" + itos(i); + inputs[i] = "n_in" + itos(p_node) + "p" + itos(i); Array values; for (int j = 0; j < 3; j++) { values.push_back(val.basis[j].x); @@ -1903,7 +1903,7 @@ Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBui if (vsnode->is_simple_decl()) { // less code to generate for some simple_decl nodes for (int i = 0, j = 0; i < initial_output_count; i++, j++) { - String var_name = "n_out" + itos(node) + "p" + itos(j); + String var_name = "n_out" + itos(p_node) + "p" + itos(j); switch (vsnode->get_output_port_type(i)) { case VisualShaderNode::PORT_TYPE_SCALAR: outputs[i] = "float " + var_name; @@ -1948,28 +1948,28 @@ Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBui } else { for (int i = 0, j = 0; i < initial_output_count; i++, j++) { - outputs[i] = "n_out" + itos(node) + "p" + itos(j); + outputs[i] = "n_out" + itos(p_node) + "p" + itos(j); switch (vsnode->get_output_port_type(i)) { case VisualShaderNode::PORT_TYPE_SCALAR: - code += " float " + outputs[i] + ";\n"; + r_code += " float " + outputs[i] + ";\n"; break; case VisualShaderNode::PORT_TYPE_SCALAR_INT: - code += " int " + outputs[i] + ";\n"; + r_code += " int " + outputs[i] + ";\n"; break; case VisualShaderNode::PORT_TYPE_VECTOR_2D: - code += " vec2 " + outputs[i] + ";\n"; + r_code += " vec2 " + outputs[i] + ";\n"; break; case VisualShaderNode::PORT_TYPE_VECTOR_3D: - code += " vec3 " + outputs[i] + ";\n"; + r_code += " vec3 " + outputs[i] + ";\n"; break; case VisualShaderNode::PORT_TYPE_VECTOR_4D: - code += " vec4 " + outputs[i] + ";\n"; + r_code += " vec4 " + outputs[i] + ";\n"; break; case VisualShaderNode::PORT_TYPE_BOOLEAN: - code += " bool " + outputs[i] + ";\n"; + r_code += " bool " + outputs[i] + ";\n"; break; case VisualShaderNode::PORT_TYPE_TRANSFORM: - code += " mat4 " + outputs[i] + ";\n"; + r_code += " mat4 " + outputs[i] + ";\n"; break; default: break; @@ -1992,73 +1992,73 @@ Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBui } } - node_code += vsnode->generate_code(get_mode(), type, node, inputs, outputs, for_preview); + node_code += vsnode->generate_code(get_mode(), type, p_node, inputs, outputs, p_for_preview); if (!node_code.is_empty()) { - code += node_name; - code += node_code; + r_code += node_name; + r_code += node_code; } for (int i = 0; i < output_count; i++) { if (expanded_output_ports[i]) { switch (vsnode->get_output_port_type(i)) { case VisualShaderNode::PORT_TYPE_VECTOR_2D: { - if (vsnode->is_output_port_connected(i + 1) || (for_preview && vsnode->get_output_port_for_preview() == (i + 1))) { // red-component - String r = "n_out" + itos(node) + "p" + itos(i + 1); - code += " float " + r + " = n_out" + itos(node) + "p" + itos(i) + ".r;\n"; + if (vsnode->is_output_port_connected(i + 1) || (p_for_preview && vsnode->get_output_port_for_preview() == (i + 1))) { // red-component + String r = "n_out" + itos(p_node) + "p" + itos(i + 1); + r_code += " float " + r + " = n_out" + itos(p_node) + "p" + itos(i) + ".r;\n"; outputs[i + 1] = r; } - if (vsnode->is_output_port_connected(i + 2) || (for_preview && vsnode->get_output_port_for_preview() == (i + 2))) { // green-component - String g = "n_out" + itos(node) + "p" + itos(i + 2); - code += " float " + g + " = n_out" + itos(node) + "p" + itos(i) + ".g;\n"; + if (vsnode->is_output_port_connected(i + 2) || (p_for_preview && vsnode->get_output_port_for_preview() == (i + 2))) { // green-component + String g = "n_out" + itos(p_node) + "p" + itos(i + 2); + r_code += " float " + g + " = n_out" + itos(p_node) + "p" + itos(i) + ".g;\n"; outputs[i + 2] = g; } i += 2; } break; case VisualShaderNode::PORT_TYPE_VECTOR_3D: { - if (vsnode->is_output_port_connected(i + 1) || (for_preview && vsnode->get_output_port_for_preview() == (i + 1))) { // red-component - String r = "n_out" + itos(node) + "p" + itos(i + 1); - code += " float " + r + " = n_out" + itos(node) + "p" + itos(i) + ".r;\n"; + if (vsnode->is_output_port_connected(i + 1) || (p_for_preview && vsnode->get_output_port_for_preview() == (i + 1))) { // red-component + String r = "n_out" + itos(p_node) + "p" + itos(i + 1); + r_code += " float " + r + " = n_out" + itos(p_node) + "p" + itos(i) + ".r;\n"; outputs[i + 1] = r; } - if (vsnode->is_output_port_connected(i + 2) || (for_preview && vsnode->get_output_port_for_preview() == (i + 2))) { // green-component - String g = "n_out" + itos(node) + "p" + itos(i + 2); - code += " float " + g + " = n_out" + itos(node) + "p" + itos(i) + ".g;\n"; + if (vsnode->is_output_port_connected(i + 2) || (p_for_preview && vsnode->get_output_port_for_preview() == (i + 2))) { // green-component + String g = "n_out" + itos(p_node) + "p" + itos(i + 2); + r_code += " float " + g + " = n_out" + itos(p_node) + "p" + itos(i) + ".g;\n"; outputs[i + 2] = g; } - if (vsnode->is_output_port_connected(i + 3) || (for_preview && vsnode->get_output_port_for_preview() == (i + 3))) { // blue-component - String b = "n_out" + itos(node) + "p" + itos(i + 3); - code += " float " + b + " = n_out" + itos(node) + "p" + itos(i) + ".b;\n"; + if (vsnode->is_output_port_connected(i + 3) || (p_for_preview && vsnode->get_output_port_for_preview() == (i + 3))) { // blue-component + String b = "n_out" + itos(p_node) + "p" + itos(i + 3); + r_code += " float " + b + " = n_out" + itos(p_node) + "p" + itos(i) + ".b;\n"; outputs[i + 3] = b; } i += 3; } break; case VisualShaderNode::PORT_TYPE_VECTOR_4D: { - if (vsnode->is_output_port_connected(i + 1) || (for_preview && vsnode->get_output_port_for_preview() == (i + 1))) { // red-component - String r = "n_out" + itos(node) + "p" + itos(i + 1); - code += " float " + r + " = n_out" + itos(node) + "p" + itos(i) + ".r;\n"; + if (vsnode->is_output_port_connected(i + 1) || (p_for_preview && vsnode->get_output_port_for_preview() == (i + 1))) { // red-component + String r = "n_out" + itos(p_node) + "p" + itos(i + 1); + r_code += " float " + r + " = n_out" + itos(p_node) + "p" + itos(i) + ".r;\n"; outputs[i + 1] = r; } - if (vsnode->is_output_port_connected(i + 2) || (for_preview && vsnode->get_output_port_for_preview() == (i + 2))) { // green-component - String g = "n_out" + itos(node) + "p" + itos(i + 2); - code += " float " + g + " = n_out" + itos(node) + "p" + itos(i) + ".g;\n"; + if (vsnode->is_output_port_connected(i + 2) || (p_for_preview && vsnode->get_output_port_for_preview() == (i + 2))) { // green-component + String g = "n_out" + itos(p_node) + "p" + itos(i + 2); + r_code += " float " + g + " = n_out" + itos(p_node) + "p" + itos(i) + ".g;\n"; outputs[i + 2] = g; } - if (vsnode->is_output_port_connected(i + 3) || (for_preview && vsnode->get_output_port_for_preview() == (i + 3))) { // blue-component - String b = "n_out" + itos(node) + "p" + itos(i + 3); - code += " float " + b + " = n_out" + itos(node) + "p" + itos(i) + ".b;\n"; + if (vsnode->is_output_port_connected(i + 3) || (p_for_preview && vsnode->get_output_port_for_preview() == (i + 3))) { // blue-component + String b = "n_out" + itos(p_node) + "p" + itos(i + 3); + r_code += " float " + b + " = n_out" + itos(p_node) + "p" + itos(i) + ".b;\n"; outputs[i + 3] = b; } - if (vsnode->is_output_port_connected(i + 4) || (for_preview && vsnode->get_output_port_for_preview() == (i + 4))) { // alpha-component - String a = "n_out" + itos(node) + "p" + itos(i + 4); - code += " float " + a + " = n_out" + itos(node) + "p" + itos(i) + ".a;\n"; + if (vsnode->is_output_port_connected(i + 4) || (p_for_preview && vsnode->get_output_port_for_preview() == (i + 4))) { // alpha-component + String a = "n_out" + itos(p_node) + "p" + itos(i + 4); + r_code += " float " + a + " = n_out" + itos(p_node) + "p" + itos(i) + ".a;\n"; outputs[i + 4] = a; } @@ -2071,11 +2071,11 @@ Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBui } if (!node_code.is_empty()) { - code += "\n"; + r_code += "\n"; } - code += "\n"; // - processed.insert(node); + r_code += "\n"; // + r_processed.insert(p_node); return OK; } @@ -2103,7 +2103,7 @@ void VisualShader::_update_shader() const { StringBuilder global_code; StringBuilder global_code_per_node; HashMap<Type, StringBuilder> global_code_per_func; - StringBuilder code; + StringBuilder shader_code; Vector<VisualShader::DefaultTextureParam> default_tex_params; HashSet<StringName> classes; HashMap<int, int> insertion_pos; @@ -2340,7 +2340,7 @@ void VisualShader::_update_shader() const { if (shader_mode != Shader::MODE_PARTICLES) { func_code += "\nvoid " + String(func_name[i]) + "() {\n"; } - insertion_pos.insert(i, code.get_string_length() + func_code.get_string_length()); + insertion_pos.insert(i, shader_code.get_string_length() + func_code.get_string_length()); Error err = _write_node(Type(i), &global_code, &global_code_per_node, &global_code_per_func, func_code, default_tex_params, input_connections, output_connections, NODE_ID_OUTPUT, processed, false, classes); ERR_FAIL_COND(err != OK); @@ -2364,7 +2364,7 @@ void VisualShader::_update_shader() const { } else { func_code += varying_code; func_code += "}\n"; - code += func_code; + shader_code += func_code; } } @@ -2377,65 +2377,65 @@ void VisualShader::_update_shader() const { bool has_process_custom = !code_map[TYPE_PROCESS_CUSTOM].is_empty(); bool has_collide = !code_map[TYPE_COLLIDE].is_empty(); - code += "void start() {\n"; + shader_code += "void start() {\n"; if (has_start || has_start_custom) { - code += " uint __seed = __hash(NUMBER + uint(1) + RANDOM_SEED);\n"; - code += " vec3 __diff = TRANSFORM[3].xyz - EMISSION_TRANSFORM[3].xyz;\n"; - code += " float __radians;\n"; - code += " vec3 __vec3_buff1;\n"; - code += " vec3 __vec3_buff2;\n"; - code += " float __scalar_buff1;\n"; - code += " float __scalar_buff2;\n"; - code += " int __scalar_ibuff;\n"; - code += " vec4 __vec4_buff;\n"; - code += " vec3 __ndiff = normalize(__diff);\n\n"; + shader_code += " uint __seed = __hash(NUMBER + uint(1) + RANDOM_SEED);\n"; + shader_code += " vec3 __diff = TRANSFORM[3].xyz - EMISSION_TRANSFORM[3].xyz;\n"; + shader_code += " float __radians;\n"; + shader_code += " vec3 __vec3_buff1;\n"; + shader_code += " vec3 __vec3_buff2;\n"; + shader_code += " float __scalar_buff1;\n"; + shader_code += " float __scalar_buff2;\n"; + shader_code += " int __scalar_ibuff;\n"; + shader_code += " vec4 __vec4_buff;\n"; + shader_code += " vec3 __ndiff = normalize(__diff);\n\n"; } if (has_start) { - code += " {\n"; - code += code_map[TYPE_START].replace("\n ", "\n "); - code += " }\n"; + shader_code += " {\n"; + shader_code += code_map[TYPE_START].replace("\n ", "\n "); + shader_code += " }\n"; if (has_start_custom) { - code += " \n"; + shader_code += " \n"; } } if (has_start_custom) { - code += " {\n"; - code += code_map[TYPE_START_CUSTOM].replace("\n ", "\n "); - code += " }\n"; + shader_code += " {\n"; + shader_code += code_map[TYPE_START_CUSTOM].replace("\n ", "\n "); + shader_code += " }\n"; } - code += "}\n\n"; - code += "void process() {\n"; + shader_code += "}\n\n"; + shader_code += "void process() {\n"; if (has_process || has_process_custom || has_collide) { - code += " uint __seed = __hash(NUMBER + uint(1) + RANDOM_SEED);\n"; - code += " vec3 __vec3_buff1;\n"; - code += " vec3 __diff = TRANSFORM[3].xyz - EMISSION_TRANSFORM[3].xyz;\n"; - code += " vec3 __ndiff = normalize(__diff);\n\n"; + shader_code += " uint __seed = __hash(NUMBER + uint(1) + RANDOM_SEED);\n"; + shader_code += " vec3 __vec3_buff1;\n"; + shader_code += " vec3 __diff = TRANSFORM[3].xyz - EMISSION_TRANSFORM[3].xyz;\n"; + shader_code += " vec3 __ndiff = normalize(__diff);\n\n"; } - code += " {\n"; + shader_code += " {\n"; String tab = " "; if (has_collide) { - code += " if (COLLIDED) {\n\n"; - code += code_map[TYPE_COLLIDE].replace("\n ", "\n "); + shader_code += " if (COLLIDED) {\n\n"; + shader_code += code_map[TYPE_COLLIDE].replace("\n ", "\n "); if (has_process) { - code += " } else {\n\n"; + shader_code += " } else {\n\n"; tab += " "; } } if (has_process) { - code += code_map[TYPE_PROCESS].replace("\n ", "\n " + tab); + shader_code += code_map[TYPE_PROCESS].replace("\n ", "\n " + tab); } if (has_collide) { - code += " }\n"; + shader_code += " }\n"; } - code += " }\n"; + shader_code += " }\n"; if (has_process_custom) { - code += " {\n\n"; - code += code_map[TYPE_PROCESS_CUSTOM].replace("\n ", "\n "); - code += " }\n"; + shader_code += " {\n\n"; + shader_code += code_map[TYPE_PROCESS_CUSTOM].replace("\n ", "\n "); + shader_code += " }\n"; } - code += "}\n\n"; + shader_code += "}\n\n"; global_compute_code += "float __rand_from_seed(inout uint seed) {\n"; global_compute_code += " int k;\n"; @@ -2504,7 +2504,7 @@ void VisualShader::_update_shader() const { final_code += global_compute_code; final_code += global_code_per_node; final_code += global_expressions; - String tcode = code; + String tcode = shader_code; for (int i = 0; i < TYPE_MAX; i++) { if (!has_func_name(RenderingServer::ShaderMode(shader_mode), func_name[i])) { continue; @@ -3648,12 +3648,12 @@ String VisualShaderNodeOutput::get_output_port_name(int p_port) const { bool VisualShaderNodeOutput::is_port_separator(int p_index) const { if (shader_mode == Shader::MODE_SPATIAL && shader_type == VisualShader::TYPE_VERTEX) { - String name = get_input_port_name(p_index); - return bool(name == "Model View Matrix"); + String port_name = get_input_port_name(p_index); + return bool(port_name == "Model View Matrix"); } if (shader_mode == Shader::MODE_SPATIAL && shader_type == VisualShader::TYPE_FRAGMENT) { - String name = get_input_port_name(p_index); - return bool(name == "AO" || name == "Normal" || name == "Rim" || name == "Clearcoat" || name == "Anisotropy" || name == "Subsurf Scatter" || name == "Alpha Scissor Threshold"); + String port_name = get_input_port_name(p_index); + return bool(port_name == "AO" || port_name == "Normal" || port_name == "Rim" || port_name == "Clearcoat" || port_name == "Anisotropy" || port_name == "Subsurf Scatter" || port_name == "Alpha Scissor Threshold"); } return false; } @@ -3666,15 +3666,15 @@ String VisualShaderNodeOutput::generate_code(Shader::Mode p_mode, VisualShader:: int idx = 0; int count = 0; - String code; + String shader_code; while (ports[idx].mode != Shader::MODE_MAX) { if (ports[idx].mode == shader_mode && ports[idx].shader_type == shader_type) { if (!p_input_vars[count].is_empty()) { String s = ports[idx].string; if (s.contains(":")) { - code += " " + s.get_slicec(':', 0) + " = " + p_input_vars[count] + "." + s.get_slicec(':', 1) + ";\n"; + shader_code += " " + s.get_slicec(':', 0) + " = " + p_input_vars[count] + "." + s.get_slicec(':', 1) + ";\n"; } else { - code += " " + s + " = " + p_input_vars[count] + ";\n"; + shader_code += " " + s + " = " + p_input_vars[count] + ";\n"; } } count++; @@ -3682,7 +3682,7 @@ String VisualShaderNodeOutput::generate_code(Shader::Mode p_mode, VisualShader:: idx++; } - return code; + return shader_code; } VisualShaderNodeOutput::VisualShaderNodeOutput() { diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h index 3aba550f03..5ed5f22cd0 100644 --- a/scene/resources/visual_shader.h +++ b/scene/resources/visual_shader.h @@ -156,7 +156,7 @@ private: } }; - Error _write_node(Type p_type, StringBuilder *global_code, StringBuilder *global_code_per_node, HashMap<Type, StringBuilder> *global_code_per_func, StringBuilder &code, Vector<DefaultTextureParam> &def_tex_params, const VMap<ConnectionKey, const List<Connection>::Element *> &input_connections, const VMap<ConnectionKey, const List<Connection>::Element *> &output_connections, int node, HashSet<int> &processed, bool for_preview, HashSet<StringName> &r_classes) const; + Error _write_node(Type p_type, StringBuilder *p_global_code, StringBuilder *p_global_code_per_node, HashMap<Type, StringBuilder> *p_global_code_per_func, StringBuilder &r_code, Vector<DefaultTextureParam> &r_def_tex_params, const VMap<ConnectionKey, const List<Connection>::Element *> &p_input_connections, const VMap<ConnectionKey, const List<Connection>::Element *> &p_output_connections, int p_node, HashSet<int> &r_processed, bool p_for_preview, HashSet<StringName> &r_classes) const; void _input_type_changed(Type p_type, int p_id); bool has_func_name(RenderingServer::ShaderMode p_mode, const String &p_func_name) const; diff --git a/scene/resources/visual_shader_particle_nodes.cpp b/scene/resources/visual_shader_particle_nodes.cpp index df6abe161e..ab7354f6e7 100644 --- a/scene/resources/visual_shader_particle_nodes.cpp +++ b/scene/resources/visual_shader_particle_nodes.cpp @@ -1291,12 +1291,12 @@ String VisualShaderNodeParticleOutput::get_input_port_name(int p_port) const { bool VisualShaderNodeParticleOutput::is_port_separator(int p_index) const { if (shader_type == VisualShader::TYPE_START || shader_type == VisualShader::TYPE_PROCESS) { - String name = get_input_port_name(p_index); - return bool(name == "Scale"); + String port_name = get_input_port_name(p_index); + return bool(port_name == "Scale"); } if (shader_type == VisualShader::TYPE_START_CUSTOM || shader_type == VisualShader::TYPE_PROCESS_CUSTOM) { - String name = get_input_port_name(p_index); - return bool(name == "Velocity"); + String port_name = get_input_port_name(p_index); + return bool(port_name == "Velocity"); } return false; } @@ -1604,24 +1604,24 @@ String VisualShaderNodeParticleEmit::generate_code(Shader::Mode p_mode, VisualSh flags_arr.push_back("FLAG_EMIT_CUSTOM"); } - String flags; + String flags_str; for (int i = 0; i < flags_arr.size(); i++) { if (i > 0) { - flags += "|"; + flags_str += "|"; } - flags += flags_arr[i]; + flags_str += flags_arr[i]; } - if (flags.is_empty()) { - flags = "uint(0)"; + if (flags_str.is_empty()) { + flags_str = "uint(0)"; } if (!default_condition) { code += " if (" + p_input_vars[0] + ") {\n"; } - code += tab + "emit_subparticle(" + transform + ", " + velocity + ", vec4(" + color + ", " + alpha + "), vec4(" + custom + ", " + custom_alpha + "), " + flags + ");\n"; + code += tab + "emit_subparticle(" + transform + ", " + velocity + ", vec4(" + color + ", " + alpha + "), vec4(" + custom + ", " + custom_alpha + "), " + flags_str + ");\n"; if (!default_condition) { code += " }\n"; |