summaryrefslogtreecommitdiff
path: root/servers/physics_3d
diff options
context:
space:
mode:
authorAndrii Doroshenko (Xrayez) <xrayez@gmail.com>2020-05-25 20:20:45 +0300
committerAndrii Doroshenko (Xrayez) <xrayez@gmail.com>2020-05-27 14:28:34 +0300
commit69d5de632e04d48a247d50c1dc2c09322129c73a (patch)
tree4b61660efa246c19beac2e0d32d40da3bad10bfc /servers/physics_3d
parent2709ddb163799d33b632eeeea0cdf3cd75ad16b6 (diff)
Split `Geometry` singleton into `Geometry2D` and `Geometry3D`
Extra `_2d` suffixes are removed from 2D methods accoringly.
Diffstat (limited to 'servers/physics_3d')
-rw-r--r--servers/physics_3d/collision_solver_3d_sat.cpp42
-rw-r--r--servers/physics_3d/shape_3d_sw.cpp34
-rw-r--r--servers/physics_3d/shape_3d_sw.h6
3 files changed, 41 insertions, 41 deletions
diff --git a/servers/physics_3d/collision_solver_3d_sat.cpp b/servers/physics_3d/collision_solver_3d_sat.cpp
index 736222c7d9..85f55ad66d 100644
--- a/servers/physics_3d/collision_solver_3d_sat.cpp
+++ b/servers/physics_3d/collision_solver_3d_sat.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "collision_solver_3d_sat.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.02
@@ -67,7 +67,7 @@ static void _generate_contacts_point_edge(const Vector3 *p_points_A, int p_point
ERR_FAIL_COND(p_point_count_B != 2);
#endif
- Vector3 closest_B = Geometry::get_closest_point_to_segment_uncapped(*p_points_A, p_points_B);
+ Vector3 closest_B = Geometry3D::get_closest_point_to_segment_uncapped(*p_points_A, p_points_B);
p_callback->call(*p_points_A, closest_B);
}
@@ -124,7 +124,7 @@ static void _generate_contacts_edge_edge(const Vector3 *p_points_A, int p_point_
}
Vector3 closest_A = p_points_A[0] + rel_A * d;
- Vector3 closest_B = Geometry::get_closest_point_to_segment_uncapped(closest_A, p_points_B);
+ Vector3 closest_B = Geometry3D::get_closest_point_to_segment_uncapped(closest_A, p_points_B);
p_callback->call(closest_A, closest_B);
}
@@ -542,11 +542,11 @@ static void _collision_sphere_convex_polygon(const Shape3DSW *p_a, const Transfo
return;
}
- const Geometry::MeshData &mesh = convex_polygon_B->get_mesh();
+ const Geometry3D::MeshData &mesh = convex_polygon_B->get_mesh();
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int face_count = mesh.faces.size();
- const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges = mesh.edges.ptr();
int edge_count = mesh.edges.size();
const Vector3 *vertices = mesh.vertices.ptr();
int vertex_count = mesh.vertices.size();
@@ -839,11 +839,11 @@ static void _collision_box_convex_polygon(const Shape3DSW *p_a, const Transform
return;
}
- const Geometry::MeshData &mesh = convex_polygon_B->get_mesh();
+ const Geometry3D::MeshData &mesh = convex_polygon_B->get_mesh();
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int face_count = mesh.faces.size();
- const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges = mesh.edges.ptr();
int edge_count = mesh.edges.size();
const Vector3 *vertices = mesh.vertices.ptr();
int vertex_count = mesh.vertices.size();
@@ -1124,11 +1124,11 @@ static void _collision_capsule_convex_polygon(const Shape3DSW *p_a, const Transf
return;
}
- const Geometry::MeshData &mesh = convex_polygon_B->get_mesh();
+ const Geometry3D::MeshData &mesh = convex_polygon_B->get_mesh();
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int face_count = mesh.faces.size();
- const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges = mesh.edges.ptr();
int edge_count = mesh.edges.size();
const Vector3 *vertices = mesh.vertices.ptr();
@@ -1257,20 +1257,20 @@ static void _collision_convex_polygon_convex_polygon(const Shape3DSW *p_a, const
return;
}
- const Geometry::MeshData &mesh_A = convex_polygon_A->get_mesh();
+ const Geometry3D::MeshData &mesh_A = convex_polygon_A->get_mesh();
- const Geometry::MeshData::Face *faces_A = mesh_A.faces.ptr();
+ const Geometry3D::MeshData::Face *faces_A = mesh_A.faces.ptr();
int face_count_A = mesh_A.faces.size();
- const Geometry::MeshData::Edge *edges_A = mesh_A.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges_A = mesh_A.edges.ptr();
int edge_count_A = mesh_A.edges.size();
const Vector3 *vertices_A = mesh_A.vertices.ptr();
int vertex_count_A = mesh_A.vertices.size();
- const Geometry::MeshData &mesh_B = convex_polygon_B->get_mesh();
+ const Geometry3D::MeshData &mesh_B = convex_polygon_B->get_mesh();
- const Geometry::MeshData::Face *faces_B = mesh_B.faces.ptr();
+ const Geometry3D::MeshData::Face *faces_B = mesh_B.faces.ptr();
int face_count_B = mesh_B.faces.size();
- const Geometry::MeshData::Edge *edges_B = mesh_B.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges_B = mesh_B.edges.ptr();
int edge_count_B = mesh_B.edges.size();
const Vector3 *vertices_B = mesh_B.vertices.ptr();
int vertex_count_B = mesh_B.vertices.size();
@@ -1362,11 +1362,11 @@ static void _collision_convex_polygon_face(const Shape3DSW *p_a, const Transform
SeparatorAxisTest<ConvexPolygonShape3DSW, FaceShape3DSW, withMargin> separator(convex_polygon_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
- const Geometry::MeshData &mesh = convex_polygon_A->get_mesh();
+ const Geometry3D::MeshData &mesh = convex_polygon_A->get_mesh();
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int face_count = mesh.faces.size();
- const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges = mesh.edges.ptr();
int edge_count = mesh.edges.size();
const Vector3 *vertices = mesh.vertices.ptr();
int vertex_count = mesh.vertices.size();
diff --git a/servers/physics_3d/shape_3d_sw.cpp b/servers/physics_3d/shape_3d_sw.cpp
index eb0e87cec0..ca33241d29 100644
--- a/servers/physics_3d/shape_3d_sw.cpp
+++ b/servers/physics_3d/shape_3d_sw.cpp
@@ -30,7 +30,7 @@
#include "shape_3d_sw.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#include "core/math/quick_hull.h"
#include "core/sort_array.h"
@@ -195,7 +195,7 @@ Vector3 RayShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
Vector3(0, 0, length)
};
- return Geometry::get_closest_point_to_segment(p_point, s);
+ return Geometry3D::get_closest_point_to_segment(p_point, s);
}
Vector3 RayShape3DSW::get_moment_of_inertia(real_t p_mass) const {
@@ -252,7 +252,7 @@ void SphereShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *
}
bool SphereShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
- return Geometry::segment_intersects_sphere(p_begin, p_end, Vector3(), radius, &r_result, &r_normal);
+ return Geometry3D::segment_intersects_sphere(p_begin, p_end, Vector3(), radius, &r_result, &r_normal);
}
bool SphereShape3DSW::intersect_point(const Vector3 &p_point) const {
@@ -441,7 +441,7 @@ Vector3 BoxShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
s[1] = closest_vertex;
s[1][i] = -s[1][i]; //edge
- Vector3 closest_edge = Geometry::get_closest_point_to_segment(p_point, s);
+ Vector3 closest_edge = Geometry3D::get_closest_point_to_segment(p_point, s);
float d = p_point.distance_to(closest_edge);
if (d < min_distance) {
@@ -540,7 +540,7 @@ bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &
// test against cylinder and spheres :-|
- collided = Geometry::segment_intersects_cylinder(p_begin, p_end, height, radius, &auxres, &auxn);
+ collided = Geometry3D::segment_intersects_cylinder(p_begin, p_end, height, radius, &auxres, &auxn);
if (collided) {
real_t d = norm.dot(auxres);
@@ -552,7 +552,7 @@ bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &
}
}
- collided = Geometry::segment_intersects_sphere(p_begin, p_end, Vector3(0, 0, height * 0.5), radius, &auxres, &auxn);
+ collided = Geometry3D::segment_intersects_sphere(p_begin, p_end, Vector3(0, 0, height * 0.5), radius, &auxres, &auxn);
if (collided) {
real_t d = norm.dot(auxres);
@@ -564,7 +564,7 @@ bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &
}
}
- collided = Geometry::segment_intersects_sphere(p_begin, p_end, Vector3(0, 0, height * -0.5), radius, &auxres, &auxn);
+ collided = Geometry3D::segment_intersects_sphere(p_begin, p_end, Vector3(0, 0, height * -0.5), radius, &auxres, &auxn);
if (collided) {
real_t d = norm.dot(auxres);
@@ -600,7 +600,7 @@ Vector3 CapsuleShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
Vector3(0, 0, height * 0.5),
};
- Vector3 p = Geometry::get_closest_point_to_segment(p_point, s);
+ Vector3 p = Geometry3D::get_closest_point_to_segment(p_point, s);
if (p.distance_to(p_point) < radius) {
return p_point;
@@ -691,10 +691,10 @@ Vector3 ConvexPolygonShape3DSW::get_support(const Vector3 &p_normal) const {
}
void ConvexPolygonShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int fc = mesh.faces.size();
- const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges = mesh.edges.ptr();
int ec = mesh.edges.size();
const Vector3 *vertices = mesh.vertices.ptr();
@@ -755,7 +755,7 @@ void ConvexPolygonShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Ve
}
bool ConvexPolygonShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int fc = mesh.faces.size();
const Vector3 *vertices = mesh.vertices.ptr();
@@ -793,7 +793,7 @@ bool ConvexPolygonShape3DSW::intersect_segment(const Vector3 &p_begin, const Vec
}
bool ConvexPolygonShape3DSW::intersect_point(const Vector3 &p_point) const {
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int fc = mesh.faces.size();
for (int i = 0; i < fc; i++) {
@@ -806,7 +806,7 @@ bool ConvexPolygonShape3DSW::intersect_point(const Vector3 &p_point) const {
}
Vector3 ConvexPolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int fc = mesh.faces.size();
const Vector3 *vertices = mesh.vertices.ptr();
@@ -844,7 +844,7 @@ Vector3 ConvexPolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) con
Vector3 min_point;
//check edges
- const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges = mesh.edges.ptr();
int ec = mesh.edges.size();
for (int i = 0; i < ec; i++) {
Vector3 s[2] = {
@@ -852,7 +852,7 @@ Vector3 ConvexPolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) con
vertices[edges[i].b]
};
- Vector3 closest = Geometry::get_closest_point_to_segment(p_point, s);
+ Vector3 closest = Geometry3D::get_closest_point_to_segment(p_point, s);
float d = closest.distance_to(p_point);
if (d < min_distance) {
min_distance = d;
@@ -986,7 +986,7 @@ void FaceShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_
}
bool FaceShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
- bool c = Geometry::segment_intersects_triangle(p_begin, p_end, vertex[0], vertex[1], vertex[2], &r_result);
+ bool c = Geometry3D::segment_intersects_triangle(p_begin, p_end, vertex[0], vertex[1], vertex[2], &r_result);
if (c) {
r_normal = Plane(vertex[0], vertex[1], vertex[2]).normal;
if (r_normal.dot(p_end - p_begin) > 0) {
@@ -1095,7 +1095,7 @@ void ConcavePolygonShape3DSW::_cull_segment(int p_idx, _SegmentCullParams *p_par
p_params->vertices[p_params->faces[bvh->face_index].indices[2]]
};
- if (Geometry::segment_intersects_triangle(
+ if (Geometry3D::segment_intersects_triangle(
p_params->from,
p_params->to,
vertices[0],
diff --git a/servers/physics_3d/shape_3d_sw.h b/servers/physics_3d/shape_3d_sw.h
index 848a1135ad..2a2cd42255 100644
--- a/servers/physics_3d/shape_3d_sw.h
+++ b/servers/physics_3d/shape_3d_sw.h
@@ -31,7 +31,7 @@
#ifndef SHAPE_SW_H
#define SHAPE_SW_H
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#include "servers/physics_server_3d.h"
/*
@@ -252,12 +252,12 @@ public:
};
struct ConvexPolygonShape3DSW : public Shape3DSW {
- Geometry::MeshData mesh;
+ Geometry3D::MeshData mesh;
void _setup(const Vector<Vector3> &p_vertices);
public:
- const Geometry::MeshData &get_mesh() const { return mesh; }
+ const Geometry3D::MeshData &get_mesh() const { return mesh; }
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; }