separate math into float and fixed
parent
85f21b7859
commit
17273d890a
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Audio
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Audio
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Audio
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ namespace MoonWorks.Audio
|
|||
get => _pitch;
|
||||
set
|
||||
{
|
||||
_pitch = MathHelper.Clamp(value, -1f, 1f);
|
||||
_pitch = Math.MathHelper.Clamp(value, -1f, 1f);
|
||||
UpdatePitch();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Collision.Float
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Collision.Float
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Collision.Float
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Collision.Float
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Collision.Float
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Collision.Float
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Collision.Float
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Collision.Float
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Collision.Float
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Collision.Float
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Collision.Float
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Graphics.Font
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#endregion
|
||||
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#region Using Statements
|
||||
using System;
|
||||
using MoonWorks.Math;
|
||||
using MoonWorks.Math.Float;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Graphics
|
||||
|
|
|
@ -22,15 +22,15 @@
|
|||
{
|
||||
return Graphics.VertexElementFormat.Float;
|
||||
}
|
||||
else if (type == typeof(Math.Vector2))
|
||||
else if (type == typeof(Math.Float.Vector2))
|
||||
{
|
||||
return Graphics.VertexElementFormat.Vector2;
|
||||
}
|
||||
else if (type == typeof(Math.Vector3))
|
||||
else if (type == typeof(Math.Float.Vector3))
|
||||
{
|
||||
return Graphics.VertexElementFormat.Vector3;
|
||||
}
|
||||
else if (type == typeof(Math.Vector4))
|
||||
else if (type == typeof(Math.Float.Vector4))
|
||||
{
|
||||
return Graphics.VertexElementFormat.Vector4;
|
||||
}
|
||||
|
|
|
@ -782,9 +782,9 @@ namespace MoonWorks.Math.Fixed
|
|||
/// <summary>
|
||||
/// Casts to floating point Matrix3x2.
|
||||
/// </summary>
|
||||
public static explicit operator Math.Matrix3x2(Matrix3x2 matrix)
|
||||
public static explicit operator Math.Float.Matrix3x2(Matrix3x2 matrix)
|
||||
{
|
||||
return new Math.Matrix3x2(
|
||||
return new Math.Float.Matrix3x2(
|
||||
(float) matrix.M11, (float) matrix.M12,
|
||||
(float) matrix.M21, (float) matrix.M22,
|
||||
(float) matrix.M31, (float) matrix.M32
|
||||
|
|
|
@ -21,7 +21,7 @@ using System.Diagnostics;
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
[Serializable]
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
|
@ -20,7 +20,7 @@ using System.Diagnostics;
|
|||
using System.Text;
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a viewing frustum for intersection operations.
|
|
@ -21,7 +21,7 @@ using System.Diagnostics;
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a sphere in 3D-space for bounding operations.
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines how the bounding volumes intersects or contain one another.
|
|
@ -10,7 +10,7 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
/// <summary>
|
||||
/// A structure encapsulating a 3x2 matrix.
|
|
@ -21,7 +21,7 @@ using System.Runtime.InteropServices;
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the right-handed 4x4 floating point matrix, which can store translation, scale and rotation information.
|
|
@ -20,7 +20,7 @@ using System.Diagnostics;
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
[Serializable]
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the intersection between a <see cref="Plane"/> and a bounding volume.
|
|
@ -20,7 +20,7 @@ using System.Diagnostics;
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a 2D-point.
|
|
@ -20,7 +20,7 @@ using System.Diagnostics;
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
/// <summary>
|
||||
/// An efficient mathematical representation for three dimensional rotations.
|
|
@ -20,7 +20,7 @@ using System.Diagnostics;
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
[Serializable]
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
|
@ -20,7 +20,7 @@ using System.Diagnostics;
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a 2D-rectangle.
|
|
@ -1,4 +1,4 @@
|
|||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
public struct Transform2D : System.IEquatable<Transform2D>
|
||||
{
|
||||
|
@ -6,7 +6,21 @@ namespace MoonWorks.Math
|
|||
public float Rotation { get; }
|
||||
public Vector2 Scale { get; }
|
||||
|
||||
public Matrix3x2 TransformMatrix { get; }
|
||||
private bool transformMatrixCalculated = false;
|
||||
private Matrix3x2 transformMatrix = Matrix3x2.Identity;
|
||||
public Matrix3x2 TransformMatrix
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!transformMatrixCalculated)
|
||||
{
|
||||
transformMatrix = CreateTransformMatrix(Position, Rotation, Scale);
|
||||
transformMatrixCalculated = true;
|
||||
}
|
||||
|
||||
return transformMatrix;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAxisAligned => Rotation % MathHelper.PiOver2 == 0;
|
||||
public bool IsUniformScale => Scale.X == Scale.Y;
|
||||
|
@ -16,7 +30,6 @@ namespace MoonWorks.Math
|
|||
Position = Vector2.Zero;
|
||||
Rotation = 0;
|
||||
Scale = Vector2.One;
|
||||
TransformMatrix = CreateTransformMatrix(Position, Rotation, Scale);
|
||||
}
|
||||
|
||||
public Transform2D(Vector2 position)
|
||||
|
@ -24,7 +37,6 @@ namespace MoonWorks.Math
|
|||
Position = position;
|
||||
Rotation = 0;
|
||||
Scale = Vector2.One;
|
||||
TransformMatrix = CreateTransformMatrix(Position, Rotation, Scale);
|
||||
}
|
||||
|
||||
public Transform2D(Vector2 position, float rotation)
|
||||
|
@ -32,7 +44,6 @@ namespace MoonWorks.Math
|
|||
Position = position;
|
||||
Rotation = rotation;
|
||||
Scale = Vector2.One;
|
||||
TransformMatrix = CreateTransformMatrix(Position, Rotation, Scale);
|
||||
}
|
||||
|
||||
public Transform2D(Vector2 position, float rotation, Vector2 scale)
|
||||
|
@ -40,7 +51,6 @@ namespace MoonWorks.Math
|
|||
Position = position;
|
||||
Rotation = rotation;
|
||||
Scale = scale;
|
||||
TransformMatrix = CreateTransformMatrix(Position, Rotation, Scale);
|
||||
}
|
||||
|
||||
public Transform2D Compose(Transform2D other)
|
|
@ -21,7 +21,7 @@ using System.Runtime.InteropServices;
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a 2D-vector.
|
|
@ -22,7 +22,7 @@ using System.Text;
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a 3D-vector.
|
|
@ -21,7 +21,7 @@ using System.Runtime.InteropServices;
|
|||
|
||||
#endregion
|
||||
|
||||
namespace MoonWorks.Math
|
||||
namespace MoonWorks.Math.Float
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a 4D-vector.
|
Loading…
Reference in New Issue