Use FloatUtil.ToString everywhere possible to preserve exact values

This commit is contained in:
dexy 2022-01-31 00:14:44 +11:00
parent 4e1b31d957
commit 8c037e24f0
2 changed files with 10 additions and 19 deletions

View File

@ -132,18 +132,15 @@ namespace CodeWalker
public static string GetVector2String(Vector2 v, string d = ", ")
{
var c = CultureInfo.InvariantCulture;
return v.X.ToString(c) + d + v.Y.ToString(c);
return ToString(v.X) + d + ToString(v.Y);
}
public static string GetVector2XmlString(Vector2 v)
{
var c = CultureInfo.InvariantCulture;
return string.Format("x=\"{0}\" y=\"{1}\"", v.X.ToString(c), v.Y.ToString(c));
return string.Format("x=\"{0}\" y=\"{1}\"", ToString(v.X), ToString(v.Y));
}
public static string GetVector3String(Vector3 v, string d = ", ")
{
var c = CultureInfo.InvariantCulture;
return v.X.ToString(c) + d + v.Y.ToString(c) + d + v.Z.ToString(c);
return ToString(v.X) + d + ToString(v.Y) + d + ToString(v.Z);
}
public static string GetVector3StringFormat(Vector3 v, string format)
{
@ -152,35 +149,29 @@ namespace CodeWalker
}
public static string GetVector3XmlString(Vector3 v)
{
var c = CultureInfo.InvariantCulture;
return string.Format("x=\"{0}\" y=\"{1}\" z=\"{2}\"", v.X.ToString(c), v.Y.ToString(c), v.Z.ToString(c));
return string.Format("x=\"{0}\" y=\"{1}\" z=\"{2}\"", ToString(v.X), ToString(v.Y), ToString(v.Z));
}
public static string GetVector4String(Vector4 v, string d = ", ")
{
var c = CultureInfo.InvariantCulture;
return v.X.ToString(c) + d + v.Y.ToString(c) + d + v.Z.ToString(c) + d + v.W.ToString(c);
return ToString(v.X) + d + ToString(v.Y) + d + ToString(v.Z) + d + ToString(v.W);
}
public static string GetVector4XmlString(Vector4 v)
{
var c = CultureInfo.InvariantCulture;
return string.Format("x=\"{0}\" y=\"{1}\" z=\"{2}\" w=\"{3}\"", v.X.ToString(c), v.Y.ToString(c), v.Z.ToString(c), v.W.ToString(c));
return string.Format("x=\"{0}\" y=\"{1}\" z=\"{2}\" w=\"{3}\"", ToString(v.X), ToString(v.Y), ToString(v.Z), ToString(v.W));
}
public static string GetQuaternionXmlString(Quaternion q)
{
var c = CultureInfo.InvariantCulture;
return string.Format("x=\"{0}\" y=\"{1}\" z=\"{2}\" w=\"{3}\"", q.X.ToString(c), q.Y.ToString(c), q.Z.ToString(c), q.W.ToString(c));
return string.Format("x=\"{0}\" y=\"{1}\" z=\"{2}\" w=\"{3}\"", ToString(q.X), ToString(q.Y), ToString(q.Z), ToString(q.W));
}
public static string GetHalf2String(Half2 v, string d = ", ")
{
var c = CultureInfo.InvariantCulture;
var f = Half.ConvertToFloat(new[] { v.X, v.Y });
return f[0].ToString(c) + d + f[1].ToString(c);
return ToString(f[0]) + d + ToString(f[1]);
}
public static string GetHalf4String(Half4 v, string d = ", ")
{
var c = CultureInfo.InvariantCulture;
var f = Half.ConvertToFloat(new[] { v.X, v.Y, v.Z, v.W });
return f[0].ToString(c) + d + f[1].ToString(c) + d + f[2].ToString(c) + d + f[3].ToString(c);
return ToString(f[0]) + d + ToString(f[1]) + d + ToString(f[2]) + d + ToString(f[3]);
}
public static string GetColourString(Color v, string d = ", ")
{

View File

@ -57,7 +57,7 @@ namespace CodeWalker.Project.Panels
BBMinTextBox.Text = FloatUtil.GetVector3String(CurrentArchetype._BaseArchetypeDef.bbMin);
BBMaxTextBox.Text = FloatUtil.GetVector3String(CurrentArchetype._BaseArchetypeDef.bbMax);
BSCenterTextBox.Text = FloatUtil.GetVector3String(CurrentArchetype._BaseArchetypeDef.bsCentre);
BSRadiusTextBox.Text = CurrentArchetype._BaseArchetypeDef.bsRadius.ToString(CultureInfo.InvariantCulture);
BSRadiusTextBox.Text = FloatUtil.ToString(CurrentArchetype._BaseArchetypeDef.bsRadius);
if (CurrentArchetype is MloArchetype MloArchetype)
{