summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-06-20 21:10:10 +0200
committerGitHub <noreply@github.com>2019-06-20 21:10:10 +0200
commit5c66771e3ebccdfec55bb94ea521d2f24cb6200a (patch)
tree80bea3ee8792cb19e719221987faf1a2bf1e88a3 /editor
parent7b88ac08437d3bd062efcbdd40c215b533032412 (diff)
parent072e40368e19e0f88ec1fbb61fe463a6fffcca36 (diff)
Merge pull request #29283 from qarmin/fix_some_always_same_values
Remove always true/false values
Diffstat (limited to 'editor')
-rw-r--r--editor/import/resource_importer_image.cpp5
-rw-r--r--editor/import/resource_importer_obj.cpp3
-rw-r--r--editor/plugins/script_editor_plugin.cpp4
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp4
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp12
-rw-r--r--editor/script_editor_debugger.cpp72
-rw-r--r--editor/spatial_editor_gizmos.cpp32
7 files changed, 64 insertions, 68 deletions
diff --git a/editor/import/resource_importer_image.cpp b/editor/import/resource_importer_image.cpp
index 1259e81be7..ed8ea5497a 100644
--- a/editor/import/resource_importer_image.cpp
+++ b/editor/import/resource_importer_image.cpp
@@ -77,9 +77,8 @@ void ResourceImporterImage::get_import_options(List<ImportOption> *r_options, in
Error ResourceImporterImage::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ);
- if (!f) {
- ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
- }
+
+ ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
size_t len = f->get_len();
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index e950421476..868f67fd77 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -215,7 +215,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p
bool generate_tangents = p_generate_tangents;
Vector3 scale_mesh = p_scale_mesh;
- bool flip_faces = false;
int mesh_flags = p_optimize ? Mesh::ARRAY_COMPRESS_DEFAULT : 0;
Vector<Vector3> vertices;
@@ -293,7 +292,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p
int idx = j;
- if (!flip_faces && idx < 2) {
+ if (idx < 2) {
idx = 1 ^ idx;
}
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index b4719b2e6d..d5e21321c3 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1915,9 +1915,7 @@ Ref<TextFile> ScriptEditor::_load_text_file(const String &p_path, Error *r_error
Ref<TextFile> text_res(text_file);
Error err = text_file->load_text(path);
- if (err != OK) {
- ERR_FAIL_COND_V(err != OK, RES());
- }
+ ERR_FAIL_COND_V(err != OK, RES());
text_file->set_file_path(local_path);
text_file->set_path(local_path, true);
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index a1c0b732fa..7f7ae8f273 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -1275,13 +1275,13 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
_edit.mode = TRANSFORM_TRANSLATE;
}
- if (cursor.region_select && nav_mode == NAVIGATION_NONE) {
+ if (cursor.region_select) {
cursor.region_end = m->get_position();
surface->update();
return;
}
- if (_edit.mode == TRANSFORM_NONE && nav_mode == NAVIGATION_NONE)
+ if (_edit.mode == TRANSFORM_NONE)
return;
Vector3 ray_pos = _get_ray_pos(m->get_position());
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 7d0c67b5ed..bfb005cd0b 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -573,13 +573,11 @@ void VisualShaderEditor::_update_graph() {
name_box->connect("text_entered", this, "_change_input_port_name", varray(name_box, nodes[n_i], i));
name_box->connect("focus_exited", this, "_port_name_focus_out", varray(name_box, nodes[n_i], i, false));
- if (is_group) {
- Button *remove_btn = memnew(Button);
- remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
- remove_btn->set_tooltip(TTR("Remove") + " " + name_left);
- remove_btn->connect("pressed", this, "_remove_input_port", varray(nodes[n_i], i), CONNECT_DEFERRED);
- hb->add_child(remove_btn);
- }
+ Button *remove_btn = memnew(Button);
+ remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
+ remove_btn->set_tooltip(TTR("Remove") + " " + name_left);
+ remove_btn->connect("pressed", this, "_remove_input_port", varray(nodes[n_i], i), CONNECT_DEFERRED);
+ hb->add_child(remove_btn);
} else {
Label *label = memnew(Label);
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 3167abb745..00c8ed6ad3 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -305,49 +305,51 @@ void ScriptEditorDebugger::_scene_tree_rmb_selected(const Vector2 &p_position) {
}
void ScriptEditorDebugger::_file_selected(const String &p_file) {
- if (file_dialog_mode == SAVE_NODE) {
-
- Array msg;
- msg.push_back("save_node");
- msg.push_back(inspected_object_id);
- msg.push_back(p_file);
- ppeer->put_var(msg);
- } else if (file_dialog_mode == SAVE_CSV) {
+ switch (file_dialog_mode) {
+ case SAVE_NODE: {
+ Array msg;
+ msg.push_back("save_node");
+ msg.push_back(inspected_object_id);
+ msg.push_back(p_file);
+ ppeer->put_var(msg);
+ } break;
+ case SAVE_CSV: {
+ Error err;
+ FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
- Error err;
- FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
+ if (err != OK) {
+ ERR_PRINTS("Failed to open " + p_file);
+ return;
+ }
+ Vector<String> line;
+ line.resize(Performance::MONITOR_MAX);
- if (err != OK) {
- ERR_PRINTS("Failed to open " + p_file);
- return;
- }
- Vector<String> line;
- line.resize(Performance::MONITOR_MAX);
+ // signatures
+ for (int i = 0; i < Performance::MONITOR_MAX; i++) {
+ line.write[i] = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
+ }
+ file->store_csv_line(line);
- // signatures
- for (int i = 0; i < Performance::MONITOR_MAX; i++) {
- line.write[i] = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
- }
- file->store_csv_line(line);
+ // values
+ List<Vector<float> >::Element *E = perf_history.back();
+ while (E) {
- // values
- List<Vector<float> >::Element *E = perf_history.back();
- while (E) {
+ Vector<float> &perf_data = E->get();
+ for (int i = 0; i < perf_data.size(); i++) {
- Vector<float> &perf_data = E->get();
- for (int i = 0; i < perf_data.size(); i++) {
+ line.write[i] = String::num_real(perf_data[i]);
+ }
+ file->store_csv_line(line);
+ E = E->prev();
+ }
+ file->store_string("\n");
- line.write[i] = String::num_real(perf_data[i]);
+ Vector<Vector<String> > profiler_data = profiler->get_data_as_csv();
+ for (int i = 0; i < profiler_data.size(); i++) {
+ file->store_csv_line(profiler_data[i]);
}
- file->store_csv_line(line);
- E = E->prev();
- }
- file->store_string("\n");
- Vector<Vector<String> > profiler_data = profiler->get_data_as_csv();
- for (int i = 0; i < profiler_data.size(); i++) {
- file->store_csv_line(profiler_data[i]);
- }
+ } break;
}
}
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index 67cbcf5de4..c4b8999401 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -1835,12 +1835,12 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
JointSpatialGizmoPlugin::CreateConeTwistJointGizmo(
physical_bone->get_joint_offset(),
physical_bone->get_global_transform() * physical_bone->get_joint_offset(),
- pb ? pb->get_global_transform() : Transform(),
- pbp ? pbp->get_global_transform() : Transform(),
+ pb->get_global_transform(),
+ pbp->get_global_transform(),
cjd->swing_span,
cjd->twist_span,
- pb ? &points : NULL,
- pbp ? &points : NULL);
+ &points,
+ &points);
} break;
case PhysicalBone::JOINT_TYPE_HINGE: {
@@ -1848,14 +1848,14 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
JointSpatialGizmoPlugin::CreateHingeJointGizmo(
physical_bone->get_joint_offset(),
physical_bone->get_global_transform() * physical_bone->get_joint_offset(),
- pb ? pb->get_global_transform() : Transform(),
- pbp ? pbp->get_global_transform() : Transform(),
+ pb->get_global_transform(),
+ pbp->get_global_transform(),
hjd->angular_limit_lower,
hjd->angular_limit_upper,
hjd->angular_limit_enabled,
points,
- pb ? &points : NULL,
- pbp ? &points : NULL);
+ &points,
+ &points);
} break;
case PhysicalBone::JOINT_TYPE_SLIDER: {
@@ -1863,15 +1863,15 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
JointSpatialGizmoPlugin::CreateSliderJointGizmo(
physical_bone->get_joint_offset(),
physical_bone->get_global_transform() * physical_bone->get_joint_offset(),
- pb ? pb->get_global_transform() : Transform(),
- pbp ? pbp->get_global_transform() : Transform(),
+ pb->get_global_transform(),
+ pbp->get_global_transform(),
sjd->angular_limit_lower,
sjd->angular_limit_upper,
sjd->linear_limit_lower,
sjd->linear_limit_upper,
points,
- pb ? &points : NULL,
- pbp ? &points : NULL);
+ &points,
+ &points);
} break;
case PhysicalBone::JOINT_TYPE_6DOF: {
@@ -1880,8 +1880,8 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
physical_bone->get_joint_offset(),
physical_bone->get_global_transform() * physical_bone->get_joint_offset(),
- pb ? pb->get_global_transform() : Transform(),
- pbp ? pbp->get_global_transform() : Transform(),
+ pb->get_global_transform(),
+ pbp->get_global_transform(),
sdofjd->axis_data[0].angular_limit_lower,
sdofjd->axis_data[0].angular_limit_upper,
@@ -1905,8 +1905,8 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
sdofjd->axis_data[2].linear_limit_enabled,
points,
- pb ? &points : NULL,
- pbp ? &points : NULL);
+ &points,
+ &points);
} break;
default:
return;