diff options
author | Andrii Doroshenko (Xrayez) <xrayez@gmail.com> | 2020-05-25 20:20:45 +0300 |
---|---|---|
committer | Andrii Doroshenko (Xrayez) <xrayez@gmail.com> | 2020-05-27 14:28:34 +0300 |
commit | 69d5de632e04d48a247d50c1dc2c09322129c73a (patch) | |
tree | 4b61660efa246c19beac2e0d32d40da3bad10bfc /modules | |
parent | 2709ddb163799d33b632eeeea0cdf3cd75ad16b6 (diff) |
Split `Geometry` singleton into `Geometry2D` and `Geometry3D`
Extra `_2d` suffixes are removed from 2D methods accoringly.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/bullet/shape_bullet.h | 2 | ||||
-rw-r--r-- | modules/csg/csg.cpp | 14 | ||||
-rw-r--r-- | modules/csg/csg_gizmos.cpp | 8 | ||||
-rw-r--r-- | modules/csg/csg_shape.cpp | 3 | ||||
-rw-r--r-- | modules/gdnavigation/nav_map.cpp | 4 | ||||
-rw-r--r-- | modules/gdnavigation/navigation_mesh_generator.cpp | 4 | ||||
-rw-r--r-- | modules/gridmap/grid_map_editor_plugin.cpp | 1 | ||||
-rw-r--r-- | modules/lightmapper_rd/lightmapper_rd.cpp | 12 |
8 files changed, 24 insertions, 24 deletions
diff --git a/modules/bullet/shape_bullet.h b/modules/bullet/shape_bullet.h index b24ded574f..a35a1d8a18 100644 --- a/modules/bullet/shape_bullet.h +++ b/modules/bullet/shape_bullet.h @@ -31,7 +31,7 @@ #ifndef SHAPE_BULLET_H #define SHAPE_BULLET_H -#include "core/math/geometry.h" +#include "core/math/geometry_3d.h" #include "core/variant.h" #include "rid_bullet.h" #include "servers/physics_server_3d.h" diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index df798623f9..ded0b970dc 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -30,7 +30,7 @@ #include "csg.h" -#include "core/math/geometry.h" +#include "core/math/geometry_2d.h" #include "core/math/math_funcs.h" #include "core/sort_array.h" @@ -964,7 +964,7 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_ face_points[face_edge_idx], face_points[(face_edge_idx + 1) % 3] }; - Vector2 closest_point = Geometry::get_closest_point_to_segment_2d(point_2D, edge_points); + Vector2 closest_point = Geometry2D::get_closest_point_to_segment(point_2D, edge_points); if ((closest_point - point_2D).length_squared() < vertex_snap2) { int opposite_vertex_idx = face.vertex_idx[(face_edge_idx + 2) % 3]; @@ -1028,7 +1028,7 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s // First check if the ends of the segment are on the edge. bool on_edge = false; for (int edge_point_idx = 0; edge_point_idx < 2; ++edge_point_idx) { - intersection_point = Geometry::get_closest_point_to_segment_2d(p_segment_points[edge_point_idx], edge_points); + intersection_point = Geometry2D::get_closest_point_to_segment(p_segment_points[edge_point_idx], edge_points); if ((intersection_point - p_segment_points[edge_point_idx]).length_squared() < vertex_snap2) { on_edge = true; break; @@ -1036,7 +1036,7 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s } // Else check if the segment intersects the edge. - if (on_edge || Geometry::segment_intersects_segment_2d(p_segment_points[0], p_segment_points[1], edge_points[0], edge_points[1], &intersection_point)) { + if (on_edge || Geometry2D::segment_intersects_segment(p_segment_points[0], p_segment_points[1], edge_points[0], edge_points[1], &intersection_point)) { // Check if intersection point is an edge point. if ((intersection_point - edge_points[0]).length_squared() < vertex_snap2 || (intersection_point - edge_points[1]).length_squared() < vertex_snap2) { @@ -1074,7 +1074,7 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s } // If opposite point is on the segemnt, add its index to segment indices too. - Vector2 closest_point = Geometry::get_closest_point_to_segment_2d(vertices[opposite_vertex_idx].point, p_segment_points); + Vector2 closest_point = Geometry2D::get_closest_point_to_segment(vertices[opposite_vertex_idx].point, p_segment_points); if ((closest_point - vertices[opposite_vertex_idx].point).length_squared() < vertex_snap2) { _add_vertex_idx_sorted(r_segment_indices, opposite_vertex_idx); } @@ -1141,7 +1141,7 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) { uvs[(face_edge_idx + 1) % 3] }; - Vector2 closest_point = Geometry::get_closest_point_to_segment_2d(p_point, edge_points); + Vector2 closest_point = Geometry2D::get_closest_point_to_segment(p_point, edge_points); if ((closest_point - p_point).length_squared() < vertex_snap2) { on_edge = true; @@ -1192,7 +1192,7 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) { } // If not on an edge, check if the point is inside the face. - if (!on_edge && Geometry::is_point_in_triangle(p_point, face_vertices[0].point, face_vertices[1].point, face_vertices[2].point)) { + if (!on_edge && Geometry2D::is_point_in_triangle(p_point, face_vertices[0].point, face_vertices[1].point, face_vertices[2].point)) { // Add the point as a new vertex. Vertex2D new_vertex; new_vertex.point = p_point; diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp index 9fa7dc1340..cce72770f5 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/csg_gizmos.cpp @@ -120,7 +120,7 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs); Vector3 ra, rb; - Geometry::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb); + Geometry3D::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb); float d = ra.x; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); @@ -139,7 +139,7 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca Vector3 axis; axis[p_idx] = 1.0; Vector3 ra, rb; - Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); + Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = ra[p_idx]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); @@ -168,7 +168,7 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca Vector3 axis; axis[p_idx == 0 ? 0 : 1] = 1.0; Vector3 ra, rb; - Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); + Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = axis.dot(ra); if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); @@ -191,7 +191,7 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca Vector3 axis; axis[0] = 1.0; Vector3 ra, rb; - Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); + Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = axis.dot(ra); if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 7df65b04c4..cea006364f 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "csg_shape.h" +#include "core/math/geometry_2d.h" #include "scene/3d/path_3d.h" void CSGShape3D::set_use_collision(bool p_enable) { @@ -1728,7 +1729,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { final_polygon.invert(); } - Vector<int> triangles = Geometry::triangulate_polygon(final_polygon); + Vector<int> triangles = Geometry2D::triangulate_polygon(final_polygon); if (triangles.size() < 3) { return nullptr; diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp index 4bea007104..7919e6a01f 100644 --- a/modules/gdnavigation/nav_map.cpp +++ b/modules/gdnavigation/nav_map.cpp @@ -155,7 +155,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p least_cost_poly->poly->points[(i + 1) % least_cost_poly->poly->points.size()].pos }; - const Vector3 new_entry = Geometry::get_closest_point_to_segment(least_cost_poly->entry, edge_line); + const Vector3 new_entry = Geometry3D::get_closest_point_to_segment(least_cost_poly->entry, edge_line); const float new_distance = least_cost_poly->entry.distance_to(new_entry) + least_cost_poly->traveled_distance; #else const float new_distance = least_cost_poly->poly->center.distance_to(edge.other_polygon->center) + least_cost_poly->traveled_distance; @@ -413,7 +413,7 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector for (size_t point_id = 0; point_id < p.points.size(); point_id += 1) { Vector3 a, b; - Geometry::get_closest_points_between_segments( + Geometry3D::get_closest_points_between_segments( p_from, p_to, p.points[point_id].pos, diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp index 7dc08fbf29..5329600e39 100644 --- a/modules/gdnavigation/navigation_mesh_generator.cpp +++ b/modules/gdnavigation/navigation_mesh_generator.cpp @@ -218,7 +218,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, ConvexPolygonShape3D *convex_polygon = Object::cast_to<ConvexPolygonShape3D>(*s); if (convex_polygon) { Vector<Vector3> varr = Variant(convex_polygon->get_points()); - Geometry::MeshData md; + Geometry3D::MeshData md; Error err = QuickHull::build(varr, md); @@ -226,7 +226,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, PackedVector3Array faces; for (int j = 0; j < md.faces.size(); ++j) { - Geometry::MeshData::Face face = md.faces[j]; + Geometry3D::MeshData::Face face = md.faces[j]; for (int k = 2; k < face.indices.size(); ++k) { faces.push_back(md.vertices[face.indices[0]]); diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 2bae43510a..3b0e78546d 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -35,7 +35,6 @@ #include "editor/plugins/node_3d_editor_plugin.h" #include "scene/3d/camera_3d.h" -#include "core/math/geometry.h" #include "core/os/keyboard.h" #include "scene/main/window.h" diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp index b55c73e9bc..4de523baa0 100644 --- a/modules/lightmapper_rd/lightmapper_rd.cpp +++ b/modules/lightmapper_rd/lightmapper_rd.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "lightmapper_rd.h" -#include "core/math/geometry.h" +#include "core/math/geometry_2d.h" #include "core/project_settings.h" #include "lm_blendseams.glsl.gen.h" #include "lm_compute.glsl.gen.h" @@ -137,7 +137,7 @@ void LightmapperRD::_plot_triangle_into_triangle_index_list(int p_size, const Ve { Vector3 qsize = aabb.size * 0.5; //quarter size, for fast aabb test - if (!Geometry::triangle_box_overlap(aabb.position + qsize, qsize, p_points)) { + if (!Geometry3D::triangle_box_overlap(aabb.position + qsize, qsize, p_points)) { //does not fit in child, go on continue; } @@ -198,7 +198,7 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_ int slices = 0; while (source_sizes.size() > 0) { - Vector<Vector3i> offsets = Geometry::partial_pack_rects(source_sizes, atlas_size); + Vector<Vector3i> offsets = Geometry2D::partial_pack_rects(source_sizes, atlas_size); Vector<int> new_indices; Vector<Vector2i> new_sources; for (int i = 0; i < offsets.size(); i++) { @@ -488,9 +488,9 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i } //generate SDF for raytracing - Vector<uint32_t> euclidean_pos = Geometry::generate_edf(solid, Vector3i(grid_size, grid_size, grid_size), false); - Vector<uint32_t> euclidean_neg = Geometry::generate_edf(solid, Vector3i(grid_size, grid_size, grid_size), true); - Vector<int8_t> sdf8 = Geometry::generate_sdf8(euclidean_pos, euclidean_neg); + Vector<uint32_t> euclidean_pos = Geometry3D::generate_edf(solid, Vector3i(grid_size, grid_size, grid_size), false); + Vector<uint32_t> euclidean_neg = Geometry3D::generate_edf(solid, Vector3i(grid_size, grid_size, grid_size), true); + Vector<int8_t> sdf8 = Geometry3D::generate_sdf8(euclidean_pos, euclidean_neg); /*****************************/ /*** CREATE GPU STRUCTURES ***/ |