Split Geometry singleton into Geometry2D and Geometry3D

Extra `_2d` suffixes are removed from 2D methods accoringly.
This commit is contained in:
Andrii Doroshenko (Xrayez) 2020-05-25 20:20:45 +03:00
parent 2709ddb163
commit 69d5de632e
70 changed files with 1503 additions and 1379 deletions

View file

@ -32,6 +32,7 @@
#include "collision_object_2d.h"
#include "core/engine.h"
#include "core/math/geometry_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
@ -75,7 +76,7 @@ void CollisionPolygon2D::_build_polygon() {
}
Vector<Vector<Vector2>> CollisionPolygon2D::_decompose_in_convex() {
Vector<Vector<Vector2>> decomp = Geometry::decompose_polygon_in_convex(polygon);
Vector<Vector<Vector2>> decomp = Geometry2D::decompose_polygon_in_convex(polygon);
return decomp;
}
@ -224,7 +225,7 @@ bool CollisionPolygon2D::_edit_use_rect() const {
}
bool CollisionPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
return Geometry::is_point_in_polygon(p_point, Variant(polygon));
return Geometry2D::is_point_in_polygon(p_point, Variant(polygon));
}
#endif

View file

@ -29,6 +29,7 @@
/*************************************************************************/
#include "light_occluder_2d.h"
#include "core/math/geometry_2d.h"
#include "core/engine.h"
@ -68,12 +69,12 @@ Rect2 OccluderPolygon2D::_edit_get_rect() const {
bool OccluderPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
if (closed) {
return Geometry::is_point_in_polygon(p_point, Variant(polygon));
return Geometry2D::is_point_in_polygon(p_point, Variant(polygon));
} else {
const real_t d = LINE_GRAB_WIDTH / 2 + p_tolerance;
const Vector2 *points = polygon.ptr();
for (int i = 0; i < polygon.size() - 1; i++) {
Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point, &points[i]);
Vector2 p = Geometry2D::get_closest_point_to_segment(p_point, &points[i]);
if (p.distance_to(p_point) <= d) {
return true;
}

View file

@ -31,6 +31,7 @@
#include "line_2d.h"
#include "core/core_string_names.h"
#include "core/math/geometry_2d.h"
#include "line_builder.h"
// Needed so we can bind functions
@ -72,7 +73,7 @@ bool Line2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc
const real_t d = _width / 2 + p_tolerance;
const Vector2 *points = _points.ptr();
for (int i = 0; i < _points.size() - 1; i++) {
Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point, &points[i]);
Vector2 p = Geometry2D::get_closest_point_to_segment(p_point, &points[i]);
if (p.distance_to(p_point) <= d) {
return true;
}

View file

@ -31,6 +31,7 @@
#include "navigation_agent_2d.h"
#include "core/engine.h"
#include "core/math/geometry_2d.h"
#include "scene/2d/navigation_2d.h"
#include "servers/navigation_server_2d.h"
@ -304,7 +305,7 @@ void NavigationAgent2D::update_navigation() {
Vector2 segment[2];
segment[0] = navigation_path[nav_path_index - 1];
segment[1] = navigation_path[nav_path_index];
Vector2 p = Geometry::get_closest_point_to_segment_2d(o, segment);
Vector2 p = Geometry2D::get_closest_point_to_segment(o, segment);
if (o.distance_to(p) >= path_max_distance) {
// To faraway, reload path
reload_path = true;

View file

@ -32,6 +32,7 @@
#include "core/core_string_names.h"
#include "core/engine.h"
#include "core/math/geometry_2d.h"
#include "core/os/mutex.h"
#include "navigation_2d.h"
#include "servers/navigation_server_2d.h"
@ -73,7 +74,7 @@ bool NavigationPolygon::_edit_is_selected_on_click(const Point2 &p_point, double
if (outline_size < 3) {
continue;
}
if (Geometry::is_point_in_polygon(p_point, Variant(outline))) {
if (Geometry2D::is_point_in_polygon(p_point, Variant(outline))) {
return true;
}
}
@ -269,7 +270,7 @@ void NavigationPolygon::make_polygons_from_outlines() {
const Vector2 *r2 = ol2.ptr();
for (int l = 0; l < olsize2; l++) {
if (Geometry::segment_intersects_segment_2d(r[0], outside_point, r2[l], r2[(l + 1) % olsize2], nullptr)) {
if (Geometry2D::segment_intersects_segment(r[0], outside_point, r2[l], r2[(l + 1) % olsize2], nullptr)) {
interscount++;
}
}

View file

@ -31,6 +31,7 @@
#include "path_2d.h"
#include "core/engine.h"
#include "core/math/geometry_2d.h"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
@ -73,7 +74,7 @@ bool Path2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc
real_t frac = j / 8.0;
s[1] = curve->interpolate(i, frac);
Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point, s);
Vector2 p = Geometry2D::get_closest_point_to_segment(p_point, s);
if (p.distance_to(p_point) <= p_tolerance) {
return true;
}

View file

@ -30,7 +30,7 @@
#include "polygon_2d.h"
#include "core/math/geometry.h"
#include "core/math/geometry_2d.h"
#include "skeleton_2d.h"
#ifdef TOOLS_ENABLED
@ -86,7 +86,7 @@ bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toler
if (internal_vertices > 0) {
polygon2d.resize(polygon2d.size() - internal_vertices);
}
return Geometry::is_point_in_polygon(p_point - get_offset(), polygon2d);
return Geometry2D::is_point_in_polygon(p_point - get_offset(), polygon2d);
}
#endif
@ -300,7 +300,7 @@ void Polygon2D::_notification(int p_what) {
}
if (invert || polygons.size() == 0) {
Vector<int> indices = Geometry::triangulate_polygon(points);
Vector<int> indices = Geometry2D::triangulate_polygon(points);
if (indices.size()) {
RS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, normal_map.is_valid() ? normal_map->get_rid() : RID(), specular_map.is_valid() ? specular_map->get_rid() : RID(), Color(specular_color.r, specular_color.g, specular_color.b, shininess));
}
@ -323,7 +323,7 @@ void Polygon2D::_notification(int p_what) {
ERR_CONTINUE(idx < 0 || idx >= points.size());
tmp_points.write[j] = points[r[j]];
}
Vector<int> indices = Geometry::triangulate_polygon(tmp_points);
Vector<int> indices = Geometry2D::triangulate_polygon(tmp_points);
int ic2 = indices.size();
const int *r2 = indices.ptr();