Merge pull request #27673 from qarmin/small_fixes

Small fixes, mostly duplicated code
This commit is contained in:
Rémi Verschelde 2019-04-22 12:00:34 +02:00 committed by GitHub
commit a342131eba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 32 additions and 60 deletions

View File

@ -480,7 +480,6 @@ RID RasterizerSceneGLES2::reflection_probe_instance_create(RID p_probe) {
rpi->current_resolution = 0; rpi->current_resolution = 0;
rpi->dirty = true; rpi->dirty = true;
rpi->last_pass = 0;
rpi->index = 0; rpi->index = 0;
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {

View File

@ -1061,12 +1061,11 @@ void RasterizerSceneGLES3::gi_probe_instance_set_light_data(RID p_probe, RID p_b
if (p_data.is_valid()) { if (p_data.is_valid()) {
RasterizerStorageGLES3::GIProbeData *gipd = storage->gi_probe_data_owner.getornull(p_data); RasterizerStorageGLES3::GIProbeData *gipd = storage->gi_probe_data_owner.getornull(p_data);
ERR_FAIL_COND(!gipd); ERR_FAIL_COND(!gipd);
if (gipd) {
gipi->tex_cache = gipd->tex_id; gipi->tex_cache = gipd->tex_id;
gipi->cell_size_cache.x = 1.0 / gipd->width; gipi->cell_size_cache.x = 1.0 / gipd->width;
gipi->cell_size_cache.y = 1.0 / gipd->height; gipi->cell_size_cache.y = 1.0 / gipd->height;
gipi->cell_size_cache.z = 1.0 / gipd->depth; 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) { void RasterizerSceneGLES3::gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) {

View File

@ -2256,8 +2256,7 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) {
Node *node = state.scene_map[name]; Node *node = state.scene_map[name];
ERR_CONTINUE(node->type != Node::TYPE_JOINT); ERR_CONTINUE(node->type != Node::TYPE_JOINT);
if (node->type != Node::TYPE_JOINT)
continue;
NodeSkeleton *sk = NULL; NodeSkeleton *sk = NULL;
while (node && !sk) { while (node && !sk) {

View File

@ -1614,8 +1614,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
continue; continue;
} }
ERR_CONTINUE(xform_idx == -1);
Vector<float> data = at.get_value_at_time(snapshots[i]); Vector<float> data = at.get_value_at_time(snapshots[i]);
ERR_CONTINUE(data.empty()); ERR_CONTINUE(data.empty());

View File

@ -130,8 +130,7 @@ void InspectorDock::_menu_option(int p_option) {
ERR_FAIL_INDEX(idx, methods.size()); ERR_FAIL_INDEX(idx, methods.size());
String name = methods[idx].name; String name = methods[idx].name;
if (current) current->call(name);
current->call(name);
} }
} }
} }

View File

@ -840,7 +840,7 @@ void AnimationTreePlayerEditor::_gui_input(Ref<InputEvent> p_event) {
click_motion = Point2(mm->get_position().x, mm->get_position().y); click_motion = Point2(mm->get_position().x, mm->get_position().y);
update(); 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); h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y); v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y);

View File

@ -1863,7 +1863,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
} }
// Confirm the move (only if it was moved) // 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) { if (transform.affine_inverse().xform(b->get_position()) != drag_from) {
_commit_canvas_item_state(drag_selection, TTR("Move CanvasItem"), true); _commit_canvas_item_state(drag_selection, TTR("Move CanvasItem"), true);
} }

View File

@ -892,10 +892,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
List<Node *>::Element *e = selection.front(); List<Node *>::Element *e = selection.front();
if (e) { if (e) {
Node *node = e->get(); Node *node = e->get();
if (node) { if (node && node->get_scene_inherited_state().is_valid()) {
if (node && node->get_scene_inherited_state().is_valid()) { scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path());
scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path());
}
} }
} }
} break; } break;

View File

