diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-07-21 11:16:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-21 11:16:19 +0200 |
commit | d4bbdb83674526a80ae6d0d2c080768da7629804 (patch) | |
tree | 9fbe5a4ba2bf8431b05845378ddaad6c07afc805 /modules | |
parent | 8cc599db645a356ca6af3bc15e7574fa6e3ada0e (diff) | |
parent | 78b0a7da0398dc8c6447b1439a6d07059311c028 (diff) |
Merge pull request #50521 from aaronfranke/iseqapprox
Use `is_equal_approx` in more places
Diffstat (limited to 'modules')
-rw-r--r-- | modules/csg/csg.cpp | 10 | ||||
-rw-r--r-- | modules/csg/csg_shape.cpp | 4 | ||||
-rw-r--r-- | modules/fbx/data/fbx_mesh_data.cpp | 4 | ||||
-rw-r--r-- | modules/navigation/nav_map.cpp | 6 |
4 files changed, 12 insertions, 12 deletions
diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 5a37486568..57206ae18b 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -42,7 +42,7 @@ inline static bool is_snapable(const Vector3 &p_point1, const Vector3 &p_point2, inline static Vector2 interpolate_segment_uv(const Vector2 p_segement_points[2], const Vector2 p_uvs[2], const Vector2 &p_interpolation_point) { float segment_length = (p_segement_points[1] - p_segement_points[0]).length(); - if (segment_length < CMP_EPSILON) { + if (p_segement_points[0].is_equal_approx(p_segement_points[1])) { return p_uvs[0]; } @@ -53,13 +53,13 @@ inline static Vector2 interpolate_segment_uv(const Vector2 p_segement_points[2], } inline static Vector2 interpolate_triangle_uv(const Vector2 p_vertices[3], const Vector2 p_uvs[3], const Vector2 &p_interpolation_point) { - if (p_interpolation_point.distance_squared_to(p_vertices[0]) < CMP_EPSILON2) { + if (p_interpolation_point.is_equal_approx(p_vertices[0])) { return p_uvs[0]; } - if (p_interpolation_point.distance_squared_to(p_vertices[1]) < CMP_EPSILON2) { + if (p_interpolation_point.is_equal_approx(p_vertices[1])) { return p_uvs[1]; } - if (p_interpolation_point.distance_squared_to(p_vertices[2]) < CMP_EPSILON2) { + if (p_interpolation_point.is_equal_approx(p_vertices[2])) { return p_uvs[2]; } @@ -589,7 +589,7 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de Vector3 intersection_point; // Check if faces are co-planar. - if ((current_normal - face_normal).length_squared() < CMP_EPSILON2 && + if (current_normal.is_equal_approx(face_normal) && is_point_in_triangle(face_center, current_points)) { // Only add an intersection if not a B face. if (!face.from_b) { diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 53424f2cfd..729dc2f8fc 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -778,7 +778,7 @@ CSGBrush *CSGMesh3D::_build_brush() { } } - bool flat = normal[0].distance_to(normal[1]) < CMP_EPSILON && normal[0].distance_to(normal[2]) < CMP_EPSILON; + bool flat = normal[0].is_equal_approx(normal[1]) && normal[0].is_equal_approx(normal[2]); vw[as + j + 0] = vertex[0]; vw[as + j + 1] = vertex[1]; @@ -820,7 +820,7 @@ CSGBrush *CSGMesh3D::_build_brush() { } } - bool flat = normal[0].distance_to(normal[1]) < CMP_EPSILON && normal[0].distance_to(normal[2]) < CMP_EPSILON; + bool flat = normal[0].is_equal_approx(normal[1]) && normal[0].is_equal_approx(normal[2]); vw[as + j + 0] = vertex[0]; vw[as + j + 1] = vertex[1]; diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp index 0d33b8e7c6..8b4b1e08b3 100644 --- a/modules/fbx/data/fbx_mesh_data.cpp +++ b/modules/fbx/data/fbx_mesh_data.cpp @@ -525,7 +525,7 @@ void FBXMeshData::reorganize_vertices( } const Vector3 vert_poly_normal = *nrml_arr->getptr(*pid); - if ((this_vert_poly_normal - vert_poly_normal).length_squared() > CMP_EPSILON) { + if (!vert_poly_normal.is_equal_approx(this_vert_poly_normal)) { // Yes this polygon need duplication. need_duplication = true; break; @@ -586,7 +586,7 @@ void FBXMeshData::reorganize_vertices( continue; } const Vector2 vert_poly_uv = *uvs->getptr(*pid); - if (((*this_vert_poly_uv) - vert_poly_uv).length_squared() > CMP_EPSILON) { + if (!vert_poly_uv.is_equal_approx(*this_vert_poly_uv)) { // Yes this polygon need duplication. need_duplication = true; break; diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp index 41306f0687..3150ca0bc8 100644 --- a/modules/navigation/nav_map.cpp +++ b/modules/navigation/nav_map.cpp @@ -734,7 +734,7 @@ void NavMap::dispatch_callbacks() { void NavMap::clip_path(const std::vector<gd::NavigationPoly> &p_navigation_polys, Vector<Vector3> &path, const gd::NavigationPoly *from_poly, const Vector3 &p_to_point, const gd::NavigationPoly *p_to_poly) const { Vector3 from = path[path.size() - 1]; - if (from.distance_to(p_to_point) < CMP_EPSILON) { + if (from.is_equal_approx(p_to_point)) { return; } Plane cut_plane; @@ -752,10 +752,10 @@ void NavMap::clip_path(const std::vector<gd::NavigationPoly> &p_navigation_polys ERR_FAIL_COND(from_poly->back_navigation_poly_id == -1); from_poly = &p_navigation_polys[from_poly->back_navigation_poly_id]; - if (pathway_start.distance_to(pathway_end) > CMP_EPSILON) { + if (!pathway_start.is_equal_approx(pathway_end)) { Vector3 inters; if (cut_plane.intersects_segment(pathway_start, pathway_end, &inters)) { - if (inters.distance_to(p_to_point) > CMP_EPSILON && inters.distance_to(path[path.size() - 1]) > CMP_EPSILON) { + if (!inters.is_equal_approx(p_to_point) && !inters.is_equal_approx(path[path.size() - 1])) { path.push_back(inters); } } |