summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2020-12-28 16:00:12 +0100
committerGitHub <noreply@github.com>2020-12-28 16:00:12 +0100
commit058f3fe069402978780f87ed383e3a72d4b3009e (patch)
treee0d0fff64ccd8bdc1dda36e7f695b6bc17c5bb52 /servers
parent18bbd6410f3ea9fad52fafe3fb90c44c4c130aaa (diff)
parenta24c38d1a814f5bc4979b99d6652f4bf2f2982c7 (diff)
Merge pull request #44149 from madmiraal/rename-tangent-orthogonal
Rename Vector2.tangent() to Vector2.orthogonal()
Diffstat (limited to 'servers')
-rw-r--r--servers/physics_2d/body_pair_2d_sw.cpp4
-rw-r--r--servers/physics_2d/collision_solver_2d_sat.cpp8
-rw-r--r--servers/physics_2d/joints_2d_sw.cpp10
-rw-r--r--servers/physics_2d/shape_2d_sw.cpp8
-rw-r--r--servers/physics_2d/shape_2d_sw.h4
-rw-r--r--servers/rendering/renderer_canvas_cull.cpp6
-rw-r--r--servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp2
7 files changed, 21 insertions, 21 deletions
diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp
index bb6629becb..b9f61acb12 100644
--- a/servers/physics_2d/body_pair_2d_sw.cpp
+++ b/servers/physics_2d/body_pair_2d_sw.cpp
@@ -409,7 +409,7 @@ bool BodyPair2DSW::setup(real_t p_step) {
kNormal += A->get_inv_inertia() * (c.rA.dot(c.rA) - rnA * rnA) + B->get_inv_inertia() * (c.rB.dot(c.rB) - rnB * rnB);
c.mass_normal = 1.0f / kNormal;
- Vector2 tangent = c.normal.tangent();
+ Vector2 tangent = c.normal.orthogonal();
real_t rtA = c.rA.dot(tangent);
real_t rtB = c.rB.dot(tangent);
real_t kTangent = A->get_inv_mass() + B->get_inv_mass();
@@ -469,7 +469,7 @@ void BodyPair2DSW::solve(real_t p_step) {
real_t vn = dv.dot(c.normal);
real_t vbn = dbv.dot(c.normal);
- Vector2 tangent = c.normal.tangent();
+ Vector2 tangent = c.normal.orthogonal();
real_t vt = dv.dot(tangent);
real_t jbn = (c.bias - vbn) * c.mass_normal;
diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp
index d993754fee..57c482e280 100644
--- a/servers/physics_2d/collision_solver_2d_sat.cpp
+++ b/servers/physics_2d/collision_solver_2d_sat.cpp
@@ -88,7 +88,7 @@ _FORCE_INLINE_ static void _generate_contacts_edge_edge(const Vector2 *p_points_
#endif
Vector2 n = p_collector->normal;
- Vector2 t = n.tangent();
+ Vector2 t = n.orthogonal();
real_t dA = n.dot(p_points_A[0]);
real_t dB = n.dot(p_points_B[0]);
@@ -209,7 +209,7 @@ public:
if (!test_axis(na)) {
return false;
}
- if (!test_axis(na.tangent())) {
+ if (!test_axis(na.orthogonal())) {
return false;
}
}
@@ -219,7 +219,7 @@ public:
if (!test_axis(nb)) {
return false;
}
- if (!test_axis(nb.tangent())) {
+ if (!test_axis(nb.orthogonal())) {
return false;
}
}
@@ -450,7 +450,7 @@ static void _collision_segment_circle(const Shape2DSW *p_a, const Transform2D &p
//segment normal
if (!separator.test_axis(
- (p_transform_a.xform(segment_A->get_b()) - p_transform_a.xform(segment_A->get_a())).normalized().tangent())) {
+ (p_transform_a.xform(segment_A->get_b()) - p_transform_a.xform(segment_A->get_a())).normalized().orthogonal())) {
return;
}
diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp
index 743f69d7d4..35f9d0e0c1 100644
--- a/servers/physics_2d/joints_2d_sw.cpp
+++ b/servers/physics_2d/joints_2d_sw.cpp
@@ -75,9 +75,9 @@ static inline real_t k_scalar(Body2DSW *a, Body2DSW *b, const Vector2 &rA, const
static inline Vector2
relative_velocity(Body2DSW *a, Body2DSW *b, Vector2 rA, Vector2 rB) {
- Vector2 sum = a->get_linear_velocity() - rA.tangent() * a->get_angular_velocity();
+ Vector2 sum = a->get_linear_velocity() - rA.orthogonal() * a->get_angular_velocity();
if (b) {
- return (b->get_linear_velocity() - rB.tangent() * b->get_angular_velocity()) - sum;
+ return (b->get_linear_velocity() - rB.orthogonal() * b->get_angular_velocity()) - sum;
} else {
return -sum;
}
@@ -264,7 +264,7 @@ bool GrooveJoint2DSW::setup(real_t p_step) {
Space2DSW *space = A->get_space();
// calculate axis
- Vector2 n = -(tb - ta).tangent().normalized();
+ Vector2 n = -(tb - ta).orthogonal().normalized();
real_t d = ta.dot(n);
xf_normal = n;
@@ -282,7 +282,7 @@ bool GrooveJoint2DSW::setup(real_t p_step) {
} else {
clamp = 0.0f;
//joint->r1 = cpvsub(cpvadd(cpvmult(cpvperp(n), -td), cpvmult(n, d)), a->p);
- rA = ((-n.tangent() * -td) + n * d) - A->get_transform().get_origin();
+ rA = ((-n.orthogonal() * -td) + n * d) - A->get_transform().get_origin();
}
// Calculate mass tensor
@@ -332,7 +332,7 @@ GrooveJoint2DSW::GrooveJoint2DSW(const Vector2 &p_a_groove1, const Vector2 &p_a_
A_groove_1 = A->get_inv_transform().xform(p_a_groove1);
A_groove_2 = A->get_inv_transform().xform(p_a_groove2);
B_anchor = B->get_inv_transform().xform(p_b_anchor);
- A_groove_normal = -(A_groove_2 - A_groove_1).normalized().tangent();
+ A_groove_normal = -(A_groove_2 - A_groove_1).normalized().orthogonal();
A->add_constraint(this, 0);
B->add_constraint(this, 1);
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp
index afb1112fc0..18ffca850c 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -228,7 +228,7 @@ void SegmentShape2DSW::set_data(const Variant &p_data) {
Rect2 r = p_data;
a = r.position;
b = r.size;
- n = (b - a).tangent();
+ n = (b - a).orthogonal();
Rect2 aabb;
aabb.position = a;
@@ -612,7 +612,7 @@ void ConvexPolygonShape2DSW::set_data(const Variant &p_data) {
for (int i = 0; i < point_count; i++) {
Vector2 p = points[i].pos;
Vector2 pn = points[(i + 1) % point_count].pos;
- points[i].normal = (pn - p).tangent().normalized();
+ points[i].normal = (pn - p).orthogonal().normalized();
}
} else {
Vector<real_t> dvr = p_data;
@@ -740,7 +740,7 @@ bool ConcavePolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Ve
if (nd < d) {
d = nd;
r_point = res;
- r_normal = (b - a).tangent().normalized();
+ r_normal = (b - a).orthogonal().normalized();
inters = true;
}
}
@@ -960,7 +960,7 @@ void ConcavePolygonShape2DSW::cull(const Rect2 &p_local_aabb, Callback p_callbac
Vector2 a = pointptr[s.points[0]];
Vector2 b = pointptr[s.points[1]];
- SegmentShape2DSW ss(a, b, (b - a).tangent().normalized());
+ SegmentShape2DSW ss(a, b, (b - a).orthogonal().normalized());
p_callback(p_userdata, &ss);
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h
index eca284f7a4..66b4ddf0df 100644
--- a/servers/physics_2d/shape_2d_sw.h
+++ b/servers/physics_2d/shape_2d_sw.h
@@ -237,7 +237,7 @@ public:
virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_SEGMENT; }
_FORCE_INLINE_ Vector2 get_xformed_normal(const Transform2D &p_xform) const {
- return (p_xform.xform(b) - p_xform.xform(a)).normalized().tangent();
+ return (p_xform.xform(b) - p_xform.xform(a)).normalized().orthogonal();
}
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); }
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const;
@@ -431,7 +431,7 @@ public:
Vector2 a = points[p_idx].pos;
p_idx++;
Vector2 b = points[p_idx == point_count ? 0 : p_idx].pos;
- return (p_xform.xform(b) - p_xform.xform(a)).normalized().tangent();
+ return (p_xform.xform(b) - p_xform.xform(a)).normalized().orthogonal();
}
virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CONVEX_POLYGON; }
diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp
index 72ae719c93..ece6e84920 100644
--- a/servers/rendering/renderer_canvas_cull.cpp
+++ b/servers/rendering/renderer_canvas_cull.cpp
@@ -524,7 +524,7 @@ void RendererCanvasCull::canvas_item_add_line(RID p_item, const Point2 &p_from,
Item::CommandPrimitive *line = canvas_item->alloc_command<Item::CommandPrimitive>();
ERR_FAIL_COND(!line);
if (p_width > 1.001) {
- Vector2 t = (p_from - p_to).tangent().normalized();
+ Vector2 t = (p_from - p_to).orthogonal().normalized();
line->points[0] = p_from + t * p_width;
line->points[1] = p_from - t * p_width;
line->points[2] = p_to - t * p_width;
@@ -600,7 +600,7 @@ void RendererCanvasCull::canvas_item_add_polyline(RID p_item, const Vector<Point
if (i == pc - 1) {
t = prev_t;
} else {
- t = (p_points[i + 1] - p_points[i]).normalized().tangent();
+ t = (p_points[i + 1] - p_points[i]).normalized().orthogonal();
if (i == 0) {
prev_t = t;
}
@@ -650,7 +650,7 @@ void RendererCanvasCull::canvas_item_add_polyline(RID p_item, const Vector<Point
if (i == pc - 1) {
t = prev_t;
} else {
- t = (p_points[i + 1] - p_points[i]).normalized().tangent();
+ t = (p_points[i + 1] - p_points[i]).normalized().orthogonal();
if (i == 0) {
prev_t = t;
}
diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
index 591018346a..415dfcc5f1 100644
--- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
@@ -1689,7 +1689,7 @@ void RendererCanvasRenderRD::light_update_directional_shadow(RID p_rid, int p_sh
to_light_xform[2] = from_pos;
to_light_xform[1] = light_dir;
- to_light_xform[0] = -light_dir.tangent();
+ to_light_xform[0] = -light_dir.orthogonal();
to_light_xform.invert();