Skip to content

Commit f2f48aa

Browse files
committed
Fix stringification of Projection
1 parent d09d82d commit f2f48aa

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

core/math/projection.cpp

Lines changed: 4 additions & 8 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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)