Skip to content

Commit

Permalink
Merge pull request godotengine#27673 from qarmin/small_fixes
Browse files Browse the repository at this point in the history
Small fixes, mostly duplicated code
  • Loading branch information
akien-mga authored Apr 22, 2019
2 parents 1e67f21 + 856a822 commit a342131
Show file tree
Hide file tree
Showing 29 changed files with 32 additions and 60 deletions.
1 change: 0 additions & 1 deletion drivers/gles2/rasterizer_scene_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ RID RasterizerSceneGLES2::reflection_probe_instance_create(RID p_probe) {
rpi->current_resolution = 0;
rpi->dirty = true;

rpi->last_pass = 0;
rpi->index = 0;

for (int i = 0; i < 6; i++) {
Expand Down
11 changes: 5 additions & 6 deletions drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,12 +1061,11 @@ void RasterizerSceneGLES3::gi_probe_instance_set_light_data(RID p_probe, RID p_b
if (p_data.is_valid()) {
RasterizerStorageGLES3::GIProbeData *gipd = storage->gi_probe_data_owner.getornull(p_data);
ERR_FAIL_COND(!gipd);
if (gipd) {
gipi->tex_cache = gipd->tex_id;
gipi->cell_size_cache.x = 1.0 / gipd->width;
gipi->cell_size_cache.y = 1.0 / gipd->height;
gipi->cell_size_cache.z = 1.0 / gipd->depth;
}

gipi->tex_cache = gipd->tex_id;
gipi->cell_size_cache.x = 1.0 / gipd->width;
gipi->cell_size_cache.y = 1.0 / gipd->height;
gipi->cell_size_cache.z = 1.0 / gipd->depth;
}
}
void RasterizerSceneGLES3::gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) {
Expand Down
3 changes: 1 addition & 2 deletions editor/collada/collada.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2256,8 +2256,7 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) {

Node *node = state.scene_map[name];
ERR_CONTINUE(node->type != Node::TYPE_JOINT);
if (node->type != Node::TYPE_JOINT)
continue;

NodeSkeleton *sk = NULL;

while (node && !sk) {
Expand Down
2 changes: 0 additions & 2 deletions editor/import/editor_import_collada.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1614,8 +1614,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
continue;
}

ERR_CONTINUE(xform_idx == -1);

Vector<float> data = at.get_value_at_time(snapshots[i]);
ERR_CONTINUE(data.empty());

Expand Down
3 changes: 1 addition & 2 deletions editor/inspector_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ void InspectorDock::_menu_option(int p_option) {
ERR_FAIL_INDEX(idx, methods.size());
String name = methods[idx].name;

if (current)
current->call(name);
current->call(name);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/animation_tree_player_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ void AnimationTreePlayerEditor::_gui_input(Ref<InputEvent> p_event) {
click_motion = Point2(mm->get_position().x, mm->get_position().y);
update();
}
if ((mm->get_button_mask() & 4 || Input::get_singleton()->is_key_pressed(KEY_SPACE))) {
if (mm->get_button_mask() & 4 || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {

h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y);
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/canvas_item_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1863,7 +1863,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
}

// Confirm the move (only if it was moved)
if (b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT && (drag_type == DRAG_MOVE)) {
if (b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT) {
if (transform.affine_inverse().xform(b->get_position()) != drag_from) {
_commit_canvas_item_state(drag_selection, TTR("Move CanvasItem"), true);
}
Expand Down
6 changes: 2 additions & 4 deletions editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,10 +892,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
List<Node *>::Element *e = selection.front();
if (e) {
Node *node = e->get();
if (node) {
if (node && node->get_scene_inherited_state().is_valid()) {
scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path());
}
if (node && node->get_scene_inherited_state().is_valid()) {
scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path());
}
}
} break;
Expand Down
1 change: 0 additions & 1 deletion editor/spatial_editor_gizmos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref

ERR_FAIL_COND(!spatial_node);

ERR_FAIL_COND(!spatial_node);
Instance ins;

Ref<ArrayMesh> mesh = memnew(ArrayMesh);
Expand Down
2 changes: 1 addition & 1 deletion modules/gdnative/videodecoder/video_stream_gdnative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ int64_t GDAPI godot_videodecoder_file_seek(void *ptr, int64_t pos, int whence) {
// file
FileAccess *file = reinterpret_cast<FileAccess *>(ptr);

size_t len = file->get_len();
if (file) {
size_t len = file->get_len();
switch (whence) {
case SEEK_SET: {
// Just for explicitness
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3008,8 +3008,8 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
}
}
}
base_type = base_type.class_type->base_type;
}
base_type = base_type.class_type->base_type;
} break;
case GDScriptParser::DataType::SCRIPT:
case GDScriptParser::DataType::GDSCRIPT: {
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ void GDScriptTokenizerText::_advance() {
}
hexa_found = true;
} else if (!hexa_found && GETCHAR(i) == 'e') {
if (hexa_found || exponent_found) {
if (exponent_found) {
_make_error("Invalid numeric constant at 'e'");
return;
}
Expand Down
4 changes: 1 addition & 3 deletions modules/recast/navigation_mesh_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ void NavigationMeshEditor::_bake_pressed() {
NavigationMeshGenerator::clear(node->get_navigation_mesh());
NavigationMeshGenerator::bake(node->get_navigation_mesh(), node);

if (node) {
node->update_gizmo();
}
node->update_gizmo();
}

void NavigationMeshEditor::_clear_pressed() {
Expand Down
4 changes: 0 additions & 4 deletions platform/android/export/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1923,10 +1923,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
zipClose(final_apk, NULL);
unzClose(tmp_unaligned);

if (err) {
return err;
}

return OK;
}

Expand Down
2 changes: 1 addition & 1 deletion platform/x11/os_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ int OS_X11::get_screen_dpi(int p_screen) const {
int height_mm = DisplayHeightMM(x11_display, p_screen);
double xdpi = (width_mm ? sc.width / (double)width_mm * 25.4 : 0);
double ydpi = (height_mm ? sc.height / (double)height_mm * 25.4 : 0);
if (xdpi || xdpi)
if (xdpi || ydpi)
return (xdpi + ydpi) / (xdpi && ydpi ? 2 : 1);

//could not get dpi
Expand Down
3 changes: 0 additions & 3 deletions scene/2d/physics_body_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1275,9 +1275,6 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const

if (collided) {
found_collision = true;
}

if (collided) {

colliders.push_back(collision);
motion = collision.remainder;
Expand Down
3 changes: 0 additions & 3 deletions scene/3d/physics_body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,9 +1203,6 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve

if (collided) {
found_collision = true;
}

if (collided) {

colliders.push_back(collision);
motion = collision.remainder;
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/base_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void BaseButton::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventMouseButton> b = p_event;

if (b.is_valid()) {
if (status.disabled || ((1 << (b->get_button_index() - 1)) & button_mask) == 0)
if (((1 << (b->get_button_index() - 1)) & button_mask) == 0)
return;

if (status.pressing_button)
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/popup_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {

for (int i = search_from; i >= 0; i--) {

if (i < 0 || i >= items.size())
if (i >= items.size())
continue;

if (!items[i].separator && !items[i].disabled) {
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/rich_text_label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1997,7 +1997,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
Item *it = main;
int charidx = 0;

if (p_from_selection && selection.active && selection.enabled) {
if (p_from_selection && selection.active) {
it = selection.to;
charidx = selection.to_char + 1;
}
Expand Down
1 change: 0 additions & 1 deletion scene/gui/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3938,7 +3938,6 @@ Tree::Tree() {
cache.click_item = NULL;
cache.click_column = 0;
cache.hover_cell = -1;
cache.hover_index = -1;
last_keypress = 0;
focus_in_id = 0;

Expand Down
2 changes: 1 addition & 1 deletion scene/main/http_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ bool HTTPRequest::_update_connection() {
call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PoolByteArray());
return true;
}
if (got_response && body_len < 0) {
if (body_len < 0) {
// Chunked transfer is done
call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, body);
return true;
Expand Down
2 changes: 1 addition & 1 deletion scene/resources/curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void Curve::update_auto_tangents(int i) {
}

if (i + 1 < _points.size()) {
if (p.right_mode == TANGENT_LINEAR && i + 1 < _points.size()) {
if (p.right_mode == TANGENT_LINEAR) {
Vector2 v = (_points[i + 1].pos - p.pos).normalized();
p.right_tangent = v.y / v.x;
}
Expand Down
6 changes: 2 additions & 4 deletions servers/audio/audio_rb_resampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,8 @@ void AudioRBResampler::clear() {
return;

//should be stopped at this point but just in case
if (rb) {
memdelete_arr(rb);
memdelete_arr(read_buf);
}
memdelete_arr(rb);
memdelete_arr(read_buf);
rb = NULL;
offset = 0;
rb_read_pos = 0;
Expand Down
2 changes: 1 addition & 1 deletion servers/audio/effects/audio_effect_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void AudioEffectRecordInstance::_io_thread_process() {

while (is_recording) {
//Check: The current recording has been requested to stop
if (is_recording && !base->recording_active) {
if (!base->recording_active) {
is_recording = false;
}

Expand Down
6 changes: 2 additions & 4 deletions servers/physics/space_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,8 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_sh
CollisionSolverSW::CallbackResult cbkres = NULL;

PhysicsServerSW::CollCbkData *cbkptr = NULL;
if (p_result_max > 0) {
cbkptr = &cbk;
cbkres = PhysicsServerSW::_shape_col_cbk;
}
cbkptr = &cbk;
cbkres = PhysicsServerSW::_shape_col_cbk;

for (int i = 0; i < amount; i++) {

Expand Down
2 changes: 1 addition & 1 deletion servers/physics_2d/shape_2d_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ bool ConvexPolygonShape2DSW::contains_point(const Vector2 &p_point) const {
in = true;
}

return (in && !out) || (!in && out);
return in != out;
}

bool ConvexPolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
Expand Down
8 changes: 3 additions & 5 deletions servers/physics_2d/space_2d_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,8 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &
CollisionSolver2DSW::CallbackResult cbkres = NULL;

Physics2DServerSW::CollCbkData *cbkptr = NULL;
if (p_result_max > 0) {
cbkptr = &cbk;
cbkres = Physics2DServerSW::_shape_col_cbk;
}
cbkptr = &cbk;
cbkres = Physics2DServerSW::_shape_col_cbk;

for (int i = 0; i < amount; i++) {

Expand All @@ -353,7 +351,7 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &
cbk.valid_depth = 0;

if (CollisionSolver2DSW::solve(shape, p_shape_xform, p_motion, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), cbkres, cbkptr, NULL, p_margin)) {
collided = p_result_max == 0 || cbk.amount > 0;
collided = cbk.amount > 0;
}
}

Expand Down
4 changes: 2 additions & 2 deletions servers/visual/visual_server_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
//failure
} else if (ins->base_type == VS::INSTANCE_LIGHT && ins->visible) {

if (ins->visible && light_cull_count < MAX_LIGHTS_CULLED) {
if (light_cull_count < MAX_LIGHTS_CULLED) {

InstanceLightData *light = static_cast<InstanceLightData *>(ins->base_data);

Expand All @@ -1888,7 +1888,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
}
} else if (ins->base_type == VS::INSTANCE_REFLECTION_PROBE && ins->visible) {

if (ins->visible && reflection_probe_cull_count < MAX_REFLECTION_PROBES_CULLED) {
if (reflection_probe_cull_count < MAX_REFLECTION_PROBES_CULLED) {

InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(ins->base_data);

Expand Down

0 comments on commit a342131

Please sign in to comment.