1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-06 19:41:11 +00:00

Initialize class/struct variables with default values in platform/ and editor/

This commit is contained in:
Rafał Mikrut
2020-11-24 10:12:55 +01:00
parent d1231be1c8
commit e1811b689b
87 changed files with 411 additions and 540 deletions

View File

@@ -113,9 +113,9 @@ class AnimationPlayerEditor : public VBoxContainer {
int current_option;
struct BlendEditor {
AcceptDialog *dialog;
Tree *tree;
OptionButton *next;
AcceptDialog *dialog = nullptr;
Tree *tree = nullptr;
OptionButton *next = nullptr;
} blend_editor;
@@ -131,13 +131,13 @@ class AnimationPlayerEditor : public VBoxContainer {
// Onion skinning.
struct {
// Settings.
bool enabled;
bool past;
bool future;
int steps;
bool differences_only;
bool force_white_modulate;
bool include_gizmos;
bool enabled = false;
bool past = false;
bool future = false;
int steps = 0;
bool differences_only = false;
bool force_white_modulate = false;
bool include_gizmos = false;
int get_needed_capture_count() const {
// 'Differences only' needs a capture of the present.
@@ -145,8 +145,8 @@ class AnimationPlayerEditor : public VBoxContainer {
}
// Rendering.
int64_t last_frame;
int can_overlay;
int64_t last_frame = 0;
int can_overlay = 0;
Size2 capture_size;
Vector<RID> captures;
Vector<bool> captures_valid;

View File

@@ -126,10 +126,10 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin {
Vector2 to;
AnimationNodeStateMachineTransition::SwitchMode mode;
StringName advance_condition_name;
bool advance_condition_state;
bool disabled;
bool auto_advance;
float width;
bool advance_condition_state = false;
bool disabled = false;
bool auto_advance = false;
float width = 0;
};
Vector<TransitionLine> transition_lines;

View File

@@ -89,10 +89,10 @@ class EditorAssetLibraryItemDescription : public ConfirmationDialog {
PanelContainer *previews_bg;
struct Preview {
int id;
bool is_video;
int id = 0;
bool is_video = false;
String video_link;
Button *button;
Button *button = nullptr;
Ref<Texture2D> image;
};
@@ -234,12 +234,12 @@ class EditorAssetLibrary : public PanelContainer {
};
struct ImageQueue {
bool active;
int queue_id;
ImageType image_type;
int image_index;
bool active = false;
int queue_id = 0;
ImageType image_type = ImageType::IMAGE_QUEUE_ICON;
int image_index = 0;
String image_url;
HTTPRequest *request;
HTTPRequest *request = nullptr;
ObjectID target;
};

View File

@@ -288,9 +288,9 @@ private:
MenuOption last_option;
struct _SelectResult {
CanvasItem *item;
float z_index;
bool has_z;
CanvasItem *item = nullptr;
float z_index = 0;
bool has_z = true;
_FORCE_INLINE_ bool operator<(const _SelectResult &p_rr) const {
return has_z && p_rr.has_z ? p_rr.z_index < z_index : p_rr.has_z;
}
@@ -308,8 +308,6 @@ private:
Transform2D xform;
float length = 0.f;
uint64_t last_pass = 0;
BoneList() {}
};
uint64_t bone_last_frame;
@@ -331,7 +329,7 @@ private:
struct PoseClipboard {
Vector2 pos;
Vector2 scale;
float rot;
float rot = 0;
ObjectID id;
};
List<PoseClipboard> pose_clipboard;

View File

@@ -563,6 +563,8 @@ CollisionShape2DEditor::CollisionShape2DEditor(EditorNode *p_editor) {
edit_handle = -1;
pressed = false;
shape_type = 0;
}
void CollisionShape2DEditorPlugin::edit(Object *p_obj) {

View File

@@ -90,7 +90,7 @@ class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator {
RID light2;
RID light_instance2;
RID camera;
mutable volatile bool preview_done;
mutable volatile bool preview_done = false;
void _preview_done(const Variant &p_udata);
@@ -134,7 +134,7 @@ class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator {
RID light2;
RID light_instance2;
RID camera;
mutable volatile bool preview_done;
mutable volatile bool preview_done = false;
void _preview_done(const Variant &p_udata);
@@ -156,7 +156,7 @@ class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator {
RID viewport_texture;
RID canvas;
RID canvas_item;
mutable volatile bool preview_done;
mutable volatile bool preview_done = false;
void _preview_done(const Variant &p_udata);

View File

@@ -301,4 +301,6 @@ MeshLibraryEditorPlugin::MeshLibraryEditorPlugin(EditorNode *p_node) {
mesh_library_editor->set_anchors_and_margins_preset(Control::PRESET_TOP_WIDE);
mesh_library_editor->set_end(Point2(0, 22));
mesh_library_editor->hide();
editor = nullptr;
}

View File

@@ -61,16 +61,10 @@ public:
Ref<Material> material;
Ref<SkinReference> skin_reference;
RID skeleton;
bool billboard;
bool unscaled;
bool can_intersect;
bool extra_margin;
Instance() {
billboard = false;
unscaled = false;
can_intersect = false;
extra_margin = false;
}
bool billboard = false;
bool unscaled = false;
bool can_intersect = false;
bool extra_margin = false;
void create_instance(Node3D *p_base, bool p_hidden = false);
};
@@ -80,7 +74,7 @@ public:
struct Handle {
Vector3 pos;
bool billboard;
bool billboard = false;
};
Vector<Vector3> handles;
@@ -296,9 +290,9 @@ private:
Label *fps_label;
struct _RayResult {
Node3D *item;
float depth;
int handle;
Node3D *item = nullptr;
float depth = 0;
int handle = 0;
_FORCE_INLINE_ bool operator<(const _RayResult &p_rr) const { return depth < p_rr.depth; }
};
@@ -375,11 +369,11 @@ private:
Vector3 click_ray_pos;
Vector3 center;
Vector3 orig_gizmo_pos;
int edited_gizmo;
int edited_gizmo = 0;
Point2 mouse_pos;
bool snap;
bool snap = false;
Ref<EditorNode3DGizmo> gizmo;
int gizmo_handle;
int gizmo_handle = 0;
Variant gizmo_initial_value;
Vector3 gizmo_initial_pos;
} _edit;
@@ -625,8 +619,8 @@ private:
AABB preview_bounds;
struct Gizmo {
bool visible;
float scale;
bool visible = false;
float scale = 0;
Transform transform;
} gizmo;

View File

@@ -290,6 +290,8 @@ void Path3DGizmo::redraw() {
Path3DGizmo::Path3DGizmo(Path3D *p_path) {
path = p_path;
set_spatial_node(p_path);
orig_in_length = 0;
orig_out_length = 0;
}
bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {

View File

@@ -234,15 +234,15 @@ static bool _is_built_in_script(Script *p_script) {
class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache {
struct Cache {
uint64_t time_loaded;
uint64_t time_loaded = 0;
RES cache;
};
Map<String, Cache> cached;
public:
uint64_t max_time_cache;
int max_cache_size;
uint64_t max_time_cache = 5 * 60 * 1000; //minutes, five
int max_cache_size = 128;
void cleanup() {
List<Map<String, Cache>::Element *> to_clean;
@@ -292,11 +292,6 @@ public:
return E->get().cache;
}
EditorScriptCodeCompletionCache() {
max_cache_size = 128;
max_time_cache = 5 * 60 * 1000; //minutes, five
}
virtual ~EditorScriptCodeCompletionCache() {}
};
@@ -1723,11 +1718,11 @@ struct _ScriptEditorItemData {
String name;
String sort_key;
Ref<Texture2D> icon;
int index;
int index = 0;
String tooltip;
bool used;
int category;
Node *ref;
bool used = false;
int category = 0;
Node *ref = nullptr;
bool operator<(const _ScriptEditorItemData &id) const {
if (category == id.category) {

View File

@@ -291,7 +291,7 @@ class ScriptEditor : public PanelContainer {
Vector<Ref<EditorSyntaxHighlighter>> syntax_highlighters;
struct ScriptHistory {
Control *control;
Control *control = nullptr;
Variant state;
};

View File

@@ -714,6 +714,8 @@ ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node) {
shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
button = editor->add_bottom_panel_item(TTR("Shader"), shader_editor);
button->hide();
_2d = false;
}
ShaderEditorPlugin::~ShaderEditorPlugin() {

View File

@@ -264,12 +264,7 @@ void BoneTransformEditor::_update_transform_properties(Transform tform) {
}
BoneTransformEditor::BoneTransformEditor(Skeleton3D *p_skeleton) :
skeleton(p_skeleton),
key_button(nullptr),
enabled_checkbox(nullptr),
keyable(false),
toggle_enabled(false),
updating(false) {
skeleton(p_skeleton) {
undo_redo = EditorNode::get_undo_redo();
}

View File

@@ -47,13 +47,13 @@ class EditorPropertyVector3;
class BoneTransformEditor : public VBoxContainer {
GDCLASS(BoneTransformEditor, VBoxContainer);
EditorInspectorSection *section;
EditorInspectorSection *section = nullptr;
EditorPropertyVector3 *translation_property;
EditorPropertyVector3 *rotation_property;
EditorPropertyVector3 *scale_property;
EditorInspectorSection *transform_section;
EditorPropertyTransform *transform_property;
EditorPropertyVector3 *translation_property = nullptr;
EditorPropertyVector3 *rotation_property = nullptr;
EditorPropertyVector3 *scale_property = nullptr;
EditorInspectorSection *transform_section = nullptr;
EditorPropertyTransform *transform_property = nullptr;
Rect2 background_rects[5];
@@ -62,12 +62,12 @@ class BoneTransformEditor : public VBoxContainer {
UndoRedo *undo_redo;
Button *key_button;
CheckBox *enabled_checkbox;
Button *key_button = nullptr;
CheckBox *enabled_checkbox = nullptr;
bool keyable;
bool toggle_enabled;
bool updating;
bool keyable = false;
bool toggle_enabled = false;
bool updating = false;
String label;
@@ -128,7 +128,6 @@ class Skeleton3DEditor : public VBoxContainer {
struct BoneInfo {
PhysicalBone3D *physical_bone = nullptr;
Transform relative_rest; // Relative to skeleton node
BoneInfo() {}
};
EditorNode *editor;
@@ -136,20 +135,20 @@ class Skeleton3DEditor : public VBoxContainer {
Skeleton3D *skeleton;
Tree *joint_tree;
BoneTransformEditor *rest_editor;
BoneTransformEditor *pose_editor;
BoneTransformEditor *custom_pose_editor;
Tree *joint_tree = nullptr;
BoneTransformEditor *rest_editor = nullptr;
BoneTransformEditor *pose_editor = nullptr;
BoneTransformEditor *custom_pose_editor = nullptr;
MenuButton *options;
EditorFileDialog *file_dialog;
MenuButton *options = nullptr;
EditorFileDialog *file_dialog = nullptr;
UndoRedo *undo_redo;
UndoRedo *undo_redo = nullptr;
void _on_click_option(int p_option);
void _file_selected(const String &p_file);
EditorFileDialog *file_export_lib;
EditorFileDialog *file_export_lib = nullptr;
void update_joint_tree();
void update_editors();

View File

@@ -409,7 +409,7 @@ void TileMapEditor::_sbox_input(const Ref<InputEvent> &p_ie) {
// In modern C++ this could have been inside its body.
namespace {
struct _PaletteEntry {
int id;
int id = 0;
String name;
bool operator<(const _PaletteEntry &p_rhs) const {

View File

@@ -131,8 +131,6 @@ class TileMapEditor : public VBoxContainer {
bool yf = false;
bool tr = false;
Vector2 ac;
CellOp() {}
};
Map<Point2i, CellOp> paint_undo;
@@ -144,8 +142,6 @@ class TileMapEditor : public VBoxContainer {
bool flip_v = false;
bool transpose = false;
Point2i autotile_coord;
TileData() {}
};
List<TileData> copydata;

View File

@@ -49,7 +49,7 @@
struct FloatConstantDef {
String name;
float value;
float value = 0;
String desc;
};
@@ -4062,9 +4062,6 @@ void VisualShaderNodePortPreview::_notification(int p_what) {
void VisualShaderNodePortPreview::_bind_methods() {
}
VisualShaderNodePortPreview::VisualShaderNodePortPreview() {
}
//////////////////////////////////
String VisualShaderConversionPlugin::converts_to() const {

View File

@@ -56,26 +56,26 @@ class VisualShaderGraphPlugin : public Reference {
private:
struct InputPort {
Button *default_input_button;
Button *default_input_button = nullptr;
};
struct Port {
TextureButton *preview_button;
TextureButton *preview_button = nullptr;
};
struct Link {
VisualShader::Type type;
VisualShaderNode *visual_node;
GraphNode *graph_node;
bool preview_visible;
int preview_pos;
VisualShader::Type type = VisualShader::Type::TYPE_MAX;
VisualShaderNode *visual_node = nullptr;
GraphNode *graph_node = nullptr;
bool preview_visible = 0;
int preview_pos = 0;
Map<int, InputPort> input_ports;
Map<int, Port> output_ports;
VBoxContainer *preview_box;
LineEdit *uniform_name;
OptionButton *const_op;
CodeEdit *expression_edit;
CurveEditor *curve_editor;
VBoxContainer *preview_box = nullptr;
LineEdit *uniform_name = nullptr;
OptionButton *const_op = nullptr;
CodeEdit *expression_edit = nullptr;
CurveEditor *curve_editor = nullptr;
};
Ref<VisualShader> visual_shader;
@@ -206,16 +206,16 @@ class VisualShaderEditor : public VBoxContainer {
String category;
String type;
String description;
int sub_func;
int sub_func = 0;
String sub_func_str;
Ref<Script> script;
int mode;
int return_type;
int func;
float value;
bool highend;
bool is_custom;
int temp_idx;
int mode = 0;
int return_type = 0;
int func = 0;
float value = 0;
bool highend = false;
bool is_custom = false;
int temp_idx = 0;
AddOption(const String &p_name = String(), const String &p_category = String(), const String &p_sub_category = String(), const String &p_type = String(), const String &p_description = String(), int p_sub_func = -1, int p_return_type = -1, int p_mode = -1, int p_func = -1, float p_value = -1, bool p_highend = false) {
name = p_name;
@@ -283,8 +283,8 @@ class VisualShaderEditor : public VBoxContainer {
static VisualShaderEditor *singleton;
struct DragOp {
VisualShader::Type type;
int node;
VisualShader::Type type = VisualShader::Type::TYPE_MAX;
int node = 0;
Vector2 from;
Vector2 to;
};
@@ -462,9 +462,9 @@ public:
class VisualShaderNodePortPreview : public Control {
GDCLASS(VisualShaderNodePortPreview, Control);
Ref<VisualShader> shader;
VisualShader::Type type;
int node;
int port;
VisualShader::Type type = VisualShader::Type::TYPE_MAX;
int node = 0;
int port = 0;
void _shader_changed(); //must regen
protected:
void _notification(int p_what);
@@ -473,7 +473,6 @@ protected:
public:
virtual Size2 get_minimum_size() const override;
void setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port);
VisualShaderNodePortPreview();
};
class VisualShaderConversionPlugin : public EditorResourceConversionPlugin {