diff options
author | Marc <marc.gilleron@gmail.com> | 2021-01-31 20:02:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-31 20:02:06 +0000 |
commit | e76efdd3ab18092f65a2bea8ca92e604420fce2f (patch) | |
tree | f8e4f63e1f5e99552534e4a604ce9146b7593bf6 /src | |
parent | 18e1b262ff503543912a9fb39a2502e5bb9a865d (diff) | |
parent | 8e1cc29c66cc4dd28721a0367ef2f55464e9f026 (diff) | |
download | redot-cpp-e76efdd3ab18092f65a2bea8ca92e604420fce2f.tar.gz |
Merge pull request #481 from Zylann/vec_constants
Added missing constants to Vector2, Vector3, Basis and Quat
Diffstat (limited to 'src')
-rw-r--r-- | src/core/Basis.cpp | 5 | ||||
-rw-r--r-- | src/core/Quat.cpp | 2 | ||||
-rw-r--r-- | src/core/Transform.cpp | 5 | ||||
-rw-r--r-- | src/core/Transform2D.cpp | 4 | ||||
-rw-r--r-- | src/core/Vector2.cpp | 9 | ||||
-rw-r--r-- | src/core/Vector3.cpp | 11 |
6 files changed, 36 insertions, 0 deletions
diff --git a/src/core/Basis.cpp b/src/core/Basis.cpp index 368afa1..903566c 100644 --- a/src/core/Basis.cpp +++ b/src/core/Basis.cpp @@ -7,6 +7,11 @@ namespace godot { +const Basis Basis::IDENTITY = Basis(); +const Basis Basis::FLIP_X = Basis(-1, 0, 0, 0, 1, 0, 0, 0, 1); +const Basis Basis::FLIP_Y = Basis(1, 0, 0, 0, -1, 0, 0, 0, 1); +const Basis Basis::FLIP_Z = Basis(1, 0, 0, 0, 1, 0, 0, 0, -1); + Basis::Basis(const Vector3 &row0, const Vector3 &row1, const Vector3 &row2) { elements[0] = row0; elements[1] = row1; diff --git a/src/core/Quat.cpp b/src/core/Quat.cpp index 00fa43d..dc179e2 100644 --- a/src/core/Quat.cpp +++ b/src/core/Quat.cpp @@ -7,6 +7,8 @@ namespace godot { +const Quat Quat::IDENTITY = Quat(); + // set_euler_xyz expects a vector containing the Euler angles in the format // (ax,ay,az), where ax is the angle of rotation around x axis, // and similar for other axes. diff --git a/src/core/Transform.cpp b/src/core/Transform.cpp index d32de8d..1eca983 100644 --- a/src/core/Transform.cpp +++ b/src/core/Transform.cpp @@ -9,6 +9,11 @@ namespace godot { +const Transform Transform::IDENTITY = Transform(); +const Transform Transform::FLIP_X = Transform(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0); +const Transform Transform::FLIP_Y = Transform(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0); +const Transform Transform::FLIP_Z = Transform(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0); + Transform Transform::inverse_xform(const Transform &t) const { Vector3 v = t.origin - origin; diff --git a/src/core/Transform2D.cpp b/src/core/Transform2D.cpp index acd6af1..6395c3d 100644 --- a/src/core/Transform2D.cpp +++ b/src/core/Transform2D.cpp @@ -7,6 +7,10 @@ namespace godot { +const Transform2D Transform2D::IDENTITY; +const Transform2D Transform2D::FLIP_X = Transform2D(-1, 0, 0, 1, 0, 0); +const Transform2D Transform2D::FLIP_Y = Transform2D(1, 0, 0, -1, 0, 0); + Transform2D::Transform2D(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy) { elements[0][0] = xx; diff --git a/src/core/Vector2.cpp b/src/core/Vector2.cpp index 44dc001..eeeeb85 100644 --- a/src/core/Vector2.cpp +++ b/src/core/Vector2.cpp @@ -6,6 +6,15 @@ namespace godot { +const Vector2 Vector2::ZERO; +const Vector2 Vector2::ONE; +const Vector2 Vector2::INF; + +const Vector2 Vector2::LEFT = Vector2(-1, 0); +const Vector2 Vector2::RIGHT = Vector2(1, 0); +const Vector2 Vector2::UP = Vector2(0, -1); +const Vector2 Vector2::DOWN = Vector2(0, 1); + bool Vector2::operator==(const Vector2 &p_vec2) const { return x == p_vec2.x && y == p_vec2.y; } diff --git a/src/core/Vector3.cpp b/src/core/Vector3.cpp index 879de0b..f4db462 100644 --- a/src/core/Vector3.cpp +++ b/src/core/Vector3.cpp @@ -8,6 +8,17 @@ namespace godot { +const Vector3 Vector3::ZERO = Vector3(); +const Vector3 Vector3::ONE = Vector3(); +const Vector3 Vector3::INF = Vector3(INFINITY, INFINITY, INFINITY); + +const Vector3 Vector3::LEFT = Vector3(-1, 0, 0); +const Vector3 Vector3::RIGHT = Vector3(1, 0, 0); +const Vector3 Vector3::UP = Vector3(0, 1, 0); +const Vector3 Vector3::DOWN = Vector3(0, -1, 0); +const Vector3 Vector3::FORWARD = Vector3(0, 0, -1); +const Vector3 Vector3::BACK = Vector3(0, 0, 1); + bool Vector3::operator<(const Vector3 &p_v) const { if (x == p_v.x) { if (y == p_v.y) |