Jump to content

C# - mat3.ToString() and mat4.ToString() missing space


photo

Recommended Posts

Hi,

for mat3.ToString() and mat4.ToString() there seems to be a missing space character after each column. For example

mat3 result = mat3.IDENTITY;

string output = mat3.ToString();

//result is 1 0 00 1 00 0 1

 

Parsing the string in again, considering spaces as split markers, leads to a non-conform matrix.

Fixing this bug should be quite easy:

mat3.cs - Line 767

//old
public override string ToString() => this.m00.ToString() + " " + this.m01.ToString() + " " + this.m02.ToString() + this.m10.ToString() + " " + this.m11.ToString() + " " + this.m12.ToString() + this.m20.ToString() + " " + this.m21.ToString() + " " + this.m22.ToString();

//new
public override string ToString() => this.m00.ToString() + " " + this.m01.ToString() + " " + this.m02.ToString() + " " + this.m10.ToString() + " " + this.m11.ToString() + " " + this.m12.ToString() + this.m20.ToString() + " " + this.m21.ToString() + " " + this.m22.ToString();

mat4.cs - Line 1221

//old
public override string ToString() => this.m00.ToString() + " " + this.m01.ToString() + " " + this.m02.ToString() + " " + this.m03.ToString() + this.m10.ToString() + " " + this.m11.ToString() + " " + this.m12.ToString() + " " + this.m13.ToString() + this.m20.ToString() + " " + this.m21.ToString() + " " + this.m22.ToString() + " " + this.m23.ToString() + " " + this.m30.ToString() + this.m31.ToString() + " " + this.m32.ToString() + " " + this.m33.ToString();

//new
public override string ToString() => this.m00.ToString() + " " + this.m01.ToString() + " " + this.m02.ToString() + " " + this.m03.ToString() + " " + this.m10.ToString() + " " + this.m11.ToString() + " " + this.m12.ToString() + " " + this.m13.ToString() + " " + this.m20.ToString() + " " + this.m21.ToString() + " " + this.m22.ToString() + " " + this.m23.ToString() + " " + this.m30.ToString() + " " + this.m31.ToString() + " " + this.m32.ToString() + " " + this.m33.ToString();

 

Link to comment

Hi silent,

with the ToString()-functions in C# I am facing another inconsistency. While all the matrices functions uses direct ToString-access of their variables (like mat4.m00.ToString() where m00 is a float or double), the vector and quat functions will format their variables with CultureInfo.CurrentCulture.

With german formatting the vec3.ToString() functions for example leads to following output:

 

vec3 standardVector = new vec3(0.0002f,0.0f,0.0f);
string outputString = standardVector.ToString() // results in 0,0002. 0. 0

 

For a more convenient behavior I would propose to use direct variable output like in your matrices.

 

Link to comment
×
×
  • Create New...