Skip to content

Commit 13d59b2

Browse files
committed
Merge pull request godotengine#99563 from akien-mga/fix-projection-stringification
Fix stringification of Projection
2 parents 1606b18 + f2f48aa commit 13d59b2

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

core/math/projection.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -912,14 +912,10 @@ void Projection::set_light_atlas_rect(const Rect2 &p_rect) {
912912
}
913913

914914
Projection::operator String() const {
915-
String str;
916-
for (int i = 0; i < 4; i++) {
917-
for (int j = 0; j < 4; j++) {
918-
str += String((j > 0) ? ", " : "\n") + rtos(columns[i][j]);
919-
}
920-
}
921-
922-
return str;
915+
return "[X: " + columns[0].operator String() +
916+
", Y: " + columns[1].operator String() +
917+
", Z: " + columns[2].operator String() +
918+
", W: " + columns[3].operator String() + "]";
923919
}
924920

925921
real_t Projection::get_aspect() const {

modules/gdscript/tests/scripts/runtime/features/stringify.gd

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func test():
2222
print(AABB(Vector3.ZERO, Vector3.ONE))
2323
print(Basis.from_euler(Vector3(0, 0, 0)))
2424
print(Transform3D.IDENTITY)
25+
print(Projection.IDENTITY)
2526

2627
print(Color(1, 2, 3, 4))
2728
print(StringName("hello"))

modules/gdscript/tests/scripts/runtime/features/stringify.out

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ hello world
1717
[P: (0.0, 0.0, 0.0), S: (1.0, 1.0, 1.0)]
1818
[X: (1.0, 0.0, 0.0), Y: (0.0, 1.0, 0.0), Z: (0.0, 0.0, 1.0)]
1919
[X: (1.0, 0.0, 0.0), Y: (0.0, 1.0, 0.0), Z: (0.0, 0.0, 1.0), O: (0.0, 0.0, 0.0)]
20+
[X: (1.0, 0.0, 0.0, 0.0), Y: (0.0, 1.0, 0.0, 0.0), Z: (0.0, 0.0, 1.0, 0.0), W: (0.0, 0.0, 0.0, 1.0)]
2021
(1.0, 2.0, 3.0, 4.0)
2122
hello
2223
hello/world

0 commit comments

Comments
 (0)