mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 17:05:37 +00:00
Modified Transform(ref Vector4, ref Matrix4, out Vector4) overload to work correctly when the ref and out parameters point to the same Vector4.
Modified Transform(Vector4, Matrix4): Vector4 to call the reference overload internally. Faster and reduces code duplication.
This commit is contained in:
parent
d757b00e0a
commit
4d3e84701c
|
@ -925,10 +925,7 @@ namespace OpenTK
|
||||||
public static Vector4 Transform(Vector4 vec, Matrix4 mat)
|
public static Vector4 Transform(Vector4 vec, Matrix4 mat)
|
||||||
{
|
{
|
||||||
Vector4 result;
|
Vector4 result;
|
||||||
result.X = Vector4.Dot(vec, mat.Column0);
|
Transform(ref vec, ref mat, out result);
|
||||||
result.Y = Vector4.Dot(vec, mat.Column1);
|
|
||||||
result.Z = Vector4.Dot(vec, mat.Column2);
|
|
||||||
result.W = Vector4.Dot(vec, mat.Column3);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -938,25 +935,11 @@ namespace OpenTK
|
||||||
/// <param name="result">The transformed vector</param>
|
/// <param name="result">The transformed vector</param>
|
||||||
public static void Transform(ref Vector4 vec, ref Matrix4 mat, out Vector4 result)
|
public static void Transform(ref Vector4 vec, ref Matrix4 mat, out Vector4 result)
|
||||||
{
|
{
|
||||||
result.X = vec.X * mat.Row0.X +
|
result = new Vector4(
|
||||||
vec.Y * mat.Row1.X +
|
vec.X * mat.Row0.X + vec.Y * mat.Row1.X + vec.Z * mat.Row2.X + vec.W * mat.Row3.X,
|
||||||
vec.Z * mat.Row2.X +
|
vec.X * mat.Row0.Y + vec.Y * mat.Row1.Y + vec.Z * mat.Row2.Y + vec.W * mat.Row3.Y,
|
||||||
vec.W * mat.Row3.X;
|
vec.X * mat.Row0.Z + vec.Y * mat.Row1.Z + vec.Z * mat.Row2.Z + vec.W * mat.Row3.Z,
|
||||||
|
vec.X * mat.Row0.W + vec.Y * mat.Row1.W + vec.Z * mat.Row2.W + vec.W * mat.Row3.W);
|
||||||
result.Y = vec.X * mat.Row0.Y +
|
|
||||||
vec.Y * mat.Row1.Y +
|
|
||||||
vec.Z * mat.Row2.Y +
|
|
||||||
vec.W * mat.Row3.Y;
|
|
||||||
|
|
||||||
result.Z = vec.X * mat.Row0.Z +
|
|
||||||
vec.Y * mat.Row1.Z +
|
|
||||||
vec.Z * mat.Row2.Z +
|
|
||||||
vec.W * mat.Row3.Z;
|
|
||||||
|
|
||||||
result.W = vec.X * mat.Row0.W +
|
|
||||||
vec.Y * mat.Row1.W +
|
|
||||||
vec.Z * mat.Row2.W +
|
|
||||||
vec.W * mat.Row3.W;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -928,10 +928,7 @@ namespace OpenTK
|
||||||
public static Vector4d Transform(Vector4d vec, Matrix4d mat)
|
public static Vector4d Transform(Vector4d vec, Matrix4d mat)
|
||||||
{
|
{
|
||||||
Vector4d result;
|
Vector4d result;
|
||||||
result.X = Vector4d.Dot(vec, mat.Column0);
|
Transform(ref vec, ref mat, out result);
|
||||||
result.Y = Vector4d.Dot(vec, mat.Column1);
|
|
||||||
result.Z = Vector4d.Dot(vec, mat.Column2);
|
|
||||||
result.W = Vector4d.Dot(vec, mat.Column3);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,25 +938,11 @@ namespace OpenTK
|
||||||
/// <param name="result">The transformed vector</param>
|
/// <param name="result">The transformed vector</param>
|
||||||
public static void Transform(ref Vector4d vec, ref Matrix4d mat, out Vector4d result)
|
public static void Transform(ref Vector4d vec, ref Matrix4d mat, out Vector4d result)
|
||||||
{
|
{
|
||||||
result.X = vec.X * mat.Row0.X +
|
result = new Vector4d(
|
||||||
vec.Y * mat.Row1.X +
|
vec.X * mat.Row0.X + vec.Y * mat.Row1.X + vec.Z * mat.Row2.X + vec.W * mat.Row3.X,
|
||||||
vec.Z * mat.Row2.X +
|
vec.X * mat.Row0.Y + vec.Y * mat.Row1.Y + vec.Z * mat.Row2.Y + vec.W * mat.Row3.Y,
|
||||||
vec.W * mat.Row3.X;
|
vec.X * mat.Row0.Z + vec.Y * mat.Row1.Z + vec.Z * mat.Row2.Z + vec.W * mat.Row3.Z,
|
||||||
|
vec.X * mat.Row0.W + vec.Y * mat.Row1.W + vec.Z * mat.Row2.W + vec.W * mat.Row3.W);
|
||||||
result.Y = vec.X * mat.Row0.Y +
|
|
||||||
vec.Y * mat.Row1.Y +
|
|
||||||
vec.Z * mat.Row2.Y +
|
|
||||||
vec.W * mat.Row3.Y;
|
|
||||||
|
|
||||||
result.Z = vec.X * mat.Row0.Z +
|
|
||||||
vec.Y * mat.Row1.Z +
|
|
||||||
vec.Z * mat.Row2.Z +
|
|
||||||
vec.W * mat.Row3.Z;
|
|
||||||
|
|
||||||
result.W = vec.X * mat.Row0.W +
|
|
||||||
vec.Y * mat.Row1.W +
|
|
||||||
vec.Z * mat.Row2.W +
|
|
||||||
vec.W * mat.Row3.W;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue