Skip to content

Commit

Permalink
Merge pull request #45845 from qarmin/cppcheck_scene_2
Browse files Browse the repository at this point in the history
Initialize class variables with default values in scene/ [2/2]
  • Loading branch information
akien-mga authored Feb 10, 2021
2 parents 3c39aa8 + 7961a1d commit e8f7312
Show file tree
Hide file tree
Showing 171 changed files with 1,022 additions and 1,904 deletions.
6 changes: 1 addition & 5 deletions editor/editor_feature_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,7 @@ void EditorFeatureProfile::_bind_methods() {
BIND_ENUM_CONSTANT(FEATURE_MAX);
}

EditorFeatureProfile::EditorFeatureProfile() {
for (int i = 0; i < FEATURE_MAX; i++) {
features_disabled[i] = false;
}
}
EditorFeatureProfile::EditorFeatureProfile() {}

//////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion scene/3d/vehicle_body_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class VehicleWheel3D : public Node3D {
Vector3 m_wheelDirectionWS; //direction in worldspace
Vector3 m_wheelAxleWS; // axle in worldspace
bool m_isInContact = false;
PhysicsBody3D *m_groundObject; //could be general void* ptr
PhysicsBody3D *m_groundObject = nullptr; //could be general void* ptr
} m_raycastInfo;

void _update(PhysicsDirectBodyState3D *s);
Expand Down
4 changes: 2 additions & 2 deletions scene/animation/animation_blend_space_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) {
Vector2 blend_pos = get_parameter(blend_position);
int closest = get_parameter(this->closest);
float length_internal = get_parameter(this->length_internal);
float mind = 0; //time of min distance point
float mind = 0.0; //time of min distance point

if (blend_mode == BLEND_MODE_INTERPOLATED) {
if (triangles.size() == 0) {
Expand Down Expand Up @@ -529,7 +529,7 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) {
}

if (new_closest != closest && new_closest != -1) {
float from = 0;
float from = 0.0;
if (blend_mode == BLEND_MODE_DISCRETE_CARRY && closest != -1) {
//see how much animation remains
from = blend_node(blend_points[closest].name, blend_points[closest].node, p_time, true, 0.0, FILTER_IGNORE, false) - length_internal;
Expand Down
2 changes: 1 addition & 1 deletion scene/animation/animation_blend_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ float AnimationNodeTransition::process(float p_time, bool p_seek) {
return 0;
}

float rem = 0;
float rem = 0.0;

if (prev < 0) { // process current animation, check for transition

Expand Down
2 changes: 1 addition & 1 deletion scene/animation/animation_node_state_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st

//find next
StringName next;
float next_xfade = 0;
float next_xfade = 0.0;
AnimationNodeStateMachineTransition::SwitchMode switch_mode = AnimationNodeStateMachineTransition::SWITCH_MODE_IMMEDIATE;

if (path.size()) {
Expand Down
2 changes: 1 addition & 1 deletion scene/animation/animation_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float
Playback &c = playback;

if (c.current.from) {
float blend_time = 0;
float blend_time = 0.0;
// find if it can blend
BlendKey bk;
bk.from = c.current.from->name;
Expand Down
2 changes: 1 addition & 1 deletion scene/animation/animation_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p
Ref<AnimationNode> node = blend_tree->get_node(node_name);

//inputs.write[p_input].last_pass = state->last_pass;
float activity = 0;
float activity = 0.0;
float ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), nullptr, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity);

Vector<AnimationTree::Activity> *activity_ptr = state->tree->input_activity_map.getptr(base_path);
Expand Down
4 changes: 2 additions & 2 deletions scene/animation/tween.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ void Tween::seek(real_t p_time) {
real_t Tween::tell() const {
// We want to grab the position of the furthest along tween
pending_update++;
real_t pos = 0;
real_t pos = 0.0;

// For each interpolation...
for (const List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
Expand All @@ -1122,7 +1122,7 @@ real_t Tween::get_runtime() const {
pending_update++;

// For each interpolation...
real_t runtime = 0;
real_t runtime = 0.0;
for (const List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
// Get the tween data and see if it's runtime is greater than the previous tweens
const InterpolateData &data = E->get();
Expand Down
11 changes: 0 additions & 11 deletions scene/gui/base_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,18 +448,7 @@ void BaseButton::_bind_methods() {
}

BaseButton::BaseButton() {
toggle_mode = false;
shortcut_in_tooltip = true;
keep_pressed_outside = false;
status.pressed = false;
status.press_attempt = false;
status.hovering = false;
status.pressing_inside = false;
status.disabled = false;
set_focus_mode(FOCUS_ALL);
action_mode = ACTION_MODE_BUTTON_RELEASE;
button_mask = BUTTON_MASK_LEFT;
shortcut_context = ObjectID();
}

BaseButton::~BaseButton() {
Expand Down
20 changes: 10 additions & 10 deletions scene/gui/base_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ class BaseButton : public Control {
};

private:
int button_mask;
bool toggle_mode;
bool shortcut_in_tooltip;
bool keep_pressed_outside;
int button_mask = BUTTON_MASK_LEFT;
bool toggle_mode = false;
bool shortcut_in_tooltip = true;
bool keep_pressed_outside = false;
Ref<Shortcut> shortcut;
ObjectID shortcut_context;

ActionMode action_mode;
ActionMode action_mode = ACTION_MODE_BUTTON_RELEASE;
struct Status {
bool pressed;
bool hovering;
bool press_attempt;
bool pressing_inside;
bool pressed = false;
bool hovering = false;
bool press_attempt = false;
bool pressing_inside = false;

bool disabled;
bool disabled = false;

} status;

Expand Down
11 changes: 5 additions & 6 deletions scene/gui/box_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
#include "margin_container.h"

struct _MinSizeCache {
int min_size;
bool will_stretch;
int final_size;
int min_size = 0;
bool will_stretch = false;
int final_size = 0;
};

void BoxContainer::_resort() {
Expand All @@ -50,7 +50,7 @@ void BoxContainer::_resort() {
int children_count = 0;
int stretch_min = 0;
int stretch_avail = 0;
float stretch_ratio_total = 0;
float stretch_ratio_total = 0.0;
Map<Control *, _MinSizeCache> min_size_cache;

for (int i = 0; i < get_child_count(); i++) {
Expand Down Expand Up @@ -105,7 +105,7 @@ void BoxContainer::_resort() {

has_stretched = true;
bool refit_successful = true; //assume refit-test will go well
float error = 0; // Keep track of accumulated error in pixels
float error = 0.0; // Keep track of accumulated error in pixels

for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
Expand Down Expand Up @@ -331,7 +331,6 @@ void BoxContainer::add_spacer(bool p_begin) {

BoxContainer::BoxContainer(bool p_vertical) {
vertical = p_vertical;
align = ALIGN_BEGIN;
}

void BoxContainer::_bind_methods() {
Expand Down
4 changes: 2 additions & 2 deletions scene/gui/box_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class BoxContainer : public Container {
};

private:
bool vertical;
AlignMode align;
bool vertical = false;
AlignMode align = ALIGN_BEGIN;

void _resort();

Expand Down
10 changes: 1 addition & 9 deletions scene/gui/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void Button::_notification(int p_what) {
color_icon.a = 0.4;
}

float icon_ofs_region = 0;
float icon_ofs_region = 0.0;
if (rtl) {
if (_internal_margin[SIDE_RIGHT] > 0) {
icon_ofs_region = _internal_margin[SIDE_RIGHT] + get_theme_constant("hseparation");
Expand Down Expand Up @@ -544,16 +544,8 @@ Button::Button(const String &p_text) {
text_buf.instance();
text_buf->set_flags(TextServer::BREAK_MANDATORY);

flat = false;
clip_text = false;
expand_icon = false;
set_mouse_filter(MOUSE_FILTER_STOP);
set_text(p_text);
align = ALIGN_CENTER;

for (int i = 0; i < 4; i++) {
_internal_margin[i] = 0;
}
}

Button::~Button() {
Expand Down
10 changes: 5 additions & 5 deletions scene/gui/button.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Button : public BaseButton {
};

private:
bool flat;
bool flat = false;
String text;
String xl_text;
Ref<TextParagraph> text_buf;
Expand All @@ -55,10 +55,10 @@ class Button : public BaseButton {
TextDirection text_direction = TEXT_DIRECTION_AUTO;

Ref<Texture2D> icon;
bool expand_icon;
bool clip_text;
TextAlign align;
float _internal_margin[4];
bool expand_icon = false;
bool clip_text = false;
TextAlign align = ALIGN_CENTER;
float _internal_margin[4] = {};

void _shape();

Expand Down
4 changes: 1 addition & 3 deletions scene/gui/center_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,4 @@ void CenterContainer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_top_left"), "set_use_top_left", "is_using_top_left");
}

CenterContainer::CenterContainer() {
use_top_left = false;
}
CenterContainer::CenterContainer() {}
2 changes: 1 addition & 1 deletion scene/gui/center_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
class CenterContainer : public Container {
GDCLASS(CenterContainer, Container);

bool use_top_left;
bool use_top_left = false;

protected:
void _notification(int p_what);
Expand Down
18 changes: 0 additions & 18 deletions scene/gui/color_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,17 +719,6 @@ void ColorPicker::_bind_methods() {

ColorPicker::ColorPicker() :
BoxContainer(true) {
updating = true;
edit_alpha = true;
text_is_constructor = false;
hsv_mode_enabled = false;
raw_mode_enabled = false;
deferred_mode_enabled = false;
changing_color = false;
presets_enabled = true;
presets_visible = true;
screen = nullptr;

HBoxContainer *hb_edit = memnew(HBoxContainer);
add_child(hb_edit);
hb_edit->set_v_size_flags(SIZE_EXPAND_FILL);
Expand Down Expand Up @@ -1002,12 +991,5 @@ void ColorPickerButton::_bind_methods() {
}

ColorPickerButton::ColorPickerButton() {
// Initialization is now done deferred,
// this improves performance in the inspector as the color picker
// can be expensive to initialize.
picker = nullptr;
popup = nullptr;
edit_alpha = true;

set_toggle_mode(true);
}
36 changes: 21 additions & 15 deletions scene/gui/color_picker.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ColorPicker : public BoxContainer {
GDCLASS(ColorPicker, BoxContainer);

private:
Control *screen;
Control *screen = nullptr;
Control *uv_edit;
Control *w_edit;
TextureRect *sample;
Expand All @@ -64,20 +64,22 @@ class ColorPicker : public BoxContainer {
Label *labels[4];
Button *text_type;
LineEdit *c_text;
bool edit_alpha;
bool edit_alpha = true;
Size2i ms;
bool text_is_constructor;
int presets_per_row;
bool text_is_constructor = false;
int presets_per_row = 0;

Color color;
bool raw_mode_enabled;
bool hsv_mode_enabled;
bool deferred_mode_enabled;
bool updating;
bool changing_color;
bool presets_enabled;
bool presets_visible;
float h, s, v;
bool raw_mode_enabled = false;
bool hsv_mode_enabled = false;
bool deferred_mode_enabled = false;
bool updating = true;
bool changing_color = false;
bool presets_enabled = true;
bool presets_visible = true;
float h = 0.0;
float s = 0.0;
float v = 0.0;
Color last_hsv;

void _html_entered(const String &p_html);
Expand Down Expand Up @@ -139,10 +141,14 @@ class ColorPicker : public BoxContainer {
class ColorPickerButton : public Button {
GDCLASS(ColorPickerButton, Button);

PopupPanel *popup;
ColorPicker *picker;
// Initialization is now done deferred,
// this improves performance in the inspector as the color picker
// can be expensive to initialize.

PopupPanel *popup = nullptr;
ColorPicker *picker = nullptr;
Color color;
bool edit_alpha;
bool edit_alpha = true;

void _color_changed(const Color &p_color);
void _modal_closed();
Expand Down
1 change: 0 additions & 1 deletion scene/gui/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ void Container::_bind_methods() {
}

Container::Container() {
pending_sort = false;
// All containers should let mouse events pass by default.
set_mouse_filter(MOUSE_FILTER_PASS);
}
2 changes: 1 addition & 1 deletion scene/gui/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
class Container : public Control {
GDCLASS(Container, Control);

bool pending_sort;
bool pending_sort = false;
void _sort_children();
void _child_minsize_changed();

Expand Down
4 changes: 2 additions & 2 deletions scene/gui/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ class Control : public CanvasItem {

LayoutDirection layout_dir = LAYOUT_DIRECTION_INHERITED;

float rotation = 0;
float rotation = 0.0;
Vector2 scale = Vector2(1, 1);
Vector2 pivot_offset;

int h_size_flags = SIZE_FILL;
int v_size_flags = SIZE_FILL;
float expand = 1;
float expand = 1.0;
Point2 custom_minimum_size;

MouseFilter mouse_filter = MOUSE_FILTER_STOP;
Expand Down
Loading

0 comments on commit e8f7312

Please sign in to comment.