mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 11:56:49 +01:00
Ported form godot4: Reformat structure string operators
The order of numbers is not changed except for Transform2D. All logic is done inside of their structures (and not in Variant).
-aaronfranke
554c776e08
This commit is contained in:
parent
3b4b25b5f8
commit
d9669b0ed0
@ -463,7 +463,7 @@ float Color::gray() const {
|
||||
}
|
||||
|
||||
Color::operator String() const {
|
||||
return rtos(r) + ", " + rtos(g) + ", " + rtos(b) + ", " + rtos(a);
|
||||
return "(" + String::num(r, 4) + ", " + String::num(g, 4) + ", " + String::num(b, 4) + ", " + String::num(a, 4) + ")";
|
||||
}
|
||||
|
||||
Color Color::operator+(const Color &p_color) const {
|
||||
|
@ -426,5 +426,5 @@ Variant AABB::intersects_rayv(const Vector3 &p_from, const Vector3 &p_dir) const
|
||||
}
|
||||
|
||||
AABB::operator String() const {
|
||||
return String() + position + " - " + size;
|
||||
return "[P: " + position.operator String() + ", S: " + size + "]";
|
||||
}
|
||||
|
@ -803,18 +803,9 @@ bool Basis::operator!=(const Basis &p_matrix) const {
|
||||
}
|
||||
|
||||
Basis::operator String() const {
|
||||
String mtx;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (i != 0 || j != 0) {
|
||||
mtx += ", ";
|
||||
}
|
||||
|
||||
mtx += rtos(rows[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
return mtx;
|
||||
return "[X: " + get_axis(0).operator String() +
|
||||
", Y: " + get_axis(1).operator String() +
|
||||
", Z: " + get_axis(2).operator String() + "]";
|
||||
}
|
||||
|
||||
Quaternion Basis::get_quaternion() const {
|
||||
|
@ -154,5 +154,5 @@ bool Plane::is_equal_approx_any_side(const Plane &p_plane) const {
|
||||
}
|
||||
|
||||
Plane::operator String() const {
|
||||
return normal.operator String() + ", " + rtos(d);
|
||||
return "[N: " + normal.operator String() + ", D: " + String::num_real(d) + "]";
|
||||
}
|
||||
|
@ -866,14 +866,10 @@ Plane Projection::xform(const Plane &p_vec4) const {
|
||||
}
|
||||
|
||||
Projection::operator String() const {
|
||||
String str;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
str += String((j > 0) ? ", " : "\n") + rtos(matrix[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
return "[ X: " + matrix[0].operator String() +
|
||||
", Y: " + matrix[1].operator String() +
|
||||
", Z: " + matrix[2].operator String() +
|
||||
", W: " + matrix[3].operator String() + " ]";
|
||||
}
|
||||
|
||||
real_t Projection::get_aspect() const {
|
||||
|
@ -258,9 +258,9 @@ Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c)
|
||||
}
|
||||
|
||||
Transform::operator String() const {
|
||||
return "[X: " + basis.get_column(0).operator String() +
|
||||
", Y: " + basis.get_column(1).operator String() +
|
||||
", Z: " + basis.get_column(2).operator String() +
|
||||
return "[X: " + basis.get_axis(0).operator String() +
|
||||
", Y: " + basis.get_axis(1).operator String() +
|
||||
", Z: " + basis.get_axis(2).operator String() +
|
||||
", O: " + origin.operator String() + "]";
|
||||
}
|
||||
|
||||
|
@ -330,5 +330,7 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t
|
||||
}
|
||||
|
||||
Transform2D::operator String() const {
|
||||
return String(String() + columns[0] + ", " + columns[1] + ", " + columns[2]);
|
||||
return "[X: " + columns[0].operator String() +
|
||||
", Y: " + columns[1].operator String() +
|
||||
", O: " + columns[2].operator String() + "]";
|
||||
}
|
||||
|
@ -1729,7 +1729,6 @@ String Variant::stringify(List<const void *> &stack) const {
|
||||
return operator Vector4();
|
||||
case VECTOR4I:
|
||||
return operator Vector4i();
|
||||
|
||||
case PLANE:
|
||||
return operator Plane();
|
||||
case QUATERNION:
|
||||
@ -1737,40 +1736,17 @@ String Variant::stringify(List<const void *> &stack) const {
|
||||
case AABB:
|
||||
return operator ::AABB();
|
||||
case BASIS: {
|
||||
Basis mat3 = operator Basis();
|
||||
|
||||
String mtx("(");
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (i != 0) {
|
||||
mtx += ", ";
|
||||
}
|
||||
|
||||
mtx += "(";
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (j != 0) {
|
||||
mtx += ", ";
|
||||
}
|
||||
|
||||
mtx += Variant(mat3.rows[i][j]).operator String();
|
||||
}
|
||||
|
||||
mtx += ")";
|
||||
}
|
||||
|
||||
return mtx + ")";
|
||||
return operator Basis();
|
||||
} break;
|
||||
case TRANSFORM:
|
||||
return operator Transform();
|
||||
case TRANSFORM2D: {
|
||||
Transform2D mat32 = operator Transform2D();
|
||||
return "(" + Variant(mat32.columns[0]).operator String() + ", " + Variant(mat32.columns[1]).operator String() + ", " + Variant(mat32.columns[2]).operator String() + ")";
|
||||
return operator Transform2D();
|
||||
} break;
|
||||
case PROJECTION:
|
||||
return operator Projection();
|
||||
|
||||
case COLOR:
|
||||
return String::num(operator Color().r) + "," + String::num(operator Color().g) + "," + String::num(operator Color().b) + "," + String::num(operator Color().a);
|
||||
return operator Color();
|
||||
case NODE_PATH:
|
||||
return operator NodePath();
|
||||
//RID
|
||||
|
Loading…
Reference in New Issue
Block a user