Skip to content

Commit 7d5ecc2

Browse files
committed
Merge pull request godotengine#107295 from Ivorforce/explicit-math-to-string
Remove implicit conversions from math types to `String`, to avoid accidental conversions
2 parents 0a4bb80 + ed836df commit 7d5ecc2

25 files changed

+55
-55
lines changed

core/math/aabb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,5 +441,5 @@ Variant AABB::intersects_ray_bind(const Vector3 &p_from, const Vector3 &p_dir) c
441441
}
442442

443443
AABB::operator String() const {
444-
return "[P: " + position.operator String() + ", S: " + size + "]";
444+
return "[P: " + String(position) + ", S: " + String(size) + "]";
445445
}

core/math/aabb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ struct [[nodiscard]] AABB {
131131
return position + (size * 0.5f);
132132
}
133133

134-
operator String() const;
134+
explicit operator String() const;
135135

136136
AABB() = default;
137137
constexpr AABB(const Vector3 &p_pos, const Vector3 &p_size) :

core/math/basis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ struct [[nodiscard]] Basis {
149149
Basis slerp(const Basis &p_to, real_t p_weight) const;
150150
void rotate_sh(real_t *p_values);
151151

152-
operator String() const;
152+
explicit operator String() const;
153153

154154
/* create / set */
155155

core/math/color.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ struct [[nodiscard]] Color {
220220
static Color from_rgba8(int64_t p_r8, int64_t p_g8, int64_t p_b8, int64_t p_a8 = 255);
221221

222222
constexpr bool operator<(const Color &p_color) const; // Used in set keys.
223-
operator String() const;
223+
explicit operator String() const;
224224

225225
// For the binder.
226226
_FORCE_INLINE_ void set_r8(int32_t r8) { r = (CLAMP(r8, 0, 255) / 255.0f); }

core/math/face3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ bool Face3::intersects_aabb(const AABB &p_aabb) const {
201201
}
202202

203203
Face3::operator String() const {
204-
return String() + vertex[0] + ", " + vertex[1] + ", " + vertex[2];
204+
return String() + String(vertex[0]) + ", " + String(vertex[1]) + ", " + String(vertex[2]);
205205
}
206206

207207
void Face3::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {

core/math/face3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct [[nodiscard]] Face3 {
7676

7777
bool intersects_aabb(const AABB &p_aabb) const;
7878
_FORCE_INLINE_ bool intersects_aabb2(const AABB &p_aabb) const;
79-
operator String() const;
79+
explicit operator String() const;
8080

8181
Face3() = default;
8282
constexpr Face3(const Vector3 &p_v1, const Vector3 &p_v2, const Vector3 &p_v3) :

core/math/plane.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct [[nodiscard]] Plane {
7878

7979
constexpr bool operator==(const Plane &p_plane) const;
8080
constexpr bool operator!=(const Plane &p_plane) const;
81-
operator String() const;
81+
explicit operator String() const;
8282

8383
Plane() = default;
8484
constexpr Plane(real_t p_a, real_t p_b, real_t p_c, real_t p_d) :

core/math/projection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct [[nodiscard]] Projection {
127127
Vector4 xform(const Vector4 &p_vec4) const;
128128
Vector4 xform_inv(const Vector4 &p_vec4) const;
129129

130-
operator String() const;
130+
explicit operator String() const;
131131

132132
void scale_translate_to_fit(const AABB &p_aabb);
133133
void add_jitter_offset(const Vector2 &p_offset);

core/math/quaternion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct [[nodiscard]] Quaternion {
115115
constexpr bool operator==(const Quaternion &p_quaternion) const;
116116
constexpr bool operator!=(const Quaternion &p_quaternion) const;
117117

118-
operator String() const;
118+
explicit operator String() const;
119119

120120
constexpr Quaternion() :
121121
x(0), y(0), z(0), w(1) {}

core/math/rect2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ struct [[nodiscard]] Rect2 {
358358
return position + size;
359359
}
360360

361-
operator String() const;
361+
explicit operator String() const;
362362
operator Rect2i() const;
363363

364364
Rect2() = default;

0 commit comments

Comments
 (0)