summaryrefslogtreecommitdiff
path: root/core/variant_call.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/variant_call.cpp')
-rw-r--r--core/variant_call.cpp95
1 files changed, 95 insertions, 0 deletions
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 3b82e980bd..0f7c1275ef 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -383,6 +383,10 @@ struct _VariantCall {
VCALL_LOCALMEM1R(Vector2, clamped);
VCALL_LOCALMEM0R(Vector2, sign);
+ VCALL_LOCALMEM0R(Vector2i, aspect);
+ VCALL_LOCALMEM0R(Vector2i, sign);
+ VCALL_LOCALMEM0R(Vector2i, abs);
+
VCALL_LOCALMEM0R(Rect2, get_area);
VCALL_LOCALMEM0R(Rect2, has_no_area);
VCALL_LOCALMEM1R(Rect2, has_point);
@@ -397,6 +401,19 @@ struct _VariantCall {
VCALL_LOCALMEM4R(Rect2, grow_individual);
VCALL_LOCALMEM0R(Rect2, abs);
+ VCALL_LOCALMEM0R(Rect2i, get_area);
+ VCALL_LOCALMEM0R(Rect2i, has_no_area);
+ VCALL_LOCALMEM1R(Rect2i, has_point);
+ VCALL_LOCALMEM1R(Rect2i, intersects);
+ VCALL_LOCALMEM1R(Rect2i, encloses);
+ VCALL_LOCALMEM1R(Rect2i, clip);
+ VCALL_LOCALMEM1R(Rect2i, merge);
+ VCALL_LOCALMEM1R(Rect2i, expand);
+ VCALL_LOCALMEM1R(Rect2i, grow);
+ VCALL_LOCALMEM2R(Rect2i, grow_margin);
+ VCALL_LOCALMEM4R(Rect2i, grow_individual);
+ VCALL_LOCALMEM0R(Rect2i, abs);
+
VCALL_LOCALMEM0R(Vector3, min_axis);
VCALL_LOCALMEM0R(Vector3, max_axis);
VCALL_LOCALMEM1R(Vector3, distance_to);
@@ -431,6 +448,10 @@ struct _VariantCall {
VCALL_LOCALMEM1R(Vector3, reflect);
VCALL_LOCALMEM0R(Vector3, sign);
+ VCALL_LOCALMEM0R(Vector3i, min_axis);
+ VCALL_LOCALMEM0R(Vector3i, max_axis);
+ VCALL_LOCALMEM0R(Vector3i, sign);
+
VCALL_LOCALMEM0R(Plane, normalized);
VCALL_LOCALMEM0R(Plane, center);
VCALL_LOCALMEM0R(Plane, get_any_point);
@@ -909,6 +930,11 @@ struct _VariantCall {
r_ret = Vector2(*p_args[0], *p_args[1]);
}
+ static void Vector2i_init1(Variant &r_ret, const Variant **p_args) {
+
+ r_ret = Vector2i(*p_args[0], *p_args[1]);
+ }
+
static void Rect2_init1(Variant &r_ret, const Variant **p_args) {
r_ret = Rect2(*p_args[0], *p_args[1]);
@@ -919,6 +945,16 @@ struct _VariantCall {
r_ret = Rect2(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
}
+ static void Rect2i_init1(Variant &r_ret, const Variant **p_args) {
+
+ r_ret = Rect2i(*p_args[0], *p_args[1]);
+ }
+
+ static void Rect2i_init2(Variant &r_ret, const Variant **p_args) {
+
+ r_ret = Rect2i(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
+ }
+
static void Transform2D_init2(Variant &r_ret, const Variant **p_args) {
Transform2D m(*p_args[0], *p_args[1]);
@@ -939,6 +975,11 @@ struct _VariantCall {
r_ret = Vector3(*p_args[0], *p_args[1], *p_args[2]);
}
+ static void Vector3i_init1(Variant &r_ret, const Variant **p_args) {
+
+ r_ret = Vector3i(*p_args[0], *p_args[1], *p_args[2]);
+ }
+
static void Plane_init1(Variant &r_ret, const Variant **p_args) {
r_ret = Plane(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
@@ -1262,8 +1303,13 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
case VECTOR2: {
return Vector2(*p_args[0]);
}
+ case VECTOR2I: {
+ return Vector2i(*p_args[0]);
+ }
case RECT2: return (Rect2(*p_args[0]));
+ case RECT2I: return (Rect2i(*p_args[0]));
case VECTOR3: return (Vector3(*p_args[0]));
+ case VECTOR3I: return (Vector3i(*p_args[0]));
case PLANE: return (Plane(*p_args[0]));
case QUAT: return (p_args[0]->operator Quat());
case AABB:
@@ -1727,6 +1773,10 @@ void register_variant_methods() {
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, clamped, REAL, "length", varray());
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, sign, varray());
+ ADDFUNC0R(VECTOR2I, REAL, Vector2i, aspect, varray());
+ ADDFUNC0R(VECTOR2I, VECTOR2I, Vector2i, sign, varray());
+ ADDFUNC0R(VECTOR2I, VECTOR2I, Vector2i, abs, varray());
+
ADDFUNC0R(RECT2, REAL, Rect2, get_area, varray());
ADDFUNC0R(RECT2, BOOL, Rect2, has_no_area, varray());
ADDFUNC1R(RECT2, BOOL, Rect2, has_point, VECTOR2, "point", varray());
@@ -1741,6 +1791,19 @@ void register_variant_methods() {
ADDFUNC4R(RECT2, RECT2, Rect2, grow_individual, REAL, "left", REAL, "top", REAL, "right", REAL, " bottom", varray());
ADDFUNC0R(RECT2, RECT2, Rect2, abs, varray());
+ ADDFUNC0R(RECT2I, INT, Rect2i, get_area, varray());
+ ADDFUNC0R(RECT2I, BOOL, Rect2i, has_no_area, varray());
+ ADDFUNC1R(RECT2I, BOOL, Rect2i, has_point, VECTOR2I, "point", varray());
+ ADDFUNC1R(RECT2I, BOOL, Rect2i, intersects, RECT2I, "b", varray());
+ ADDFUNC1R(RECT2I, BOOL, Rect2i, encloses, RECT2I, "b", varray());
+ ADDFUNC1R(RECT2I, RECT2I, Rect2i, clip, RECT2I, "b", varray());
+ ADDFUNC1R(RECT2I, RECT2I, Rect2i, merge, RECT2I, "b", varray());
+ ADDFUNC1R(RECT2I, RECT2I, Rect2i, expand, VECTOR2I, "to", varray());
+ ADDFUNC1R(RECT2I, RECT2I, Rect2i, grow, INT, "by", varray());
+ ADDFUNC2R(RECT2I, RECT2I, Rect2i, grow_margin, INT, "margin", INT, "by", varray());
+ ADDFUNC4R(RECT2I, RECT2I, Rect2i, grow_individual, INT, "left", INT, "top", INT, "right", INT, " bottom", varray());
+ ADDFUNC0R(RECT2I, RECT2I, Rect2i, abs, varray());
+
ADDFUNC0R(VECTOR3, INT, Vector3, min_axis, varray());
ADDFUNC0R(VECTOR3, INT, Vector3, max_axis, varray());
ADDFUNC1R(VECTOR3, REAL, Vector3, angle_to, VECTOR3, "to", varray());
@@ -1775,6 +1838,10 @@ void register_variant_methods() {
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, reflect, VECTOR3, "n", varray());
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, sign, varray());
+ ADDFUNC0R(VECTOR3I, INT, Vector3i, min_axis, varray());
+ ADDFUNC0R(VECTOR3I, INT, Vector3i, max_axis, varray());
+ ADDFUNC0R(VECTOR3I, VECTOR3I, Vector3i, sign, varray());
+
ADDFUNC0R(PLANE, PLANE, Plane, normalized, varray());
ADDFUNC0R(PLANE, VECTOR3, Plane, center, varray());
ADDFUNC0R(PLANE, VECTOR3, Plane, get_any_point, varray());
@@ -2048,14 +2115,19 @@ void register_variant_methods() {
/* REGISTER CONSTRUCTORS */
_VariantCall::add_constructor(_VariantCall::Vector2_init1, Variant::VECTOR2, "x", Variant::REAL, "y", Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Vector2i_init1, Variant::VECTOR2I, "x", Variant::INT, "y", Variant::INT);
_VariantCall::add_constructor(_VariantCall::Rect2_init1, Variant::RECT2, "position", Variant::VECTOR2, "size", Variant::VECTOR2);
_VariantCall::add_constructor(_VariantCall::Rect2_init2, Variant::RECT2, "x", Variant::REAL, "y", Variant::REAL, "width", Variant::REAL, "height", Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Rect2i_init1, Variant::RECT2I, "position", Variant::VECTOR2, "size", Variant::VECTOR2);
+ _VariantCall::add_constructor(_VariantCall::Rect2i_init2, Variant::RECT2I, "x", Variant::INT, "y", Variant::INT, "width", Variant::INT, "height", Variant::INT);
+
_VariantCall::add_constructor(_VariantCall::Transform2D_init2, Variant::TRANSFORM2D, "rotation", Variant::REAL, "position", Variant::VECTOR2);
_VariantCall::add_constructor(_VariantCall::Transform2D_init3, Variant::TRANSFORM2D, "x_axis", Variant::VECTOR2, "y_axis", Variant::VECTOR2, "origin", Variant::VECTOR2);
_VariantCall::add_constructor(_VariantCall::Vector3_init1, Variant::VECTOR3, "x", Variant::REAL, "y", Variant::REAL, "z", Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Vector3i_init1, Variant::VECTOR3I, "x", Variant::INT, "y", Variant::INT, "z", Variant::INT);
_VariantCall::add_constructor(_VariantCall::Plane_init1, Variant::PLANE, "a", Variant::REAL, "b", Variant::REAL, "c", Variant::REAL, "d", Variant::REAL);
_VariantCall::add_constructor(_VariantCall::Plane_init2, Variant::PLANE, "v1", Variant::VECTOR3, "v2", Variant::VECTOR3, "v3", Variant::VECTOR3);
@@ -2100,9 +2172,25 @@ void register_variant_methods() {
_VariantCall::add_variant_constant(Variant::VECTOR3, "FORWARD", Vector3(0, 0, -1));
_VariantCall::add_variant_constant(Variant::VECTOR3, "BACK", Vector3(0, 0, 1));
+ _VariantCall::add_constant(Variant::VECTOR3I, "AXIS_X", Vector3::AXIS_X);
+ _VariantCall::add_constant(Variant::VECTOR3I, "AXIS_Y", Vector3::AXIS_Y);
+ _VariantCall::add_constant(Variant::VECTOR3I, "AXIS_Z", Vector3::AXIS_Z);
+
+ _VariantCall::add_variant_constant(Variant::VECTOR3I, "ZERO", Vector3i(0, 0, 0));
+ _VariantCall::add_variant_constant(Variant::VECTOR3I, "ONE", Vector3i(1, 1, 1));
+ _VariantCall::add_variant_constant(Variant::VECTOR3I, "LEFT", Vector3i(-1, 0, 0));
+ _VariantCall::add_variant_constant(Variant::VECTOR3I, "RIGHT", Vector3i(1, 0, 0));
+ _VariantCall::add_variant_constant(Variant::VECTOR3I, "UP", Vector3i(0, 1, 0));
+ _VariantCall::add_variant_constant(Variant::VECTOR3I, "DOWN", Vector3i(0, -1, 0));
+ _VariantCall::add_variant_constant(Variant::VECTOR3I, "FORWARD", Vector3i(0, 0, -1));
+ _VariantCall::add_variant_constant(Variant::VECTOR3I, "BACK", Vector3i(0, 0, 1));
+
_VariantCall::add_constant(Variant::VECTOR2, "AXIS_X", Vector2::AXIS_X);
_VariantCall::add_constant(Variant::VECTOR2, "AXIS_Y", Vector2::AXIS_Y);
+ _VariantCall::add_constant(Variant::VECTOR2I, "AXIS_X", Vector2::AXIS_X);
+ _VariantCall::add_constant(Variant::VECTOR2I, "AXIS_Y", Vector2::AXIS_Y);
+
_VariantCall::add_variant_constant(Variant::VECTOR2, "ZERO", Vector2(0, 0));
_VariantCall::add_variant_constant(Variant::VECTOR2, "ONE", Vector2(1, 1));
_VariantCall::add_variant_constant(Variant::VECTOR2, "INF", Vector2(Math_INF, Math_INF));
@@ -2111,6 +2199,13 @@ void register_variant_methods() {
_VariantCall::add_variant_constant(Variant::VECTOR2, "UP", Vector2(0, -1));
_VariantCall::add_variant_constant(Variant::VECTOR2, "DOWN", Vector2(0, 1));
+ _VariantCall::add_variant_constant(Variant::VECTOR2I, "ZERO", Vector2i(0, 0));
+ _VariantCall::add_variant_constant(Variant::VECTOR2I, "ONE", Vector2i(1, 1));
+ _VariantCall::add_variant_constant(Variant::VECTOR2I, "LEFT", Vector2i(-1, 0));
+ _VariantCall::add_variant_constant(Variant::VECTOR2I, "RIGHT", Vector2i(1, 0));
+ _VariantCall::add_variant_constant(Variant::VECTOR2I, "UP", Vector2i(0, -1));
+ _VariantCall::add_variant_constant(Variant::VECTOR2I, "DOWN", Vector2i(0, 1));
+
_VariantCall::add_variant_constant(Variant::TRANSFORM2D, "IDENTITY", Transform2D());
_VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_X", Transform2D(-1, 0, 0, 1, 0, 0));
_VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_Y", Transform2D(1, 0, 0, -1, 0, 0));