diff --git a/editor/scene/2d/sprite_2d_editor_plugin.cpp b/editor/scene/2d/sprite_2d_editor_plugin.cpp index ab4014bc97..79622ab0b1 100644 --- a/editor/scene/2d/sprite_2d_editor_plugin.cpp +++ b/editor/scene/2d/sprite_2d_editor_plugin.cpp @@ -96,7 +96,7 @@ Vector expand(const Vector &points, const Rect2i &rect, float Vector2 prev = Vector2(p2[lasti].x, p2[lasti].y); for (uint64_t i = 0; i < p2.size(); i++) { Vector2 cur = Vector2(p2[i].x, p2[i].y); - if (cur.distance_to(prev) > 0.5) { + if (cur.distance_to(prev) > 0.5f) { outPoints.push_back(cur); prev = cur; } diff --git a/editor/scene/2d/tiles/tile_data_editors.cpp b/editor/scene/2d/tiles/tile_data_editors.cpp index 8fe2bf64a7..7c431e7913 100644 --- a/editor/scene/2d/tiles/tile_data_editors.cpp +++ b/editor/scene/2d/tiles/tile_data_editors.cpp @@ -414,11 +414,11 @@ void GenericTilePolygonEditor::_grab_polygon_point(Vector2 p_pos, const Transfor const real_t grab_threshold = EDITOR_GET("editors/polygon_editor/point_grab_radius"); r_polygon_index = -1; r_point_index = -1; - float closest_distance = grab_threshold + 1.0; + real_t closest_distance = grab_threshold + 1.0f; for (unsigned int i = 0; i < polygons.size(); i++) { const Vector &polygon = polygons[i]; for (int j = 0; j < polygon.size(); j++) { - float distance = p_pos.distance_to(p_polygon_xform.xform(polygon[j])); + real_t distance = p_pos.distance_to(p_polygon_xform.xform(polygon[j])); if (distance < grab_threshold && distance < closest_distance) { r_polygon_index = i; r_point_index = j; diff --git a/editor/scene/canvas_item_editor_plugin.cpp b/editor/scene/canvas_item_editor_plugin.cpp index c939e3a142..ea6429680b 100644 --- a/editor/scene/canvas_item_editor_plugin.cpp +++ b/editor/scene/canvas_item_editor_plugin.cpp @@ -1849,7 +1849,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref &p_event) { }; DragType resize_drag = DRAG_NONE; - real_t radius = (select_handle->get_size().width / 2) * 1.5; + real_t radius = select_handle->get_size().width * (1.5f / 2.0f); for (int i = 0; i < 4; i++) { int prev = (i + 3) % 4; diff --git a/modules/godot_physics_3d/godot_body_pair_3d.cpp b/modules/godot_physics_3d/godot_body_pair_3d.cpp index 1bbd1289df..76440125a0 100644 --- a/modules/godot_physics_3d/godot_body_pair_3d.cpp +++ b/modules/godot_physics_3d/godot_body_pair_3d.cpp @@ -204,9 +204,9 @@ bool GodotBodyPair3D::_test_ccd(real_t p_step, GodotBody3D *p_A, int p_shape_A, shape_A_ptr->get_supports(p_xform_A.basis.xform_inv(mnormal).normalized(), max_supports, supports_A, support_count_A, support_type_A); // Cast a segment from each support point of A in the motion direction. - int segment_support_idx = -1; - float segment_hit_length = FLT_MAX; Vector3 segment_hit_local; + real_t segment_hit_length = FLT_MAX; + int segment_support_idx = -1; for (int i = 0; i < support_count_A; i++) { supports_A[i] = p_xform_A.xform(supports_A[i]); @@ -224,7 +224,7 @@ bool GodotBodyPair3D::_test_ccd(real_t p_step, GodotBody3D *p_A, int p_shape_A, Vector3 rpos, rnorm; int fi = -1; if (p_B->get_shape(p_shape_B)->intersect_segment(local_from, local_to, rpos, rnorm, fi, true)) { - float hit_length = local_from.distance_to(rpos); + real_t hit_length = local_from.distance_to(rpos); if (hit_length < segment_hit_length) { segment_support_idx = i; segment_hit_length = hit_length; diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp index 39dfae306a..b01a65c935 100644 --- a/modules/mobile_vr/mobile_vr_interface.cpp +++ b/modules/mobile_vr/mobile_vr_interface.cpp @@ -147,27 +147,27 @@ void MobileVRInterface::set_position_from_sensors() { if (sensor_first) { sensor_first = false; } else { - acc = scrub(acc, last_accerometer_data, 2, 0.2); - magneto = scrub(magneto, last_magnetometer_data, 3, 0.3); + acc = scrub(acc, last_accerometer_data, 2, 0.2f); + magneto = scrub(magneto, last_magnetometer_data, 3, 0.3f); }; last_accerometer_data = acc; last_magnetometer_data = magneto; - if (grav.length() < 0.1) { + if (grav.length() < 0.1f) { // not ideal but use our accelerometer, this will contain shaky user behavior // maybe look into some math but I'm guessing that if this isn't available, it's because we lack the gyro sensor to actually work out // what a stable gravity vector is grav = acc; - if (grav.length() > 0.1) { + if (grav.length() > 0.1f) { has_grav = true; }; } else { has_grav = true; }; - bool has_magneto = magneto.length() > 0.1; - if (gyro.length() > 0.1) { + bool has_magneto = magneto.length() > 0.1f; + if (gyro.length() > 0.1f) { /* this can return to 0.0 if the user doesn't move the phone, so once on, it's on */ has_gyro = true; }; diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index ac8d910a57..bdd22977b6 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -1069,14 +1069,14 @@ void CPUParticles2D::_particles_process(double p_delta) { Vector2 pos = p.transform[2]; //apply linear acceleration - force += p.velocity.length() > 0.0 ? p.velocity.normalized() * tex_linear_accel * Math::lerp(parameters_min[PARAM_LINEAR_ACCEL], parameters_max[PARAM_LINEAR_ACCEL], rand_from_seed(_seed)) : Vector2(); + force += p.velocity.length() > 0.0f ? p.velocity.normalized() * tex_linear_accel * Math::lerp(parameters_min[PARAM_LINEAR_ACCEL], parameters_max[PARAM_LINEAR_ACCEL], rand_from_seed(_seed)) : Vector2(); //apply radial acceleration Vector2 org = emission_xform[2]; Vector2 diff = pos - org; - force += diff.length() > 0.0 ? diff.normalized() * (tex_radial_accel)*Math::lerp(parameters_min[PARAM_RADIAL_ACCEL], parameters_max[PARAM_RADIAL_ACCEL], rand_from_seed(_seed)) : Vector2(); + force += diff.length() > 0.0f ? diff.normalized() * (tex_radial_accel)*Math::lerp(parameters_min[PARAM_RADIAL_ACCEL], parameters_max[PARAM_RADIAL_ACCEL], rand_from_seed(_seed)) : Vector2(); //apply tangential acceleration; Vector2 yx = Vector2(diff.y, diff.x); - force += yx.length() > 0.0 ? (yx * Vector2(-1.0, 1.0)).normalized() * (tex_tangential_accel * Math::lerp(parameters_min[PARAM_TANGENTIAL_ACCEL], parameters_max[PARAM_TANGENTIAL_ACCEL], rand_from_seed(_seed))) : Vector2(); + force += yx.length() > 0.0f ? (yx * Vector2(-1.0f, 1.0f)).normalized() * (tex_tangential_accel * Math::lerp(parameters_min[PARAM_TANGENTIAL_ACCEL], parameters_max[PARAM_TANGENTIAL_ACCEL], rand_from_seed(_seed))) : Vector2(); //apply attractor forces p.velocity += force * local_delta; //orbit velocity @@ -1165,7 +1165,7 @@ void CPUParticles2D::_particles_process(double p_delta) { p.color *= p.base_color * p.start_color_rand; if (particle_flags[PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY]) { - if (p.velocity.length() > 0.0) { + if (p.velocity.length() > 0.0f) { p.transform.columns[1] = p.velocity; } diff --git a/scene/2d/physics/character_body_2d.cpp b/scene/2d/physics/character_body_2d.cpp index 374676be12..c70acc5a60 100644 --- a/scene/2d/physics/character_body_2d.cpp +++ b/scene/2d/physics/character_body_2d.cpp @@ -156,7 +156,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo // If we hit a ceiling platform, we set the vertical velocity to at least the platform one. if (on_ceiling && result.collider_velocity != Vector2() && result.collider_velocity.dot(up_direction) < 0) { // If ceiling sliding is on, only apply when the ceiling is flat or when the motion is upward. - if (!slide_on_ceiling || motion.dot(up_direction) < 0 || (result.collision_normal + up_direction).length() < 0.01) { + if (!slide_on_ceiling || motion.dot(up_direction) < 0 || (result.collision_normal + up_direction).length() < 0.01f) { apply_ceiling_velocity = true; Vector2 ceiling_vertical_velocity = up_direction * up_direction.dot(result.collider_velocity); Vector2 motion_vertical_velocity = up_direction * up_direction.dot(velocity); @@ -166,7 +166,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo } } - if (on_floor && floor_stop_on_slope && (velocity.normalized() + up_direction).length() < 0.01) { + if (on_floor && floor_stop_on_slope && (velocity.normalized() + up_direction).length() < 0.01f) { Transform2D gt = get_global_transform(); if (result.travel.length() <= margin + CMP_EPSILON) { gt.columns[2] -= result.travel; diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index 1b74765ddc..456755aa24 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -900,7 +900,7 @@ void CPUParticles3D::_particles_process(double p_delta) { } // rotate spread to direction Vector3 binormal = Vector3(0.0, 1.0, 0.0).cross(direction_nrm); - if (binormal.length_squared() < 0.00000001) { + if (binormal.length_squared() < 0.00000001f) { // direction is parallel to Y. Choose Z as the binormal. binormal = Vector3(0.0, 0.0, 1.0); } @@ -1084,19 +1084,19 @@ void CPUParticles3D::_particles_process(double p_delta) { position.z = 0.0; } //apply linear acceleration - force += p.velocity.length() > 0.0 ? p.velocity.normalized() * tex_linear_accel * Math::lerp(parameters_min[PARAM_LINEAR_ACCEL], parameters_max[PARAM_LINEAR_ACCEL], rand_from_seed(alt_seed)) : Vector3(); + force += p.velocity.length() > 0.0f ? p.velocity.normalized() * tex_linear_accel * Math::lerp(parameters_min[PARAM_LINEAR_ACCEL], parameters_max[PARAM_LINEAR_ACCEL], rand_from_seed(alt_seed)) : Vector3(); //apply radial acceleration Vector3 org = emission_xform.origin; Vector3 diff = position - org; - force += diff.length() > 0.0 ? diff.normalized() * (tex_radial_accel)*Math::lerp(parameters_min[PARAM_RADIAL_ACCEL], parameters_max[PARAM_RADIAL_ACCEL], rand_from_seed(alt_seed)) : Vector3(); + force += diff.length() > 0.0f ? diff.normalized() * (tex_radial_accel)*Math::lerp(parameters_min[PARAM_RADIAL_ACCEL], parameters_max[PARAM_RADIAL_ACCEL], rand_from_seed(alt_seed)) : Vector3(); if (particle_flags[PARTICLE_FLAG_DISABLE_Z]) { Vector2 yx = Vector2(diff.y, diff.x); Vector2 yx2 = (yx * Vector2(-1.0, 1.0)).normalized(); - force += yx.length() > 0.0 ? Vector3(yx2.x, yx2.y, 0.0) * (tex_tangential_accel * Math::lerp(parameters_min[PARAM_TANGENTIAL_ACCEL], parameters_max[PARAM_TANGENTIAL_ACCEL], rand_from_seed(alt_seed))) : Vector3(); + force += yx.length() > 0.0f ? Vector3(yx2.x, yx2.y, 0.0f) * (tex_tangential_accel * Math::lerp(parameters_min[PARAM_TANGENTIAL_ACCEL], parameters_max[PARAM_TANGENTIAL_ACCEL], rand_from_seed(alt_seed))) : Vector3(); } else { Vector3 crossDiff = diff.normalized().cross(gravity.normalized()); - force += crossDiff.length() > 0.0 ? crossDiff.normalized() * (tex_tangential_accel * Math::lerp(parameters_min[PARAM_TANGENTIAL_ACCEL], parameters_max[PARAM_TANGENTIAL_ACCEL], rand_from_seed(alt_seed))) : Vector3(); + force += crossDiff.length() > 0.0f ? crossDiff.normalized() * (tex_tangential_accel * Math::lerp(parameters_min[PARAM_TANGENTIAL_ACCEL], parameters_max[PARAM_TANGENTIAL_ACCEL], rand_from_seed(alt_seed))) : Vector3(); } //apply attractor forces p.velocity += force * local_delta; @@ -1196,7 +1196,7 @@ void CPUParticles3D::_particles_process(double p_delta) { if (particle_flags[PARTICLE_FLAG_DISABLE_Z]) { if (particle_flags[PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY]) { - if (p.velocity.length() > 0.0) { + if (p.velocity.length() > 0.0f) { p.transform.basis.set_column(1, p.velocity.normalized()); } else { p.transform.basis.set_column(1, p.transform.basis.get_column(1)); @@ -1213,7 +1213,7 @@ void CPUParticles3D::_particles_process(double p_delta) { } else { //orient particle Y towards velocity if (particle_flags[PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY]) { - if (p.velocity.length() > 0.0) { + if (p.velocity.length() > 0.0f) { p.transform.basis.set_column(1, p.velocity.normalized()); } else { p.transform.basis.set_column(1, p.transform.basis.get_column(1).normalized()); diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp index 5bc827270e..3e2c11e093 100644 --- a/scene/3d/gpu_particles_collision_3d.cpp +++ b/scene/3d/gpu_particles_collision_3d.cpp @@ -330,7 +330,7 @@ void GPUParticlesCollisionSDF3D::_find_closest_distance(const Vector3 &p_pos, co bool pass = true; if (!p_bvh[p_bvh_cell].bounds.has_point(p_pos)) { //outside, find closest point - Vector3 he = p_bvh[p_bvh_cell].bounds.size * 0.5; + Vector3 he = p_bvh[p_bvh_cell].bounds.size * 0.5f; Vector3 center = p_bvh[p_bvh_cell].bounds.position + he; Vector3 rel = (p_pos - center).abs(); diff --git a/scene/3d/physics/character_body_3d.cpp b/scene/3d/physics/character_body_3d.cpp index 19bebc581b..71f86af35d 100644 --- a/scene/3d/physics/character_body_3d.cpp +++ b/scene/3d/physics/character_body_3d.cpp @@ -183,7 +183,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo // If we hit a ceiling platform, we set the vertical velocity to at least the platform one. if (collision_state.ceiling && platform_ceiling_velocity != Vector3() && platform_ceiling_velocity.dot(up_direction) < 0) { // If ceiling sliding is on, only apply when the ceiling is flat or when the motion is upward. - if (!slide_on_ceiling || motion.dot(up_direction) < 0 || (ceiling_normal + up_direction).length() < 0.01) { + if (!slide_on_ceiling || motion.dot(up_direction) < 0 || (ceiling_normal + up_direction).length() < 0.01f) { apply_ceiling_velocity = true; Vector3 ceiling_vertical_velocity = up_direction * up_direction.dot(platform_ceiling_velocity); Vector3 motion_vertical_velocity = up_direction * up_direction.dot(velocity); @@ -193,7 +193,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo } } - if (collision_state.floor && floor_stop_on_slope && (velocity.normalized() + up_direction).length() < 0.01) { + if (collision_state.floor && floor_stop_on_slope && (velocity.normalized() + up_direction).length() < 0.01f) { Transform3D gt = get_global_transform(); if (result.travel.length() <= margin + CMP_EPSILON) { gt.origin -= result.travel; @@ -232,7 +232,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo // Cancel the motion. Transform3D gt = get_global_transform(); real_t travel_total = result.travel.length(); - real_t cancel_dist_max = MIN(0.1, margin * 20); + real_t cancel_dist_max = MIN(0.1f, margin * 20.0f); if (travel_total <= margin + CMP_EPSILON) { gt.origin -= result.travel; result.travel = Vector3(); // Cancel for constant speed computation. diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp index dd4b0a2bb3..6cc01c2580 100644 --- a/scene/3d/voxelizer.cpp +++ b/scene/3d/voxelizer.cpp @@ -614,7 +614,7 @@ void Voxelizer::_fixup_plot(int p_idx, int p_level) { bake_cells.write[p_idx].normal[2] /= alpha; Vector3 n(bake_cells[p_idx].normal[0], bake_cells[p_idx].normal[1], bake_cells[p_idx].normal[2]); - if (n.length() < 0.01) { + if (n.length() < 0.01f) { //too much fight over normal, zero it bake_cells.write[p_idx].normal[0] = 0; bake_cells.write[p_idx].normal[1] = 0; diff --git a/scene/gui/color_picker_shape.cpp b/scene/gui/color_picker_shape.cpp index 460e2c7292..20491ce6b6 100644 --- a/scene/gui/color_picker_shape.cpp +++ b/scene/gui/color_picker_shape.cpp @@ -745,7 +745,7 @@ void ColorPickerShapeWheel::_wheel_input(const Ref &p_event) { if (is_click && !spinning) { real_t dist = center.distance_to(event_position); - if (dist >= center.x * WHEEL_RADIUS * 2.0 && dist <= center.x) { + if (dist >= center.x * (WHEEL_RADIUS * 2.0f) && dist <= center.x) { spinning = true; if (!wheel_focused) { cursor_editing = true; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index d0e4145acc..1a9d863f98 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2056,7 +2056,7 @@ void Viewport::_gui_input_event(Ref p_event) { Viewport *section_root = get_section_root_viewport(); if (!gui.drag_attempted && gui.mouse_focus && section_root && !section_root->gui.global_dragging && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { gui.drag_accum += mm->get_relative(); - float len = gui.drag_accum.length(); + real_t len = gui.drag_accum.length(); if (len > gui.drag_threshold) { { // Attempt grab, try parent controls too. CanvasItem *ci = gui.mouse_focus;