@ -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);
ERR_FAIL_COND(!spatial_node);
Instance ins; Instance ins;
Ref<ArrayMesh> mesh = memnew(ArrayMesh); Ref<ArrayMesh> mesh = memnew(ArrayMesh);

View File

@ -61,8 +61,8 @@ int64_t GDAPI godot_videodecoder_file_seek(void *ptr, int64_t pos, int whence) {
// file // file
FileAccess *file = reinterpret_cast<FileAccess *>(ptr); FileAccess *file = reinterpret_cast<FileAccess *>(ptr);
size_t len = file->get_len();
if (file) { if (file) {
size_t len = file->get_len();
switch (whence) { switch (whence) {
case SEEK_SET: { case SEEK_SET: {
// Just for explicitness // Just for explicitness

View File

@ -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; } break;
case GDScriptParser::DataType::SCRIPT: case GDScriptParser::DataType::SCRIPT:
case GDScriptParser::DataType::GDSCRIPT: { case GDScriptParser::DataType::GDSCRIPT: {

View File

@ -896,7 +896,7 @@ void GDScriptTokenizerText::_advance() {
} }
hexa_found = true; hexa_found = true;
} else if (!hexa_found && GETCHAR(i) == 'e') { } else if (!hexa_found && GETCHAR(i) == 'e') {
if (hexa_found || exponent_found) { if (exponent_found) {
_make_error("Invalid numeric constant at 'e'"); _make_error("Invalid numeric constant at 'e'");
return; return;
} }

View File

@ -67,9 +67,7 @@ void NavigationMeshEditor::_bake_pressed() {
NavigationMeshGenerator::clear(node->get_navigation_mesh()); NavigationMeshGenerator::clear(node->get_navigation_mesh());
NavigationMeshGenerator::bake(node->get_navigation_mesh(), node); NavigationMeshGenerator::bake(node->get_navigation_mesh(), node);
if (node) { node->update_gizmo();
node->update_gizmo();
}
} }
void NavigationMeshEditor::_clear_pressed() { void NavigationMeshEditor::_clear_pressed() {

View File

@ -1923,10 +1923,6 @@ public:
zipClose(final_apk, NULL); zipClose(final_apk, NULL);
unzClose(tmp_unaligned); unzClose(tmp_unaligned);
if (err) {
return err;
}
return OK; return OK;
} }

View File

@ -1165,7 +1165,7 @@ int OS_X11::get_screen_dpi(int p_screen) const {
int height_mm = DisplayHeightMM(x11_display, p_screen); int height_mm = DisplayHeightMM(x11_display, p_screen);
double xdpi = (width_mm ? sc.width / (double)width_mm * 25.4 : 0); double xdpi = (width_mm ? sc.width / (double)width_mm * 25.4 : 0);
double ydpi = (height_mm ? sc.height / (double)height_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); return (xdpi + ydpi) / (xdpi && ydpi ? 2 : 1);
//could not get dpi //could not get dpi

View File

@ -1275,9 +1275,6 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
if (collided) { if (collided) {
found_collision = true; found_collision = true;
}
if (collided) {
colliders.push_back(collision); colliders.push_back(collision);
motion = collision.remainder; motion = collision.remainder;

View File

@ -1203,9 +1203,6 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
if (collided) { if (collided) {
found_collision = true; found_collision = true;
}
if (collided) {
colliders.push_back(collision); colliders.push_back(collision);
motion = collision.remainder; motion = collision.remainder;

View File

@ -59,7 +59,7 @@ void BaseButton::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventMouseButton> b = p_event; Ref<InputEventMouseButton> b = p_event;
if (b.is_valid()) { 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; return;
if (status.pressing_button) if (status.pressing_button)

View File

@ -239,7 +239,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
for (int i = search_from; i >= 0; i--) { for (int i = search_from; i >= 0; i--) {
if (i < 0 || i >= items.size()) if (i >= items.size())
continue; continue;
if (!items[i].separator && !items[i].disabled) { if (!items[i].separator && !items[i].disabled) {

View File

@ -1997,7 +1997,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
Item *it = main; Item *it = main;
int charidx = 0; int charidx = 0;
if (p_from_selection && selection.active && selection.enabled) { if (p_from_selection && selection.active) {
it = selection.to; it = selection.to;
charidx = selection.to_char + 1; charidx = selection.to_char + 1;
} }

View File

@ -3938,7 +3938,6 @@ Tree::Tree() {
cache.click_item = NULL; cache.click_item = NULL;
cache.click_column = 0; cache.click_column = 0;
cache.hover_cell = -1; cache.hover_cell = -1;
cache.hover_index = -1;
last_keypress = 0; last_keypress = 0;
focus_in_id = 0; focus_in_id = 0;

View File

@ -286,7 +286,7 @@ bool HTTPRequest::_update_connection() {
call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PoolByteArray()); call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PoolByteArray());
return true; return true;
} }
if (got_response && body_len < 0) { if (body_len < 0) {
// Chunked transfer is done // Chunked transfer is done
call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, body); call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, body);
return true; return true;

View File

@ -268,7 +268,7 @@ void Curve::update_auto_tangents(int i) {
} }
if (i + 1 < _points.size()) { 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(); Vector2 v = (_points[i + 1].pos - p.pos).normalized();
p.right_tangent = v.y / v.x; p.right_tangent = v.y / v.x;
} }

View File

@ -201,10 +201,8 @@ void AudioRBResampler::clear() {
return; return;
//should be stopped at this point but just in case //should be stopped at this point but just in case
if (rb) { memdelete_arr(rb);
memdelete_arr(rb); memdelete_arr(read_buf);
memdelete_arr(read_buf);
}
rb = NULL; rb = NULL;
offset = 0; offset = 0;
rb_read_pos = 0; rb_read_pos = 0;

View File

@ -66,7 +66,7 @@ void AudioEffectRecordInstance::_io_thread_process() {
while (is_recording) { while (is_recording) {
//Check: The current recording has been requested to stop //Check: The current recording has been requested to stop
if (is_recording && !base->recording_active) { if (!base->recording_active) {
is_recording = false; is_recording = false;
} }

View File

@ -351,10 +351,8 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_sh
CollisionSolverSW::CallbackResult cbkres = NULL; CollisionSolverSW::CallbackResult cbkres = NULL;
PhysicsServerSW::CollCbkData *cbkptr = NULL; PhysicsServerSW::CollCbkData *cbkptr = NULL;
if (p_result_max > 0) { cbkptr = &cbk;
cbkptr = &cbk; cbkres = PhysicsServerSW::_shape_col_cbk;
cbkres = PhysicsServerSW::_shape_col_cbk;
}
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {

View File

@ -586,7 +586,7 @@ bool ConvexPolygonShape2DSW::contains_point(const Vector2 &p_point) const {
in = true; 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 { bool ConvexPolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {

View File

@ -333,10 +333,8 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &
CollisionSolver2DSW::CallbackResult cbkres = NULL; CollisionSolver2DSW::CallbackResult cbkres = NULL;
Physics2DServerSW::CollCbkData *cbkptr = NULL; Physics2DServerSW::CollCbkData *cbkptr = NULL;
if (p_result_max > 0) { cbkptr = &cbk;
cbkptr = &cbk; cbkres = Physics2DServerSW::_shape_col_cbk;
cbkres = Physics2DServerSW::_shape_col_cbk;
}
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
@ -353,7 +351,7 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &
cbk.valid_depth = 0; 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)) { 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;
} }
} }

View File

@ -1871,7 +1871,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
//failure //failure
} else if (ins->base_type == VS::INSTANCE_LIGHT && ins->visible) { } 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); InstanceLightData *light = static_cast<InstanceLightData *>(ins->base_data);
@ -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) { } 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); InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(ins->base_data);