diff options
| author | Daniel Rakos <daniel.rakos@rastergrid.com> | 2019-04-11 17:06:02 +0200 |
|---|---|---|
| committer | Daniel Rakos <daniel.rakos@rastergrid.com> | 2019-04-11 19:59:34 +0200 |
| commit | 4be7fcdde50d04ff7c1f105662e2df620a3f7af0 (patch) | |
| tree | 6c8b23e014455ed2a17e2a2736f9cf6d77064836 /include/core | |
| parent | f0fe88bd36603b5ccb0d1c865e1ad8432dbe3b5e (diff) | |
| download | redot-cpp-4be7fcdde50d04ff7c1f105662e2df620a3f7af0.tar.gz | |
Fix bug in Basis [] operator and add missing Transform-Vector3 * operator
The [] operator of Basis was returning a reference to a temporary, so fixed it.
There was no * operator in Transform equivalent to the xform function, which is
not in line with GDScript behavior.
Also fixed remaining cases where Transform relied on the old behavior of the
[] operator of Basis (i.e. that it returns the row, not the column).
Diffstat (limited to 'include/core')
| -rw-r--r-- | include/core/Basis.hpp | 2 | ||||
| -rw-r--r-- | include/core/Transform.hpp | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/include/core/Basis.hpp b/include/core/Basis.hpp index b559b00..eb1cf76 100644 --- a/include/core/Basis.hpp +++ b/include/core/Basis.hpp @@ -307,7 +307,7 @@ public: Basis(); - const Vector3 &operator[](int axis) const { + const Vector3 operator[](int axis) const { return get_axis(axis); } diff --git a/include/core/Transform.hpp b/include/core/Transform.hpp index a56a9a2..9da6366 100644 --- a/include/core/Transform.hpp +++ b/include/core/Transform.hpp @@ -58,6 +58,13 @@ public: void operator*=(const Transform &p_transform); Transform operator*(const Transform &p_transform) const; + inline Vector3 operator*(const Vector3 &p_vector) const { + return Vector3( + basis.elements[0].dot(p_vector) + origin.x, + basis.elements[1].dot(p_vector) + origin.y, + basis.elements[2].dot(p_vector) + origin.z); + } + Transform interpolate_with(const Transform &p_transform, real_t p_c) const; Transform inverse_xform(const Transform &t) const; |
