diff options
author | qarmin <mikrutrafal54@gmail.com> | 2019-06-26 15:08:25 +0200 |
---|---|---|
committer | qarmin <mikrutrafal54@gmail.com> | 2019-06-26 15:08:25 +0200 |
commit | 4e5310cc60dc17e5ef09e57115ca8236544679e4 (patch) | |
tree | 894c5070a709198ed994db7c7d0c0e124abbc9e5 /scene | |
parent | 5c66771e3ebccdfec55bb94ea521d2f24cb6200a (diff) |
Some code changed with Clang-Tidy
Diffstat (limited to 'scene')
35 files changed, 167 insertions, 228 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 5bf70e12b7..b7ace804ef 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -69,10 +69,7 @@ bool AnimatedSprite::_edit_use_rect() const { Ref<Texture> t; if (animation) t = frames->get_frame(animation, frame); - if (t.is_null()) - return false; - - return true; + return t.is_valid(); } Rect2 AnimatedSprite::get_anchorable_rect() const { diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 73f583111b..932af469d0 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -457,8 +457,8 @@ void AudioStreamPlayer2D::set_stream_paused(bool p_pause) { if (p_pause != stream_paused) { stream_paused = p_pause; - stream_paused_fade_in = p_pause ? false : true; - stream_paused_fade_out = p_pause ? true : false; + stream_paused_fade_in = !p_pause; + stream_paused_fade_out = p_pause; } } diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 1f585d84ce..2604eb04e4 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -143,7 +143,7 @@ public: void set_particles_anim_v_frames(int p_frames); int get_particles_anim_v_frames() const; - void set_particles_anim_loop(bool p_frames); + void set_particles_anim_loop(bool p_loop); bool get_particles_anim_loop() const; static void init_shaders(); diff --git a/scene/2d/cpu_particles_2d.h b/scene/2d/cpu_particles_2d.h index 6c83abb311..813f5ddc6e 100644 --- a/scene/2d/cpu_particles_2d.h +++ b/scene/2d/cpu_particles_2d.h @@ -252,7 +252,7 @@ public: void set_color(const Color &p_color); Color get_color() const; - void set_color_ramp(const Ref<Gradient> &p_texture); + void set_color_ramp(const Ref<Gradient> &p_ramp); Ref<Gradient> get_color_ramp() const; void set_particle_flag(Flags p_flag, bool p_enable); diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 5ba184b324..4488dc501c 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -38,8 +38,7 @@ VARIANT_ENUM_CAST(Line2D::LineJointMode) VARIANT_ENUM_CAST(Line2D::LineCapMode) VARIANT_ENUM_CAST(Line2D::LineTextureMode) -Line2D::Line2D() : - Node2D() { +Line2D::Line2D() { _joint_mode = LINE_JOINT_SHARP; _begin_cap_mode = LINE_CAP_NONE; _end_cap_mode = LINE_CAP_NONE; diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 89dd1e5341..66e5ce250f 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -157,8 +157,8 @@ private: bool operator<(const ShapePair &p_sp) const { if (body_shape == p_sp.body_shape) return local_shape < p_sp.local_shape; - else - return body_shape < p_sp.body_shape; + + return body_shape < p_sp.body_shape; } ShapePair() {} diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index a8c7622828..6626fccf1c 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -63,10 +63,7 @@ Rect2 Sprite::_edit_get_rect() const { } bool Sprite::_edit_use_rect() const { - if (texture.is_null()) - return false; - - return true; + return texture.is_valid(); } Rect2 Sprite::get_anchorable_rect() const { diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index ff8c218575..ff28f60d4f 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -93,7 +93,7 @@ void AudioStreamPlayer3D::_mix_audio() { } bool interpolate_filter = !started; - ; + if (!found) { //create new if was not used before if (prev_output_count < MAX_OUTPUTS) { @@ -872,8 +872,8 @@ void AudioStreamPlayer3D::set_stream_paused(bool p_pause) { if (p_pause != stream_paused) { stream_paused = p_pause; - stream_paused_fade_in = stream_paused ? false : true; - stream_paused_fade_out = stream_paused ? true : false; + stream_paused_fade_in = !stream_paused; + stream_paused_fade_out = stream_paused; } } diff --git a/scene/3d/camera.h b/scene/3d/camera.h index c0a4f77435..6460f17e85 100644 --- a/scene/3d/camera.h +++ b/scene/3d/camera.h @@ -113,7 +113,7 @@ public: void set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far); void set_orthogonal(float p_size, float p_z_near, float p_z_far); - void set_frustum(float p_size, Vector2 p_offset, float p_near, float p_far); + void set_frustum(float p_size, Vector2 p_offset, float p_z_near, float p_z_far); void set_projection(Camera::Projection p_mode); void make_current(); diff --git a/scene/3d/cpu_particles.h b/scene/3d/cpu_particles.h index 6f267102fa..6566792def 100644 --- a/scene/3d/cpu_particles.h +++ b/scene/3d/cpu_particles.h @@ -249,7 +249,7 @@ public: void set_color(const Color &p_color); Color get_color() const; - void set_color_ramp(const Ref<Gradient> &p_texture); + void set_color_ramp(const Ref<Gradient> &p_ramp); Ref<Gradient> get_color_ramp() const; void set_particle_flag(Flags p_flag, bool p_enable); diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body.cpp index 909d4fda34..a9d96292a1 100644 --- a/scene/3d/soft_body.cpp +++ b/scene/3d/soft_body.cpp @@ -699,7 +699,6 @@ bool SoftBody::is_ray_pickable() const { } SoftBody::SoftBody() : - MeshInstance(), physics_rid(PhysicsServer::get_singleton()->soft_body_create()), mesh_owner(false), collision_mask(1), diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index 32b8219ee0..71136fc0f6 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -723,7 +723,7 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) { real_t rollingFriction = 0.f; if (wheelInfo.m_raycastInfo.m_isInContact) { - if (engine_force != 0.f && wheelInfo.engine_traction != false) { + if (engine_force != 0.f && wheelInfo.engine_traction) { rollingFriction = -engine_force * s->get_step(); } else { real_t defaultRollingFrictionImpulse = 0.f; @@ -928,8 +928,7 @@ void VehicleBody::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "steering", PROPERTY_HINT_RANGE, "-180,180.0,0.01"), "set_steering", "get_steering"); } -VehicleBody::VehicleBody() : - RigidBody() { +VehicleBody::VehicleBody() { m_pitchControl = 0; m_currentVehicleSpeedKmHour = real_t(0.); diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp index 75b419ca58..5fa8c43f9f 100644 --- a/scene/3d/voxel_light_baker.cpp +++ b/scene/3d/voxel_light_baker.cpp @@ -212,9 +212,7 @@ static bool fast_tri_box_overlap(const Vector3 &boxcenter, const Vector3 boxhalf /* compute plane equation of triangle: normal*x+d=0 */ normal = e0.cross(e1); d = -normal.dot(v0); /* plane eq: normal.x+d=0 */ - if (!planeBoxOverlap(normal, d, boxhalfsize)) return false; - - return true; /* box and triangle overlaps */ + return planeBoxOverlap(normal, d, boxhalfsize); /* if true, box and triangle overlaps */ } static _FORCE_INLINE_ void get_uv_and_normal(const Vector3 &p_pos, const Vector3 *p_vtx, const Vector2 *p_uv, const Vector3 *p_normal, Vector2 &r_uv, Vector3 &r_normal) { diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index a2411743d4..f1ce948c43 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -178,11 +178,11 @@ float AnimationNodeStateMachinePlayback::get_current_length() const { return len_current; } -bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *sm, const StringName &p_travel) { +bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_state_machine, const StringName &p_travel) { ERR_FAIL_COND_V(!playing, false); - ERR_FAIL_COND_V(!sm->states.has(p_travel), false); - ERR_FAIL_COND_V(!sm->states.has(current), false); + ERR_FAIL_COND_V(!p_state_machine->states.has(p_travel), false); + ERR_FAIL_COND_V(!p_state_machine->states.has(current), false); path.clear(); //a new one will be needed @@ -191,25 +191,25 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *sm, c loops_current = 0; // reset loops, so fade does not happen immediately - Vector2 current_pos = sm->states[current].position; - Vector2 target_pos = sm->states[p_travel].position; + Vector2 current_pos = p_state_machine->states[current].position; + Vector2 target_pos = p_state_machine->states[p_travel].position; Map<StringName, AStarCost> cost_map; List<int> open_list; //build open list - for (int i = 0; i < sm->transitions.size(); i++) { - if (sm->transitions[i].from == current) { + for (int i = 0; i < p_state_machine->transitions.size(); i++) { + if (p_state_machine->transitions[i].from == current) { open_list.push_back(i); - float cost = sm->states[sm->transitions[i].to].position.distance_to(current_pos); - cost *= sm->transitions[i].transition->get_priority(); + float cost = p_state_machine->states[p_state_machine->transitions[i].to].position.distance_to(current_pos); + cost *= p_state_machine->transitions[i].transition->get_priority(); AStarCost ap; ap.prev = current; ap.distance = cost; - cost_map[sm->transitions[i].to] = ap; + cost_map[p_state_machine->transitions[i].to] = ap; - if (sm->transitions[i].to == p_travel) { //prematurely found it! :D + if (p_state_machine->transitions[i].to == p_travel) { //prematurely found it! :D path.push_back(p_travel); return true; } @@ -230,42 +230,42 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *sm, c for (List<int>::Element *E = open_list.front(); E; E = E->next()) { - float cost = cost_map[sm->transitions[E->get()].to].distance; - cost += sm->states[sm->transitions[E->get()].to].position.distance_to(target_pos); + float cost = cost_map[p_state_machine->transitions[E->get()].to].distance; + cost += p_state_machine->states[p_state_machine->transitions[E->get()].to].position.distance_to(target_pos); if (cost < least_cost) { least_cost_transition = E; } } - StringName transition_prev = sm->transitions[least_cost_transition->get()].from; - StringName transition = sm->transitions[least_cost_transition->get()].to; + StringName transition_prev = p_state_machine->transitions[least_cost_transition->get()].from; + StringName transition = p_state_machine->transitions[least_cost_transition->get()].to; - for (int i = 0; i < sm->transitions.size(); i++) { - if (sm->transitions[i].from != transition || sm->transitions[i].to == transition_prev) { + for (int i = 0; i < p_state_machine->transitions.size(); i++) { + if (p_state_machine->transitions[i].from != transition || p_state_machine->transitions[i].to == transition_prev) { continue; //not interested on those } - float distance = sm->states[sm->transitions[i].from].position.distance_to(sm->states[sm->transitions[i].to].position); - distance *= sm->transitions[i].transition->get_priority(); - distance += cost_map[sm->transitions[i].from].distance; + float distance = p_state_machine->states[p_state_machine->transitions[i].from].position.distance_to(p_state_machine->states[p_state_machine->transitions[i].to].position); + distance *= p_state_machine->transitions[i].transition->get_priority(); + distance += cost_map[p_state_machine->transitions[i].from].distance; - if (cost_map.has(sm->transitions[i].to)) { + if (cost_map.has(p_state_machine->transitions[i].to)) { //oh this was visited already, can we win the cost? - if (distance < cost_map[sm->transitions[i].to].distance) { - cost_map[sm->transitions[i].to].distance = distance; - cost_map[sm->transitions[i].to].prev = sm->transitions[i].from; + if (distance < cost_map[p_state_machine->transitions[i].to].distance) { + cost_map[p_state_machine->transitions[i].to].distance = distance; + cost_map[p_state_machine->transitions[i].to].prev = p_state_machine->transitions[i].from; } } else { //add to open list AStarCost ac; - ac.prev = sm->transitions[i].from; + ac.prev = p_state_machine->transitions[i].from; ac.distance = distance; - cost_map[sm->transitions[i].to] = ac; + cost_map[p_state_machine->transitions[i].to] = ac; open_list.push_back(i); - if (sm->transitions[i].to == p_travel) { + if (p_state_machine->transitions[i].to == p_travel) { found_route = true; break; } @@ -291,12 +291,12 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *sm, c return true; } -float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm, float p_time, bool p_seek) { +float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_state_machine, float p_time, bool p_seek) { //if not playing and it can restart, then restart if (!playing && start_request == StringName()) { - if (!stop_request && sm->start_node) { - start(sm->start_node); + if (!stop_request && p_state_machine->start_node) { + start(p_state_machine->start_node); } else { return 0; } @@ -320,7 +320,7 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm, ERR_FAIL_V(0); } - if (!_travel(sm, start_request)) { + if (!_travel(p_state_machine, start_request)) { //can't travel, then teleport path.clear(); current = start_request; @@ -339,16 +339,16 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm, if (do_start) { - if (sm->start_node != StringName() && p_seek && p_time == 0) { - current = sm->start_node; + if (p_state_machine->start_node != StringName() && p_seek && p_time == 0) { + current = p_state_machine->start_node; } - len_current = sm->blend_node(current, sm->states[current].node, 0, true, 1.0, AnimationNode::FILTER_IGNORE, false); + len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, 1.0, AnimationNode::FILTER_IGNORE, false); pos_current = 0; loops_current = 0; } - if (!sm->states.has(current)) { + if (!p_state_machine->states.has(current)) { playing = false; //current does not exist current = StringName(); return 0; @@ -357,7 +357,7 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm, if (fading_from != StringName()) { - if (!sm->states.has(fading_from)) { + if (!p_state_machine->states.has(fading_from)) { fading_from = StringName(); } else { if (!p_seek) { @@ -370,11 +370,11 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm, } } - float rem = sm->blend_node(current, sm->states[current].node, p_time, p_seek, fade_blend, AnimationNode::FILTER_IGNORE, false); + float rem = p_state_machine->blend_node(current, p_state_machine->states[current].node, p_time, p_seek, fade_blend, AnimationNode::FILTER_IGNORE, false); if (fading_from != StringName()) { - sm->blend_node(fading_from, sm->states[fading_from].node, p_time, p_seek, 1.0 - fade_blend, AnimationNode::FILTER_IGNORE, false); + p_state_machine->blend_node(fading_from, p_state_machine->states[fading_from].node, p_time, p_seek, 1.0 - fade_blend, AnimationNode::FILTER_IGNORE, false); } //guess playback position @@ -399,40 +399,40 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm, if (path.size()) { - for (int i = 0; i < sm->transitions.size(); i++) { - if (sm->transitions[i].from == current && sm->transitions[i].to == path[0]) { - next_xfade = sm->transitions[i].transition->get_xfade_time(); - switch_mode = sm->transitions[i].transition->get_switch_mode(); + for (int i = 0; i < p_state_machine->transitions.size(); i++) { + if (p_state_machine->transitions[i].from == current && p_state_machine->transitions[i].to == path[0]) { + next_xfade = p_state_machine->transitions[i].transition->get_xfade_time(); + switch_mode = p_state_machine->transitions[i].transition->get_switch_mode(); next = path[0]; } } } else { float priority_best = 1e20; int auto_advance_to = -1; - for (int i = 0; i < sm->transitions.size(); i++) { + for (int i = 0; i < p_state_machine->transitions.size(); i++) { bool auto_advance = false; - if (sm->transitions[i].transition->has_auto_advance()) { + if (p_state_machine->transitions[i].transition->has_auto_advance()) { auto_advance = true; } - StringName advance_condition_name = sm->transitions[i].transition->get_advance_condition_name(); - if (advance_condition_name != StringName() && bool(sm->get_parameter(advance_condition_name))) { + StringName advance_condition_name = p_state_machine->transitions[i].transition->get_advance_condition_name(); + if (advance_condition_name != StringName() && bool(p_state_machine->get_parameter(advance_condition_name))) { auto_advance = true; } - if (sm->transitions[i].from == current && auto_advance) { + if (p_state_machine->transitions[i].from == current && auto_advance) { - if (sm->transitions[i].transition->get_priority() <= priority_best) { - priority_best = sm->transitions[i].transition->get_priority(); + if (p_state_machine->transitions[i].transition->get_priority() <= priority_best) { + priority_best = p_state_machine->transitions[i].transition->get_priority(); auto_advance_to = i; } } } if (auto_advance_to != -1) { - next = sm->transitions[auto_advance_to].to; - next_xfade = sm->transitions[auto_advance_to].transition->get_xfade_time(); - switch_mode = sm->transitions[auto_advance_to].transition->get_switch_mode(); + next = p_state_machine->transitions[auto_advance_to].to; + next_xfade = p_state_machine->transitions[auto_advance_to].transition->get_xfade_time(); + switch_mode = p_state_machine->transitions[auto_advance_to].transition->get_switch_mode(); } } @@ -467,12 +467,12 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm, } current = next; if (switch_mode == AnimationNodeStateMachineTransition::SWITCH_MODE_SYNC) { - len_current = sm->blend_node(current, sm->states[current].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false); + len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false); pos_current = MIN(pos_current, len_current); - sm->blend_node(current, sm->states[current].node, pos_current, true, 0, AnimationNode::FILTER_IGNORE, false); + p_state_machine->blend_node(current, p_state_machine->states[current].node, pos_current, true, 0, AnimationNode::FILTER_IGNORE, false); } else { - len_current = sm->blend_node(current, sm->states[current].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false); + len_current = p_state_machine->blend_node(current, p_state_machine->states[current].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false); pos_current = 0; } @@ -482,9 +482,9 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *sm, } //compute time left for transitions by using the end node - if (sm->end_node != StringName() && sm->end_node != current) { + if (p_state_machine->end_node != StringName() && p_state_machine->end_node != current) { - rem = sm->blend_node(sm->end_node, sm->states[sm->end_node].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false); + rem = p_state_machine->blend_node(p_state_machine->end_node, p_state_machine->states[p_state_machine->end_node].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false); } return rem; diff --git a/scene/animation/root_motion_view.h b/scene/animation/root_motion_view.h index 07f51165a7..b30b06229e 100644 --- a/scene/animation/root_motion_view.h +++ b/scene/animation/root_motion_view.h @@ -56,7 +56,7 @@ public: void set_animation_path(const NodePath &p_path); NodePath get_animation_path() const; - void set_color(const Color &p_path); + void set_color(const Color &p_color); Color get_color() const; void set_cell_size(float p_size); diff --git a/scene/animation/skeleton_ik.cpp b/scene/animation/skeleton_ik.cpp index 06d6806f03..43c4b2aa51 100644 --- a/scene/animation/skeleton_ik.cpp +++ b/scene/animation/skeleton_ik.cpp @@ -423,7 +423,6 @@ void SkeletonIK::_notification(int p_what) { } SkeletonIK::SkeletonIK() : - Node(), interpolation(1), override_tip_basis(true), use_magnet(false), diff --git a/scene/animation/skeleton_ik.h b/scene/animation/skeleton_ik.h index 5d48b7be33..d2c5f56ace 100644 --- a/scene/animation/skeleton_ik.h +++ b/scene/animation/skeleton_ik.h @@ -165,7 +165,7 @@ protected: _validate_property(PropertyInfo &property) const; static void _bind_methods(); - virtual void _notification(int p_notification); + virtual void _notification(int p_what); public: SkeletonIK(); @@ -192,7 +192,7 @@ public: void set_use_magnet(bool p_use); bool is_using_magnet() const; - void set_magnet_position(const Vector3 &p_constraint); + void set_magnet_position(const Vector3 &p_local_position); const Vector3 &get_magnet_position() const; void set_min_distance(real_t p_min_distance); diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index c70e58564f..4dee4e1d12 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -583,9 +583,7 @@ bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) { } // Did we get an error from the function call? - if (error.error == Variant::CallError::CALL_OK) - return true; - return false; + return error.error == Variant::CallError::CALL_OK; } case INTER_CALLBACK: diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index 2def9fe8fc..c053fceb74 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -339,7 +339,7 @@ void AudioStreamPlayer::set_stream_paused(bool p_pause) { if (p_pause != stream_paused) { stream_paused = p_pause; - stream_paused_fade = p_pause ? true : false; + stream_paused_fade = p_pause; } } diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index cc37d4cf7d..b7d2131ee9 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -91,7 +91,6 @@ void BoxContainer::_resort() { int stretch_diff = stretch_max - stretch_min; if (stretch_diff < 0) { //avoid negative stretch space - stretch_max = stretch_min; stretch_diff = 0; } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 0845b56828..6e0e26312f 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1042,55 +1042,37 @@ int Control::get_constant(const StringName &p_name, const StringName &p_type) co bool Control::has_icon_override(const StringName &p_name) const { const Ref<Texture> *tex = data.icon_override.getptr(p_name); - if (tex) - return true; - else - return false; + return tex != NULL; } bool Control::has_shader_override(const StringName &p_name) const { const Ref<Shader> *sdr = data.shader_override.getptr(p_name); - if (sdr) - return true; - else - return false; + return sdr != NULL; } bool Control::has_stylebox_override(const StringName &p_name) const { const Ref<StyleBox> *style = data.style_override.getptr(p_name); - if (style) - return true; - else - return false; + return style != NULL; } bool Control::has_font_override(const StringName &p_name) const { const Ref<Font> *font = data.font_override.getptr(p_name); - if (font) - return true; - else - return false; + return font != NULL; } bool Control::has_color_override(const StringName &p_name) const { const Color *color = data.color_override.getptr(p_name); - if (color) - return true; - else - return false; + return color != NULL; } bool Control::has_constant_override(const StringName &p_name) const { const int *constant = data.constant_override.getptr(p_name); - if (constant) - return true; - else - return false; + return constant != NULL; } bool Control::has_icon(const StringName &p_name, const StringName &p_type) const { @@ -1997,10 +1979,7 @@ Control *Control::find_next_valid_focus() const { break; } - if (next_child) { - - from = next_child; - } else { + if (!next_child) { next_child = _next_control(from); if (!next_child) { //nothing else.. go up and find either window or subwindow diff --git a/scene/gui/control.h b/scene/gui/control.h index a6f9a442ae..2489a5eda4 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -139,8 +139,8 @@ private: bool operator()(const Control *p_a, const Control *p_b) const { if (p_a->get_canvas_layer() == p_b->get_canvas_layer()) return p_b->is_greater_than(p_a); - else - return p_a->get_canvas_layer() < p_b->get_canvas_layer(); + + return p_a->get_canvas_layer() < p_b->get_canvas_layer(); } }; diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index bc8dcf0e82..ba4d390fc5 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -302,11 +302,8 @@ bool FileDialog::_is_open_should_be_disabled() { Dictionary d = ti->get_metadata(0); // Opening a file, but selected a folder? Forbidden. - if (((mode == MODE_OPEN_FILE || mode == MODE_OPEN_FILES) && d["dir"]) || // Flipped case, also forbidden. - (mode == MODE_OPEN_DIR && !d["dir"])) - return true; - - return false; + return ((mode == MODE_OPEN_FILE || mode == MODE_OPEN_FILES) && d["dir"]) || // Flipped case, also forbidden. + (mode == MODE_OPEN_DIR && !d["dir"]); } void FileDialog::_go_up() { diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index e3e9368a12..e18387a52e 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -470,7 +470,6 @@ void Label::regenerate_word_cache() { wc->word_len = i - word_pos; wc->space_count = space_count; current_word_size = char_width; - space_count = 0; word_pos = i; } } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index da6bff8ab8..cd3c8c0097 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -623,10 +623,7 @@ bool LineEdit::_is_over_clear_button(const Point2 &p_pos) const { } Ref<Texture> icon = Control::get_icon("clear"); int x_ofs = get_stylebox("normal")->get_offset().x; - if (p_pos.x > get_size().width - icon->get_width() - x_ofs) { - return true; - } - return false; + return p_pos.x > get_size().width - icon->get_width() - x_ofs; } void LineEdit::_notification(int p_what) { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 8891f679ee..134bcc91a8 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -447,14 +447,13 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & if (p_font_color_shadow.a > 0) { float x_ofs_shadow = align_ofs + pofs; float y_ofs_shadow = y + lh - line_descent; - float move = font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + shadow_ofs, c[i], c[i + 1], p_font_color_shadow); + font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + shadow_ofs, c[i], c[i + 1], p_font_color_shadow); if (p_shadow_as_outline) { font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + Vector2(-shadow_ofs.x, shadow_ofs.y), c[i], c[i + 1], p_font_color_shadow); font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + Vector2(shadow_ofs.x, -shadow_ofs.y), c[i], c[i + 1], p_font_color_shadow); font->draw_char(ci, Point2(x_ofs_shadow, y_ofs_shadow) + Vector2(-shadow_ofs.x, -shadow_ofs.y), c[i], c[i + 1], p_font_color_shadow); } - x_ofs_shadow += move; } if (selected) { @@ -935,84 +934,80 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { return; if (b->get_button_index() == BUTTON_LEFT) { + if (b->is_pressed() && !b->is_doubleclick()) { + scroll_updated = false; + int line = 0; + Item *item = NULL; - if (true) { + bool outside; + _find_click(main, b->get_position(), &item, &line, &outside); - if (b->is_pressed() && !b->is_doubleclick()) { - scroll_updated = false; - int line = 0; - Item *item = NULL; - - bool outside; - _find_click(main, b->get_position(), &item, &line, &outside); - - if (item) { + if (item) { - if (selection.enabled) { + if (selection.enabled) { - selection.click = item; - selection.click_char = line; + selection.click = item; + selection.click_char = line; - // Erase previous selection. - if (selection.active) { - selection.from = NULL; - selection.from_char = '\0'; - selection.to = NULL; - selection.to_char = '\0'; - selection.active = false; + // Erase previous selection. + if (selection.active) { + selection.from = NULL; + selection.from_char = '\0'; + selection.to = NULL; + selection.to_char = '\0'; + selection.active = false; - update(); - } + update(); } } - } else if (b->is_pressed() && b->is_doubleclick() && selection.enabled) { + } + } else if (b->is_pressed() && b->is_doubleclick() && selection.enabled) { - //doubleclick: select word - int line = 0; - Item *item = NULL; - bool outside; + //doubleclick: select word + int line = 0; + Item *item = NULL; + bool outside; - _find_click(main, b->get_position(), &item, &line, &outside); + _find_click(main, b->get_position(), &item, &line, &outside); - while (item && item->type != ITEM_TEXT) { + while (item && item->type != ITEM_TEXT) { - item = _get_next_item(item, true); - } + item = _get_next_item(item, true); + } - if (item && item->type == ITEM_TEXT) { + if (item && item->type == ITEM_TEXT) { - String itext = static_cast<ItemText *>(item)->text; + String itext = static_cast<ItemText *>(item)->text; - int beg, end; - if (select_word(itext, line, beg, end)) { + int beg, end; + if (select_word(itext, line, beg, end)) { - selection.from = item; - selection.to = item; - selection.from_char = beg; - selection.to_char = end - 1; - selection.active = true; - update(); - } + selection.from = item; + selection.to = item; + selection.from_char = beg; + selection.to_char = end - 1; + selection.active = true; + update(); } - } else if (!b->is_pressed()) { + } + } else if (!b->is_pressed()) { - selection.click = NULL; + selection.click = NULL; - if (!b->is_doubleclick() && !scroll_updated) { - int line = 0; - Item *item = NULL; + if (!b->is_doubleclick() && !scroll_updated) { + int line = 0; + Item *item = NULL; - bool outside; - _find_click(main, b->get_position(), &item, &line, &outside); + bool outside; + _find_click(main, b->get_position(), &item, &line, &outside); - if (item) { + if (item) { - Variant meta; - if (!outside && _find_meta(item, &meta)) { - //meta clicked + Variant meta; + if (!outside && _find_meta(item, &meta)) { + //meta clicked - emit_signal("meta_clicked", meta); - } + emit_signal("meta_clicked", meta); } } } diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index a1034937b5..d83ae47671 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -140,19 +140,17 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { _cancel_drag(); } - if (true) { - drag_speed = Vector2(); - drag_accum = Vector2(); - last_drag_accum = Vector2(); - drag_from = Vector2(h_scroll->get_value(), v_scroll->get_value()); - drag_touching = OS::get_singleton()->has_touchscreen_ui_hint(); - drag_touching_deaccel = false; - beyond_deadzone = false; + drag_speed = Vector2(); + drag_accum = Vector2(); + last_drag_accum = Vector2(); + drag_from = Vector2(h_scroll->get_value(), v_scroll->get_value()); + drag_touching = OS::get_singleton()->has_touchscreen_ui_hint(); + drag_touching_deaccel = false; + beyond_deadzone = false; + time_since_motion = 0; + if (drag_touching) { + set_physics_process_internal(true); time_since_motion = 0; - if (drag_touching) { - set_physics_process_internal(true); - time_since_motion = 0; - } } } else { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 36d7dad1d3..62b6a917fc 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1603,7 +1603,6 @@ void TextEdit::_consume_pair_symbol(CharType ch) { insert_text_at_cursor(ch_pair); cursor_set_column(cursor_position_to_move); - return; } void TextEdit::_consume_backspace_for_pair_symbol(int prev_line, int prev_column) { @@ -5404,11 +5403,7 @@ bool TextEdit::is_line_comment(int p_line) const { for (int i = 0; i < line_length - 1; i++) { if (_is_symbol(text[p_line][i]) && cri_map.has(i)) { const Text::ColorRegionInfo &cri = cri_map[i]; - if (color_regions[cri.region].begin_key == "#" || color_regions[cri.region].begin_key == "//") { - return true; - } else { - return false; - } + return color_regions[cri.region].begin_key == "#" || color_regions[cri.region].begin_key == "//"; } else if (_is_whitespace(text[p_line][i])) { continue; } else { @@ -5457,9 +5452,7 @@ bool TextEdit::is_folded(int p_line) const { ERR_FAIL_INDEX_V(p_line, text.size(), false); if (p_line + 1 >= text.size()) return false; - if (!is_line_hidden(p_line) && is_line_hidden(p_line + 1)) - return true; - return false; + return !is_line_hidden(p_line) && is_line_hidden(p_line + 1); } Vector<int> TextEdit::get_folded_lines() const { diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 54370d02ba..924c480b15 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1929,8 +1929,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool edited_col = col; bool on_arrow = x > col_width - cache.select_arrow->get_width(); - bring_up_editor = false; - custom_popup_rect = Rect2i(get_global_position() + Point2i(col_ofs, _get_title_button_height() + y_ofs + item_h - cache.offset.y), Size2(get_column_width(col), item_h)); if (on_arrow || !p_item->cells[col].custom_button) { diff --git a/scene/main/node.cpp b/scene/main/node.cpp index ee23b24b3c..715151b4f5 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1393,7 +1393,7 @@ Node *Node::get_node(const NodePath &p_path) const { Node *node = get_node_or_null(p_path); if (!node) { ERR_EXPLAIN("Node not found: " + p_path); - ERR_FAIL_COND_V(!node, NULL); + ERR_FAIL_V(NULL); } return node; } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 10e5ad78e2..dcd70a1844 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -532,7 +532,7 @@ void Viewport::_notification(int p_what) { Map<ObjectID, uint64_t>::Element *F = physics_2d_mouseover.find(res[i].collider_id); if (!F) { - F = physics_2d_mouseover.insert(res[i].collider_id, frame); + physics_2d_mouseover.insert(res[i].collider_id, frame); co->_mouse_enter(); } else { F->get() = frame; diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp index 5d8adc0c8d..99a17fb5b9 100644 --- a/scene/resources/multimesh.cpp +++ b/scene/resources/multimesh.cpp @@ -35,7 +35,7 @@ void MultiMesh::_set_transform_array(const PoolVector<Vector3> &p_array) { if (transform_format != TRANSFORM_3D) return; - PoolVector<Vector3> xforms = p_array; + const PoolVector<Vector3> &xforms = p_array; int len = xforms.size(); ERR_FAIL_COND((len / 4) != instance_count); if (len == 0) @@ -85,7 +85,7 @@ void MultiMesh::_set_transform_2d_array(const PoolVector<Vector2> &p_array) { if (transform_format != TRANSFORM_2D) return; - PoolVector<Vector2> xforms = p_array; + const PoolVector<Vector2> &xforms = p_array; int len = xforms.size(); ERR_FAIL_COND((len / 3) != instance_count); if (len == 0) @@ -130,7 +130,7 @@ PoolVector<Vector2> MultiMesh::_get_transform_2d_array() const { void MultiMesh::_set_color_array(const PoolVector<Color> &p_array) { - PoolVector<Color> colors = p_array; + const PoolVector<Color> &colors = p_array; int len = colors.size(); if (len == 0) return; @@ -162,7 +162,7 @@ PoolVector<Color> MultiMesh::_get_color_array() const { void MultiMesh::_set_custom_data_array(const PoolVector<Color> &p_array) { - PoolVector<Color> custom_datas = p_array; + const PoolVector<Color> &custom_datas = p_array; int len = custom_datas.size(); if (len == 0) return; diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 04d13c8869..74a493d3b5 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -743,8 +743,6 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const { int i, j, prevrow, thisrow, point; float x, y, z, u, v, radius; - radius = bottom_radius > top_radius ? bottom_radius : top_radius; - PoolVector<Vector3> points; PoolVector<Vector3> normals; PoolVector<float> tangents; diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index efc1082a6b..339f008a3d 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1324,7 +1324,7 @@ Error ResourceFormatLoaderText::convert_file_to_binary(const String &p_src_path, ERR_FAIL_COND_V(err != OK, ERR_CANT_OPEN); Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText); - String path = p_src_path; + const String &path = p_src_path; ria->local_path = ProjectSettings::get_singleton()->localize_path(path); ria->res_path = ria->local_path; //ria->set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) ); @@ -1441,7 +1441,7 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant, int len = varray.size(); for (int i = 0; i < len; i++) { - Variant v = varray.get(i); + const Variant &v = varray.get(i); _find_resources(v); } diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index df753276e4..ef64b50711 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -699,7 +699,7 @@ public: virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty - void set_function(Function p_op); + void set_function(Function p_func); Function get_function() const; virtual Vector<StringName> get_editable_properties() const; @@ -740,7 +740,7 @@ public: virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty - void set_function(Function p_op); + void set_function(Function p_func); Function get_function() const; virtual Vector<StringName> get_editable_properties() const; @@ -895,7 +895,7 @@ public: virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty - void set_function(Function p_op); + void set_function(Function p_func); Function get_function() const; virtual Vector<StringName> get_editable_properties() const; @@ -935,7 +935,7 @@ public: virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty - void set_function(Function p_op); + void set_function(Function p_func); Function get_function() const; virtual Vector<StringName> get_editable_properties() const; |