Merge pull request #5950 from neikeq/pr-issue-5944
Fix regression with str() improvements for math types
This commit is contained in:
commit
0dc2adad46
6 changed files with 44 additions and 23 deletions
|
@ -658,5 +658,5 @@ Matrix32 Matrix32::interpolate_with(const Matrix32& p_transform, float p_c) cons
|
|||
|
||||
Matrix32::operator String() const {
|
||||
|
||||
return "("+String(String()+elements[0]+", "+elements[1]+", "+elements[2])+")";
|
||||
return String(String()+elements[0]+", "+elements[1]+", "+elements[2]);
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ struct Vector2 {
|
|||
float get_aspect() const { return width/height; }
|
||||
|
||||
|
||||
operator String() const { return "("+String::num(x)+", "+String::num(y)+")"; }
|
||||
operator String() const { return String::num(x)+", "+String::num(y); }
|
||||
|
||||
_FORCE_INLINE_ Vector2(float p_x,float p_y) { x=p_x; y=p_y; }
|
||||
_FORCE_INLINE_ Vector2() { x=0; y=0; }
|
||||
|
@ -356,7 +356,7 @@ struct Rect2 {
|
|||
}
|
||||
|
||||
|
||||
operator String() const { return "("+String(pos)+", "+String(size)+")"; }
|
||||
operator String() const { return String(pos)+", "+String(size); }
|
||||
|
||||
Rect2() {}
|
||||
Rect2( float p_x, float p_y, float p_width, float p_height) { pos=Point2(p_x,p_y); size=Size2( p_width, p_height ); }
|
||||
|
@ -409,7 +409,7 @@ struct Point2i {
|
|||
|
||||
float get_aspect() const { return width/(float)height; }
|
||||
|
||||
operator String() const { return "("+String::num(x)+", "+String::num(y)+")"; }
|
||||
operator String() const { return String::num(x)+", "+String::num(y); }
|
||||
|
||||
operator Vector2() const { return Vector2(x,y); }
|
||||
inline Point2i(const Vector2& p_vec2) { x=(int)p_vec2.x; y=(int)p_vec2.y; }
|
||||
|
@ -540,7 +540,7 @@ struct Rect2i {
|
|||
}
|
||||
|
||||
|
||||
operator String() const { return "("+String(pos)+", "+String(size)+")"; }
|
||||
operator String() const { return String(pos)+", "+String(size); }
|
||||
|
||||
operator Rect2() const { return Rect2(pos,size); }
|
||||
Rect2i(const Rect2& p_r2) { pos=p_r2.pos; size=p_r2.size; }
|
||||
|
|
|
@ -233,26 +233,19 @@ bool Matrix3::operator!=(const Matrix3& p_matrix) const {
|
|||
|
||||
Matrix3::operator String() const {
|
||||
|
||||
String mtx("(");
|
||||
String mtx;
|
||||
for (int i=0;i<3;i++) {
|
||||
|
||||
if (i!=0)
|
||||
mtx+=", ";
|
||||
|
||||
mtx+="(";
|
||||
|
||||
for (int j=0;j<3;j++) {
|
||||
|
||||
if (j!=0)
|
||||
if (i!=0 || j!=0)
|
||||
mtx+=", ";
|
||||
|
||||
mtx+=rtos( elements[i][j] );
|
||||
}
|
||||
|
||||
mtx+=")";
|
||||
}
|
||||
|
||||
return mtx+")";
|
||||
return mtx;
|
||||
}
|
||||
|
||||
Matrix3::operator Quat() const {
|
||||
|
|
|
@ -252,7 +252,7 @@ Quat Quat::cubic_slerp(const Quat& q, const Quat& prep, const Quat& postq,const
|
|||
|
||||
Quat::operator String() const {
|
||||
|
||||
return "("+String::num(x)+", "+String::num(y)+", "+ String::num(z)+", "+ String::num(w)+")";
|
||||
return String::num(x)+", "+String::num(y)+", "+ String::num(z)+", "+ String::num(w);
|
||||
}
|
||||
|
||||
Quat::Quat(const Vector3& axis, const real_t& angle) {
|
||||
|
|
|
@ -182,5 +182,5 @@ Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, co
|
|||
# endif
|
||||
Vector3::operator String() const {
|
||||
|
||||
return "("+(rtos(x)+", "+rtos(y)+", "+rtos(z))+")";
|
||||
return (rtos(x)+", "+rtos(y)+", "+rtos(z));
|
||||
}
|
||||
|
|
|
@ -1515,15 +1515,43 @@ Variant::operator String() const {
|
|||
case INT: return String::num(_data._int);
|
||||
case REAL: return String::num(_data._real);
|
||||
case STRING: return *reinterpret_cast<const String*>(_data._mem);
|
||||
case VECTOR2: return operator Vector2();
|
||||
case RECT2: return operator Rect2();
|
||||
case MATRIX32: return operator Matrix32();
|
||||
case VECTOR3: return operator Vector3();
|
||||
case VECTOR2: return "("+operator Vector2()+")";
|
||||
case RECT2: return "("+operator Rect2()+")";
|
||||
case MATRIX32: {
|
||||
|
||||
Matrix32 mat32 = operator Matrix32();
|
||||
return "("+Variant(mat32.elements[0]).operator String()+", "+Variant(mat32.elements[1]).operator String()+", "+Variant(mat32.elements[2]).operator String()+")";
|
||||
} break;
|
||||
case VECTOR3: return "("+operator Vector3()+")";
|
||||
case PLANE: return operator Plane();
|
||||
//case QUAT:
|
||||
case _AABB: return operator AABB();
|
||||
case QUAT: return operator Quat();
|
||||
case MATRIX3: return operator Matrix3();
|
||||
case QUAT: return "("+operator Quat()+")";
|
||||
case MATRIX3: {
|
||||
|
||||
Matrix3 mat3 = operator Matrix3();
|
||||
|
||||
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.elements[i][j] ).operator String();
|
||||
}
|
||||
|
||||
mtx+=")";
|
||||
}
|
||||
|
||||
return mtx+")";
|
||||
} break;
|
||||
case TRANSFORM: return operator Transform();
|
||||
case NODE_PATH: return operator NodePath();
|
||||
case INPUT_EVENT: return operator InputEvent();
|
||||
|
|
Loading…
Reference in a new issue