summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/math/math_2d.cpp29
-rw-r--r--core/math/math_2d.h5
-rw-r--r--core/variant_call.cpp2
3 files changed, 7 insertions, 29 deletions
diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp
index c77fe96ff2..11003c1cd5 100644
--- a/core/math/math_2d.cpp
+++ b/core/math/math_2d.cpp
@@ -222,35 +222,6 @@ Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, c
(2.0 * p0 - 5.0 * p1 + 4 * p2 - p3) * t2 +
(-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3);
return out;
-
- /*
- real_t mu = p_t;
- real_t mu2 = mu*mu;
-
- Vector2 a0 = p_post_b - p_b - p_pre_a + *this;
- Vector2 a1 = p_pre_a - *this - a0;
- Vector2 a2 = p_b - p_pre_a;
- Vector2 a3 = *this;
-
- return ( a0*mu*mu2 + a1*mu2 + a2*mu + a3 );
-*/
- /*
- real_t t = p_t;
- real_t t2 = t*t;
- real_t t3 = t2*t;
-
- real_t a = 2.0*t3- 3.0*t2 + 1;
- real_t b = -2.0*t3+ 3.0*t2;
- real_t c = t3- 2.0*t2 + t;
- real_t d = t3- t2;
-
- Vector2 p_a=*this;
-
- return Vector2(
- (a * p_a.x) + (b *p_b.x) + (c * p_pre_a.x) + (d * p_post_b.x),
- (a * p_a.y) + (b *p_b.y) + (c * p_pre_a.y) + (d * p_post_b.y)
- );
-*/
}
// slide returns the component of the vector along the given plane, specified by its normal vector.
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index d788318f5e..60351445c0 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -382,6 +382,11 @@ struct Rect2 {
size = end - begin;
}
+ inline Rect2 abs() const {
+
+ return Rect2(Point2(position.x + MIN(size.x, 0), position.y + MIN(size.y, 0)), size.abs());
+ }
+
operator String() const { return String(position) + ", " + String(size); }
Rect2() {}
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 991573e8d7..f66cce85c9 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -360,6 +360,7 @@ struct _VariantCall {
VCALL_LOCALMEM2R(Rect2, grow_margin);
VCALL_LOCALMEM4R(Rect2, grow_individual);
VCALL_LOCALMEM1R(Rect2, expand);
+ VCALL_LOCALMEM0R(Rect2, abs);
VCALL_LOCALMEM0R(Vector3, min_axis);
VCALL_LOCALMEM0R(Vector3, max_axis);
@@ -1526,6 +1527,7 @@ void register_variant_methods() {
ADDFUNC2R(RECT2, RECT2, Rect2, grow_margin, INT, "margin", REAL, "by", varray());
ADDFUNC4R(RECT2, RECT2, Rect2, grow_individual, REAL, "left", REAL, "top", REAL, "right", REAL, " bottom", varray());
ADDFUNC1R(RECT2, RECT2, Rect2, expand, VECTOR2, "to", varray());
+ ADDFUNC0R(RECT2, RECT2, Rect2, abs, varray());
ADDFUNC0R(VECTOR3, INT, Vector3, min_axis, varray());
ADDFUNC0R(VECTOR3, INT, Vector3, max_axis, varray());