diff --git a/core/math/basis.h b/core/math/basis.h index 3736047dd30..2889a4aa5ee 100644 --- a/core/math/basis.h +++ b/core/math/basis.h @@ -158,8 +158,8 @@ public: _FORCE_INLINE_ Basis operator+(const Basis &p_matrix) const; _FORCE_INLINE_ void operator-=(const Basis &p_matrix); _FORCE_INLINE_ Basis operator-(const Basis &p_matrix) const; - _FORCE_INLINE_ void operator*=(real_t p_val); - _FORCE_INLINE_ Basis operator*(real_t p_val) const; + _FORCE_INLINE_ void operator*=(const real_t p_val); + _FORCE_INLINE_ Basis operator*(const real_t p_val) const; int get_orthogonal_index() const; void set_orthogonal_index(int p_index); @@ -298,13 +298,13 @@ _FORCE_INLINE_ Basis Basis::operator-(const Basis &p_matrix) const { return ret; } -_FORCE_INLINE_ void Basis::operator*=(real_t p_val) { +_FORCE_INLINE_ void Basis::operator*=(const real_t p_val) { elements[0] *= p_val; elements[1] *= p_val; elements[2] *= p_val; } -_FORCE_INLINE_ Basis Basis::operator*(real_t p_val) const { +_FORCE_INLINE_ Basis Basis::operator*(const real_t p_val) const { Basis ret(*this); ret *= p_val; return ret; diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp index 0140f31b8a3..16934d67df2 100644 --- a/core/math/transform_2d.cpp +++ b/core/math/transform_2d.cpp @@ -276,6 +276,18 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t return res; } +void Transform2D::operator*=(const real_t p_val) { + elements[0] *= p_val; + elements[1] *= p_val; + elements[2] *= p_val; +} + +Transform2D Transform2D::operator*(const real_t p_val) const { + Transform2D ret(*this); + ret *= p_val; + return ret; +} + Transform2D::operator String() const { return "[X: " + elements[0].operator String() + ", Y: " + elements[1].operator String() + diff --git a/core/math/transform_2d.h b/core/math/transform_2d.h index 715f013701e..34cfd0c1a95 100644 --- a/core/math/transform_2d.h +++ b/core/math/transform_2d.h @@ -107,6 +107,8 @@ struct Transform2D { void operator*=(const Transform2D &p_transform); Transform2D operator*(const Transform2D &p_transform) const; + void operator*=(const real_t p_val); + Transform2D operator*(const real_t p_val) const; Transform2D interpolate_with(const Transform2D &p_transform, real_t p_c) const; diff --git a/core/math/transform_3d.cpp b/core/math/transform_3d.cpp index a34d998dded..51766b39f46 100644 --- a/core/math/transform_3d.cpp +++ b/core/math/transform_3d.cpp @@ -190,6 +190,17 @@ Transform3D Transform3D::operator*(const Transform3D &p_transform) const { return t; } +void Transform3D::operator*=(const real_t p_val) { + origin *= p_val; + basis *= p_val; +} + +Transform3D Transform3D::operator*(const real_t p_val) const { + Transform3D ret(*this); + ret *= p_val; + return ret; +} + Transform3D::operator String() const { return "[X: " + basis.get_axis(0).operator String() + ", Y: " + basis.get_axis(1).operator String() + diff --git a/core/math/transform_3d.h b/core/math/transform_3d.h index 078a2ca11a7..3d8e70cec76 100644 --- a/core/math/transform_3d.h +++ b/core/math/transform_3d.h @@ -88,6 +88,8 @@ public: void operator*=(const Transform3D &p_transform); Transform3D operator*(const Transform3D &p_transform) const; + void operator*=(const real_t p_val); + Transform3D operator*(const real_t p_val) const; Transform3D interpolate_with(const Transform3D &p_transform, real_t p_c) const; diff --git a/core/variant/variant_op.cpp b/core/variant/variant_op.cpp index 10d0a830145..e7badd22b84 100644 --- a/core/variant/variant_op.cpp +++ b/core/variant/variant_op.cpp @@ -1458,6 +1458,8 @@ void Variant::_register_variant_operators() { register_op>(Variant::OP_MULTIPLY, Variant::COLOR, Variant::FLOAT); register_op>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::TRANSFORM2D); + register_op>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::INT); + register_op>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::FLOAT); register_op>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::VECTOR2); register_op>(Variant::OP_MULTIPLY, Variant::VECTOR2, Variant::TRANSFORM2D); register_op>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::RECT2); @@ -1466,6 +1468,8 @@ void Variant::_register_variant_operators() { register_op, Vector, Transform2D>>(Variant::OP_MULTIPLY, Variant::PACKED_VECTOR2_ARRAY, Variant::TRANSFORM2D); register_op>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::TRANSFORM3D); + register_op>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::INT); + register_op>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::FLOAT); register_op>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::VECTOR3); register_op>(Variant::OP_MULTIPLY, Variant::VECTOR3, Variant::TRANSFORM3D); register_op>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::AABB); @@ -1474,6 +1478,8 @@ void Variant::_register_variant_operators() { register_op, Vector, Transform3D>>(Variant::OP_MULTIPLY, Variant::PACKED_VECTOR3_ARRAY, Variant::TRANSFORM3D); register_op>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::BASIS); + register_op>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::INT); + register_op>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::FLOAT); register_op>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::VECTOR3); register_op>(Variant::OP_MULTIPLY, Variant::VECTOR3, Variant::BASIS); diff --git a/doc/classes/Basis.xml b/doc/classes/Basis.xml index 14fca046722..62d2bb2b54e 100644 --- a/doc/classes/Basis.xml +++ b/doc/classes/Basis.xml @@ -155,6 +155,24 @@ + + + + + + + This operator multiplies all components of the [Basis], which scales it uniformly. + + + + + + + + + This operator multiplies all components of the [Basis], which scales it uniformly. + + diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml index 0dbf95376ad..8e9f052ed22 100644 --- a/doc/classes/Transform2D.xml +++ b/doc/classes/Transform2D.xml @@ -148,17 +148,9 @@ - + - - - - - - - - - + @@ -172,13 +164,39 @@ - + - + + + + + + + + + + + + + + + + This operator multiplies all components of the [Transform2D], including the origin vector, which scales it uniformly. + + + + + + + + + This operator multiplies all components of the [Transform2D], including the origin vector, which scales it uniformly. + + diff --git a/doc/classes/Transform3D.xml b/doc/classes/Transform3D.xml index 0d492555231..785d274ec66 100644 --- a/doc/classes/Transform3D.xml +++ b/doc/classes/Transform3D.xml @@ -145,6 +145,24 @@ + + + + + + + This operator multiplies all components of the [Transform3D], including the origin vector, which scales it uniformly. + + + + + + + + + This operator multiplies all components of the [Transform3D], including the origin vector, which scales it uniformly. + + diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp index d69c9114b9a..b94f4b4c6cc 100644 --- a/modules/gdnavigation/navigation_mesh_generator.cpp +++ b/modules/gdnavigation/navigation_mesh_generator.cpp @@ -255,7 +255,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor for (int i = 0; i < meshes.size(); i += 2) { Ref mesh = meshes[i + 1]; if (mesh.is_valid()) { - _add_mesh(mesh, p_accumulated_transform * xform * meshes[i], p_verticies, p_indices); + _add_mesh(mesh, p_accumulated_transform * xform * (Transform3D)meshes[i], p_verticies, p_indices); } } }