daily update on 20240407 by nitload youmu
This commit is contained in:
@@ -0,0 +1,243 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Camera.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the “Software”), to deal in the Software without restriction,
|
||||
// including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
// and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and
|
||||
// this permission notice shall be included in all copies
|
||||
// or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED “AS IS”,
|
||||
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH
|
||||
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Graphics.ShaderEdit;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphic
|
||||
{
|
||||
public sealed class Camera : IglConvertable
|
||||
{
|
||||
|
||||
Uniform<Matrix44>[] convertedUniform ;
|
||||
|
||||
glHandleSet uniformHandle;
|
||||
internal bool _isLookAtAvailable;
|
||||
internal Matrix44 cameraAtt;
|
||||
internal vec3d cameraCoord;
|
||||
internal Matrix44 _lookAt;
|
||||
internal Matrix44 _projection;
|
||||
|
||||
public Camera()
|
||||
{
|
||||
cameraAtt = Matrix44.Unit;
|
||||
cameraCoord = Vec3d.Unit;
|
||||
_isLookAtAvailable = false;
|
||||
_lookAt = Matrix44.Unit;
|
||||
convertedUniform = new Uniform<Matrix44>[2];
|
||||
}
|
||||
|
||||
public Camera(vec3d position, vec3d target, vec3d up) : this()
|
||||
{
|
||||
SetLookAt(position, target, up);
|
||||
}
|
||||
|
||||
public Matrix44 LookAt
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_isLookAtAvailable)
|
||||
{
|
||||
return _lookAt;
|
||||
}
|
||||
Matrix44 att = cameraAtt;
|
||||
att.Colum1 = Linear.Normalize(att.Colum1);
|
||||
Matrix44 coord = Matrix44.Unit;
|
||||
coord.Colum3.vec -= cameraCoord.vec;
|
||||
_lookAt = att.Transpose * coord;
|
||||
_isLookAtAvailable = true;
|
||||
return _lookAt;
|
||||
}
|
||||
}
|
||||
|
||||
public Matrix44 Projection
|
||||
=> _projection;
|
||||
|
||||
public void MoveNear(float distance)
|
||||
{
|
||||
cameraCoord.Z -= distance;
|
||||
}
|
||||
|
||||
public void MoveRight(float distance)
|
||||
{
|
||||
cameraCoord.X -= distance;
|
||||
}
|
||||
|
||||
public void MoveUp(float distance)
|
||||
{
|
||||
cameraCoord.Y -= distance;
|
||||
}
|
||||
|
||||
public void Perspective(Radius fovy, Vec2d size, float zNear, float zFar)
|
||||
{
|
||||
if (fovy == Radius.Zero)
|
||||
{
|
||||
fovy = new Radius(0.000001f);
|
||||
}
|
||||
if (zFar == zNear)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float rad = fovy._radius;
|
||||
float aspect = size.X / size.Y;
|
||||
float tanHalfFovy = Scaler.Tan(rad / 2.0f);
|
||||
tanHalfFovy = tanHalfFovy==float.PositiveInfinity? float.MaxValue : tanHalfFovy;
|
||||
tanHalfFovy = tanHalfFovy == float.NegativeInfinity ? float.MinValue : tanHalfFovy;
|
||||
|
||||
_projection.Colum0.X = 1.0f / (aspect * tanHalfFovy);
|
||||
_projection.Colum1.Y = 1.0f / tanHalfFovy;
|
||||
_projection.Colum2.Z = (-(zFar + zNear)) / (zFar - zNear);
|
||||
_projection.Colum3.W = -1.0f;
|
||||
_projection.Colum2.Y = (-(2.0f * zFar * zNear)) / (zFar - zNear);
|
||||
}
|
||||
|
||||
public void Pitch(Radius r)
|
||||
{
|
||||
Matrix32 partialCoord = new Matrix32(
|
||||
cameraAtt.Colum1.vec,
|
||||
cameraAtt.Colum2.vec
|
||||
);
|
||||
Matrix22 rotation = new Matrix22(
|
||||
GeometryScaler.Cos(r), -GeometryScaler.Sin(r),
|
||||
GeometryScaler.Sin(r), -GeometryScaler.Cos(r)
|
||||
);
|
||||
|
||||
partialCoord *= rotation;
|
||||
cameraAtt.Colum1.vec = partialCoord.colum0.vec;
|
||||
cameraAtt.Colum2.vec = partialCoord.colum1.vec;
|
||||
}
|
||||
|
||||
public void SetLookAt(vec3d position, vec3d target, vec3d up)
|
||||
{
|
||||
vec3d direction = target - position;
|
||||
|
||||
Linear.Normalize(ref direction, ref up);
|
||||
vec3d right = Linear.Cross(up, direction);
|
||||
|
||||
cameraAtt.Colum0.vec = direction.vec;
|
||||
cameraAtt.Colum1.vec = up.vec;
|
||||
cameraAtt.Colum2.vec = right.vec;
|
||||
}
|
||||
|
||||
public void DisplayGLtypeDefinition()
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"struct camera\n" +
|
||||
"\t{{\n" +
|
||||
"\tmatrix4x4 Perspective;\n" +
|
||||
"\tmatrix4x4 View;\n" +
|
||||
"\t}}\n"
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all uniform related to this <see cref="Camera"/>.
|
||||
/// </summary>
|
||||
/// <param name="source">Shader program requires this camera.</param>
|
||||
/// <param name="uniformName">
|
||||
/// Name of all related uniforms.
|
||||
/// If you fallow form from <see cref="IglConvertable.DisplayGLtypeDefinition"/>
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public unsafe void GainAllUniforms(ShaderProgram source, params string[] uniformName)
|
||||
{
|
||||
GLcontext* gl = GL.api;
|
||||
uniformHandle = new glHandleSet(2);
|
||||
byte[] name1;
|
||||
byte[] name2;
|
||||
Console.WriteLine(uniformName.Length);
|
||||
switch (uniformName.Length)
|
||||
{
|
||||
case 2:
|
||||
name1 = Encoding.UTF8.GetBytes(uniformName[0]);
|
||||
name2 = Encoding.UTF8.GetBytes(uniformName[1]);
|
||||
fixed (byte* namePtr = name1)
|
||||
{
|
||||
uniformHandle[(uint)0].Value = gl->glGetUniformLocation(
|
||||
source.handle.Value, namePtr);
|
||||
}
|
||||
fixed (byte* namePtr = name2)
|
||||
{
|
||||
uniformHandle[(uint)1].Value = gl->glGetUniformLocation(
|
||||
source.handle.Value, namePtr);
|
||||
}
|
||||
convertedUniform[0] = Uniform<Matrix44>.FromHandle(uniformHandle[(uint)0]);
|
||||
convertedUniform[1] = Uniform<Matrix44>.FromHandle(uniformHandle[(uint)1]);
|
||||
break;
|
||||
case 1:
|
||||
name1 = Encoding.UTF8.GetBytes($"{uniformName[0]}.Perspective");
|
||||
name2 = Encoding.UTF8.GetBytes($"{uniformName[0]}.View");
|
||||
fixed (byte* namePtr = name1)
|
||||
{
|
||||
uniformHandle[(uint)0].Value = gl->glGetUniformLocation(
|
||||
source.handle.Value, namePtr);
|
||||
}
|
||||
fixed (byte* namePtr = name2)
|
||||
{
|
||||
uniformHandle[(uint)1].Value = gl->glGetUniformLocation(
|
||||
source.handle.Value, namePtr);
|
||||
}
|
||||
convertedUniform[0] = Uniform<Matrix44>.FromHandle(uniformHandle[(uint)0]);
|
||||
convertedUniform[1] = Uniform<Matrix44>.FromHandle(uniformHandle[(uint)1]);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
ShaderStruct IglConvertable.GetConvertedGLtype()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public unsafe void SetAllUniforms()
|
||||
{
|
||||
GL.SetValue(convertedUniform[0], _projection);
|
||||
GL.SetValue(convertedUniform[1], LookAt);
|
||||
}
|
||||
|
||||
~Camera()
|
||||
{
|
||||
if (uniformHandle != null)
|
||||
{
|
||||
uniformHandle.Release();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ using System.Runtime.InteropServices;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = (2 * 2 * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix2x2 : IMat
|
||||
public struct Matrix22 : IMat
|
||||
{
|
||||
|
||||
[FieldOffset(2 * 2 * 4 * sizeof(float))]
|
||||
@@ -46,14 +46,14 @@ namespace StgSharp.Math
|
||||
[FieldOffset(2 * 4 * sizeof(float))]
|
||||
internal Mat2 transpose;
|
||||
|
||||
internal Matrix2x2(
|
||||
internal Matrix22(
|
||||
Mat2 mat
|
||||
)
|
||||
{
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
internal Matrix2x2(
|
||||
internal Matrix22(
|
||||
Vector4 c0,
|
||||
Vector4 c1
|
||||
)
|
||||
@@ -62,7 +62,7 @@ namespace StgSharp.Math
|
||||
mat.colum1 = c1;
|
||||
}
|
||||
|
||||
public Matrix2x2(
|
||||
public Matrix22(
|
||||
float a00, float a01,
|
||||
float a10, float a11
|
||||
)
|
||||
@@ -71,12 +71,12 @@ namespace StgSharp.Math
|
||||
mat.colum1 = new Vector4(a01, a11, 0, 0);
|
||||
}
|
||||
|
||||
public Matrix2x2 Transpose
|
||||
public Matrix22 Transpose
|
||||
{
|
||||
get
|
||||
{
|
||||
InternalTranspose();
|
||||
return new Matrix2x2(this.transpose);
|
||||
return new Matrix22(this.transpose);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,28 +101,28 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x2 operator -(Matrix2x2 left, Matrix2x2 right)
|
||||
public static Matrix22 operator -(Matrix22 left, Matrix22 right)
|
||||
{
|
||||
return new Matrix2x2(
|
||||
return new Matrix22(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x2 operator *(Matrix2x2 mat, float value)
|
||||
public static Matrix22 operator *(Matrix22 mat, float value)
|
||||
{
|
||||
return new Matrix2x2(
|
||||
return new Matrix22(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x2 operator *(Matrix2x2 left, Matrix2x2 right)
|
||||
public static Matrix22 operator *(Matrix22 left, Matrix22 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x2(
|
||||
return new Matrix22(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
@@ -132,10 +132,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator *(Matrix2x2 left, Matrix2x3 right)
|
||||
public static Matrix23 operator *(Matrix22 left, Matrix23 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x3(
|
||||
return new Matrix23(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -147,10 +147,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator *(Matrix2x2 left, Matrix2x4 right)
|
||||
public static Matrix24 operator *(Matrix22 left, Matrix24 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x4(
|
||||
return new Matrix24(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -164,9 +164,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x2 operator /(Matrix2x2 mat, float value)
|
||||
public static Matrix22 operator /(Matrix22 mat, float value)
|
||||
{
|
||||
return new Matrix2x2(
|
||||
return new Matrix22(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value
|
||||
);
|
||||
@@ -174,10 +174,10 @@ namespace StgSharp.Math
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix2x2 operator +(Matrix2x2 left, Matrix2x2 right)
|
||||
public static unsafe Matrix22 operator +(Matrix22 left, Matrix22 right)
|
||||
{
|
||||
Mat2* refmat = InternalIO.add_mat2(&left.mat, &right.mat);
|
||||
Matrix2x2 ret = new Matrix2x2(*refmat);
|
||||
Matrix22 ret = new Matrix22(*refmat);
|
||||
InternalIO.deinit_mat2(refmat);
|
||||
return ret;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ using System.Runtime.InteropServices;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = ((3 + 2) * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix2x3
|
||||
public struct Matrix23
|
||||
{
|
||||
|
||||
[FieldOffset(5 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
@@ -44,7 +44,7 @@ namespace StgSharp.Math
|
||||
[FieldOffset(0)] internal Mat3 mat;
|
||||
[FieldOffset(3 * 4 * sizeof(float))] internal Mat2 transpose;
|
||||
|
||||
internal Matrix2x3(
|
||||
internal Matrix23(
|
||||
Vector4 c0,
|
||||
Vector4 c1,
|
||||
Vector4 c2
|
||||
@@ -55,7 +55,7 @@ namespace StgSharp.Math
|
||||
mat.colum2 = c2;
|
||||
}
|
||||
|
||||
public Matrix2x3(
|
||||
public Matrix23(
|
||||
float a00, float a01, float a02,
|
||||
float a10, float a11, float a12
|
||||
)
|
||||
@@ -126,9 +126,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator -(Matrix2x3 left, Matrix2x3 right)
|
||||
public static Matrix23 operator -(Matrix23 left, Matrix23 right)
|
||||
{
|
||||
return new Matrix2x3(
|
||||
return new Matrix23(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1,
|
||||
left.mat.colum2 - right.mat.colum2
|
||||
@@ -136,9 +136,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator *(Matrix2x3 mat, float value)
|
||||
public static Matrix23 operator *(Matrix23 mat, float value)
|
||||
{
|
||||
return new Matrix2x3(
|
||||
return new Matrix23(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value
|
||||
@@ -146,10 +146,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x2 operator *(Matrix2x3 left, Matrix3x2 right)
|
||||
public static Matrix22 operator *(Matrix23 left, Matrix32 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x2(
|
||||
return new Matrix22(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
@@ -159,10 +159,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator *(Matrix2x3 left, Matrix3x3 right)
|
||||
public static Matrix23 operator *(Matrix23 left, Matrix33 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x3(
|
||||
return new Matrix23(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -174,10 +174,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator *(Matrix2x3 left, Matrix3x4 right)
|
||||
public static Matrix24 operator *(Matrix23 left, Matrix34 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x4(
|
||||
return new Matrix24(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -191,9 +191,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator /(Matrix2x3 mat, float value)
|
||||
public static Matrix23 operator /(Matrix23 mat, float value)
|
||||
{
|
||||
return new Matrix2x3(
|
||||
return new Matrix23(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value
|
||||
@@ -201,9 +201,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator +(Matrix2x3 left, Matrix2x3 right)
|
||||
public static Matrix23 operator +(Matrix23 left, Matrix23 right)
|
||||
{
|
||||
return new Matrix2x3(
|
||||
return new Matrix23(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2
|
||||
@@ -36,7 +36,7 @@ using System.Runtime.InteropServices;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = ((4 + 2) * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix2x4
|
||||
public struct Matrix24
|
||||
{
|
||||
|
||||
[FieldOffset(6 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
@@ -49,7 +49,7 @@ namespace StgSharp.Math
|
||||
[FieldOffset(32)] public Vec2d Colum2;
|
||||
[FieldOffset(48)] public Vec2d Colum3;
|
||||
|
||||
internal Matrix2x4(
|
||||
internal Matrix24(
|
||||
Vector4 c0,
|
||||
Vector4 c1,
|
||||
Vector4 c2,
|
||||
@@ -63,7 +63,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
|
||||
public Matrix2x4(
|
||||
public Matrix24(
|
||||
float a00, float a01, float a02, float a03,
|
||||
float a10, float a11, float a12, float a13
|
||||
)
|
||||
@@ -141,9 +141,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator -(Matrix2x4 left, Matrix2x4 right)
|
||||
public static Matrix24 operator -(Matrix24 left, Matrix24 right)
|
||||
{
|
||||
return new Matrix2x4(
|
||||
return new Matrix24(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1,
|
||||
left.mat.colum2 - right.mat.colum2,
|
||||
@@ -152,9 +152,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator *(Matrix2x4 mat, float value)
|
||||
public static Matrix24 operator *(Matrix24 mat, float value)
|
||||
{
|
||||
return new Matrix2x4(
|
||||
return new Matrix24(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value,
|
||||
@@ -163,10 +163,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x2 operator *(Matrix2x4 left, Matrix4x2 right)
|
||||
public static Matrix22 operator *(Matrix24 left, Matrix42 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x2(
|
||||
return new Matrix22(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
@@ -176,10 +176,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x3 operator *(Matrix2x4 left, Matrix4x3 right)
|
||||
public static Matrix23 operator *(Matrix24 left, Matrix43 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x3(
|
||||
return new Matrix23(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -191,10 +191,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator *(Matrix2x4 left, Matrix4x4 right)
|
||||
public static Matrix24 operator *(Matrix24 left, Matrix44 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix2x4(
|
||||
return new Matrix24(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -208,9 +208,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator /(Matrix2x4 mat, float value)
|
||||
public static Matrix24 operator /(Matrix24 mat, float value)
|
||||
{
|
||||
return new Matrix2x4(
|
||||
return new Matrix24(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value,
|
||||
@@ -219,9 +219,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix2x4 operator +(Matrix2x4 left, Matrix2x4 right)
|
||||
public static Matrix24 operator +(Matrix24 left, Matrix24 right)
|
||||
{
|
||||
return new Matrix2x4(
|
||||
return new Matrix24(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2,
|
||||
@@ -36,7 +36,7 @@ using System.Runtime.InteropServices;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = (5 * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix3x2
|
||||
public struct Matrix32
|
||||
{
|
||||
|
||||
[FieldOffset(0)] internal vec3d colum0;
|
||||
@@ -46,7 +46,7 @@ namespace StgSharp.Math
|
||||
[FieldOffset(0)] internal Mat2 mat;
|
||||
[FieldOffset(2 * 4 * sizeof(float))] internal Mat3 transpose;
|
||||
|
||||
internal Matrix3x2(
|
||||
internal Matrix32(
|
||||
Vector4 c0,
|
||||
Vector4 c1
|
||||
)
|
||||
@@ -56,7 +56,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
|
||||
public unsafe Matrix3x2(
|
||||
public unsafe Matrix32(
|
||||
float a00, float a01,
|
||||
float a10, float a11,
|
||||
float a20, float a21
|
||||
@@ -137,28 +137,28 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator -(Matrix3x2 left, Matrix3x2 right)
|
||||
public static Matrix32 operator -(Matrix32 left, Matrix32 right)
|
||||
{
|
||||
return new Matrix3x2(
|
||||
return new Matrix32(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator *(Matrix3x2 mat, float value)
|
||||
public static Matrix32 operator *(Matrix32 mat, float value)
|
||||
{
|
||||
return new Matrix3x2(
|
||||
return new Matrix32(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator *(Matrix3x2 left, Matrix2x2 right)
|
||||
public static Matrix32 operator *(Matrix32 left, Matrix22 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x2(
|
||||
return new Matrix32(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
@@ -171,10 +171,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator *(Matrix3x2 left, Matrix2x3 right)
|
||||
public static Matrix33 operator *(Matrix32 left, Matrix23 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x3(
|
||||
return new Matrix33(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -190,10 +190,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator *(Matrix3x2 left, Matrix2x4 right)
|
||||
public static Matrix34 operator *(Matrix32 left, Matrix24 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x4(
|
||||
return new Matrix34(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -212,18 +212,18 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator /(Matrix3x2 mat, float value)
|
||||
public static Matrix32 operator /(Matrix32 mat, float value)
|
||||
{
|
||||
return new Matrix3x2(
|
||||
return new Matrix32(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator +(Matrix3x2 left, Matrix3x2 right)
|
||||
public static Matrix32 operator +(Matrix32 left, Matrix32 right)
|
||||
{
|
||||
return new Matrix3x2(
|
||||
return new Matrix32(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1
|
||||
);
|
||||
@@ -36,7 +36,7 @@ using System.Runtime.InteropServices;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = (6 * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix3x3
|
||||
public struct Matrix33
|
||||
{
|
||||
|
||||
[FieldOffset(6 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
@@ -47,7 +47,7 @@ namespace StgSharp.Math
|
||||
[FieldOffset(1 * 4 * sizeof(float))] public vec3d Colum1;
|
||||
[FieldOffset(2 * 4 * sizeof(float))] public vec3d Colum2;
|
||||
|
||||
internal Matrix3x3(
|
||||
internal Matrix33(
|
||||
Vector4 c0,
|
||||
Vector4 c1,
|
||||
Vector4 c2
|
||||
@@ -58,7 +58,7 @@ namespace StgSharp.Math
|
||||
mat.colum2 = c2;
|
||||
}
|
||||
|
||||
public Matrix3x3(
|
||||
public Matrix33(
|
||||
float a00, float a01, float a02,
|
||||
float a10, float a11, float a12,
|
||||
float a20, float a21, float a22
|
||||
@@ -138,9 +138,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator -(Matrix3x3 left, Matrix3x3 right)
|
||||
public static Matrix33 operator -(Matrix33 left, Matrix33 right)
|
||||
{
|
||||
return new Matrix3x3(
|
||||
return new Matrix33(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2
|
||||
@@ -148,9 +148,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator *(Matrix3x3 mat, float value)
|
||||
public static Matrix33 operator *(Matrix33 mat, float value)
|
||||
{
|
||||
return new Matrix3x3(
|
||||
return new Matrix33(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value
|
||||
@@ -158,7 +158,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static vec3d operator *(Matrix3x3 left, vec3d right)
|
||||
public static vec3d operator *(Matrix33 left, vec3d right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new vec3d(
|
||||
@@ -169,10 +169,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator *(Matrix3x3 left, Matrix3x2 right)
|
||||
public static Matrix32 operator *(Matrix33 left, Matrix32 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x2(
|
||||
return new Matrix32(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
@@ -185,10 +185,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator *(Matrix3x3 left, Matrix3x3 right)
|
||||
public static Matrix33 operator *(Matrix33 left, Matrix33 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x3(
|
||||
return new Matrix33(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -204,10 +204,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator *(Matrix3x3 left, Matrix3x4 right)
|
||||
public static Matrix34 operator *(Matrix33 left, Matrix34 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x4(
|
||||
return new Matrix34(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -226,9 +226,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator /(Matrix3x3 mat, float value)
|
||||
public static Matrix33 operator /(Matrix33 mat, float value)
|
||||
{
|
||||
return new Matrix3x3(
|
||||
return new Matrix33(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value
|
||||
@@ -236,9 +236,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator +(Matrix3x3 left, Matrix3x3 right)
|
||||
public static Matrix33 operator +(Matrix33 left, Matrix33 right)
|
||||
{
|
||||
return new Matrix3x3(
|
||||
return new Matrix33(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2
|
||||
@@ -38,7 +38,7 @@ namespace StgSharp.Math
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = (7 * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix3x4
|
||||
public struct Matrix34
|
||||
{
|
||||
|
||||
[FieldOffset(7 * 4 * sizeof(float))] internal bool isTransposed;
|
||||
@@ -51,12 +51,12 @@ namespace StgSharp.Math
|
||||
[FieldOffset(2 * 4 * sizeof(float))] public vec3d Colum2;
|
||||
[FieldOffset(3 * 4 * sizeof(float))] public vec3d Colum3;
|
||||
|
||||
internal Matrix3x4(Mat4 mat)
|
||||
internal Matrix34(Mat4 mat)
|
||||
{
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
internal Matrix3x4(
|
||||
internal Matrix34(
|
||||
Vector4 c0,
|
||||
Vector4 c1,
|
||||
Vector4 c2,
|
||||
@@ -69,7 +69,7 @@ namespace StgSharp.Math
|
||||
mat.colum3 = c3;
|
||||
}
|
||||
|
||||
public Matrix3x4(
|
||||
public Matrix34(
|
||||
float a00, float a01, float a02, float a03,
|
||||
float a10, float a11, float a12, float a13,
|
||||
float a20, float a21, float a22, float a23
|
||||
@@ -141,9 +141,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator -(Matrix3x4 left, Matrix3x4 right)
|
||||
public static Matrix34 operator -(Matrix34 left, Matrix34 right)
|
||||
{
|
||||
return new Matrix3x4(
|
||||
return new Matrix34(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1,
|
||||
left.mat.colum2 - right.mat.colum2,
|
||||
@@ -152,9 +152,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator *(Matrix3x4 mat, float value)
|
||||
public static Matrix34 operator *(Matrix34 mat, float value)
|
||||
{
|
||||
return new Matrix3x4(
|
||||
return new Matrix34(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value,
|
||||
@@ -163,10 +163,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x2 operator *(Matrix3x4 left, Matrix4x2 right)
|
||||
public static Matrix32 operator *(Matrix34 left, Matrix42 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x2(
|
||||
return new Matrix32(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
@@ -179,10 +179,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x3 operator *(Matrix3x4 left, Matrix4x3 right)
|
||||
public static Matrix33 operator *(Matrix34 left, Matrix43 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x3(
|
||||
return new Matrix33(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -198,10 +198,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator *(Matrix3x4 left, Matrix4x4 right)
|
||||
public static Matrix34 operator *(Matrix34 left, Matrix44 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix3x4(
|
||||
return new Matrix34(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -220,9 +220,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator /(Matrix3x4 mat, float value)
|
||||
public static Matrix34 operator /(Matrix34 mat, float value)
|
||||
{
|
||||
return new Matrix3x4(
|
||||
return new Matrix34(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value,
|
||||
@@ -231,9 +231,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix3x4 operator +(Matrix3x4 left, Matrix3x4 right)
|
||||
public static Matrix34 operator +(Matrix34 left, Matrix34 right)
|
||||
{
|
||||
return new Matrix3x4(
|
||||
return new Matrix34(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2,
|
||||
@@ -39,7 +39,7 @@ namespace StgSharp.Math
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = ((16 + 8) * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix4x2
|
||||
public struct Matrix42
|
||||
{
|
||||
|
||||
[FieldOffset((16 + 8) * sizeof(float))] internal bool isTransposed;
|
||||
@@ -47,12 +47,12 @@ namespace StgSharp.Math
|
||||
[FieldOffset(0)] internal Mat2 mat;
|
||||
[FieldOffset(8 * sizeof(float))] internal Mat4 transpose;
|
||||
|
||||
internal Matrix4x2(Mat2 mat)
|
||||
internal Matrix42(Mat2 mat)
|
||||
{
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
internal Matrix4x2(
|
||||
internal Matrix42(
|
||||
Vector4 c0,
|
||||
Vector4 c1
|
||||
)
|
||||
@@ -62,7 +62,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
|
||||
public Matrix4x2(
|
||||
public Matrix42(
|
||||
float a00, float a01,
|
||||
float a10, float a11,
|
||||
float a20, float a21,
|
||||
@@ -144,28 +144,28 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x2 operator -(Matrix4x2 left, Matrix4x2 right)
|
||||
public static unsafe Matrix42 operator -(Matrix42 left, Matrix42 right)
|
||||
{
|
||||
return new Matrix4x2(
|
||||
return new Matrix42(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum0 - right.mat.colum0
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x2 operator *(Matrix4x2 mat, float value)
|
||||
public static Matrix42 operator *(Matrix42 mat, float value)
|
||||
{
|
||||
return new Matrix4x2(
|
||||
return new Matrix42(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x2 operator *(Matrix4x2 left, Matrix2x2 right)
|
||||
public static Matrix42 operator *(Matrix42 left, Matrix22 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x2(
|
||||
return new Matrix42(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
@@ -181,10 +181,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator *(Matrix4x2 left, Matrix2x3 right)
|
||||
public static Matrix43 operator *(Matrix42 left, Matrix23 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x3(
|
||||
return new Matrix43(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -204,10 +204,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x4 operator *(Matrix4x2 left, Matrix2x4 right)
|
||||
public static Matrix44 operator *(Matrix42 left, Matrix24 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x4(
|
||||
return new Matrix44(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -231,18 +231,18 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x2 operator /(Matrix4x2 mat, float value)
|
||||
public static Matrix42 operator /(Matrix42 mat, float value)
|
||||
{
|
||||
return new Matrix4x2(
|
||||
return new Matrix42(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x2 operator +(Matrix4x2 left, Matrix4x2 right)
|
||||
public static unsafe Matrix42 operator +(Matrix42 left, Matrix42 right)
|
||||
{
|
||||
return new Matrix4x2(
|
||||
return new Matrix42(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum0 + right.mat.colum0
|
||||
);
|
||||
@@ -37,7 +37,7 @@ using System.Runtime.InteropServices;
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = (7 * 4 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix4x3 : IEquatable<Matrix4x3>
|
||||
public struct Matrix43 : IEquatable<Matrix43>
|
||||
{
|
||||
|
||||
[FieldOffset(7 * 4 * sizeof(float))]
|
||||
@@ -49,7 +49,7 @@ namespace StgSharp.Math
|
||||
[FieldOffset(3 * 4 * sizeof(float))]
|
||||
internal Mat4 transpose;
|
||||
|
||||
internal Matrix4x3(
|
||||
internal Matrix43(
|
||||
Vector4 c0,
|
||||
Vector4 c1,
|
||||
Vector4 c2
|
||||
@@ -60,7 +60,7 @@ namespace StgSharp.Math
|
||||
mat.colum2 = c2;
|
||||
}
|
||||
|
||||
public Matrix4x3(
|
||||
public Matrix43(
|
||||
float a00, float a01, float a02,
|
||||
float a10, float a11, float a12,
|
||||
float a20, float a21, float a22,
|
||||
@@ -117,10 +117,10 @@ namespace StgSharp.Math
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return (obj is Matrix4x3 x) && Equals(x);
|
||||
return (obj is Matrix43 x) && Equals(x);
|
||||
}
|
||||
|
||||
public bool Equals(Matrix4x3 other)
|
||||
public bool Equals(Matrix43 other)
|
||||
{
|
||||
return EqualityComparer<Mat3>.Default.Equals(mat, other.mat);
|
||||
}
|
||||
@@ -152,24 +152,24 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator -(Matrix4x3 left, Matrix4x3 right)
|
||||
public static Matrix43 operator -(Matrix43 left, Matrix43 right)
|
||||
{
|
||||
return new Matrix4x3(
|
||||
return new Matrix43(
|
||||
left.mat.colum0 - right.mat.colum0,
|
||||
left.mat.colum1 - right.mat.colum1,
|
||||
left.mat.colum2 - right.mat.colum2
|
||||
);
|
||||
}
|
||||
|
||||
public static bool operator !=(Matrix4x3 left, Matrix4x3 right)
|
||||
public static bool operator !=(Matrix43 left, Matrix43 right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator *(Matrix4x3 mat, float value)
|
||||
public static Matrix43 operator *(Matrix43 mat, float value)
|
||||
{
|
||||
return new Matrix4x3(
|
||||
return new Matrix43(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value
|
||||
@@ -177,10 +177,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x2 operator *(Matrix4x3 left, Matrix3x2 right)
|
||||
public static Matrix42 operator *(Matrix43 left, Matrix32 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x2(
|
||||
return new Matrix42(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
@@ -197,10 +197,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator *(Matrix4x3 left, Matrix3x3 right)
|
||||
public static Matrix43 operator *(Matrix43 left, Matrix33 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x3(
|
||||
return new Matrix43(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -221,10 +221,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x4 operator *(Matrix4x3 left, Matrix3x4 right)
|
||||
public static Matrix44 operator *(Matrix43 left, Matrix34 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x4(
|
||||
return new Matrix44(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -249,9 +249,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator /(Matrix4x3 mat, float value)
|
||||
public static Matrix43 operator /(Matrix43 mat, float value)
|
||||
{
|
||||
return new Matrix4x3(
|
||||
return new Matrix43(
|
||||
mat.mat.colum0 / value,
|
||||
mat.mat.colum1 / value,
|
||||
mat.mat.colum2 / value
|
||||
@@ -259,16 +259,16 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator +(Matrix4x3 left, Matrix4x3 right)
|
||||
public static Matrix43 operator +(Matrix43 left, Matrix43 right)
|
||||
{
|
||||
return new Matrix4x3(
|
||||
return new Matrix43(
|
||||
left.mat.colum0 + right.mat.colum0,
|
||||
left.mat.colum1 + right.mat.colum1,
|
||||
left.mat.colum2 + right.mat.colum2
|
||||
);
|
||||
}
|
||||
|
||||
public static bool operator ==(Matrix4x3 left, Matrix4x3 right)
|
||||
public static bool operator ==(Matrix43 left, Matrix43 right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="matrix4x4.cs"
|
||||
// file="Matrix44.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -29,6 +29,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -41,20 +42,24 @@ namespace StgSharp.Math
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = (2 * 16 * sizeof(float)) + sizeof(bool), Pack = 16)]
|
||||
public struct Matrix4x4 : IEquatable<Matrix4x4>
|
||||
public unsafe struct Matrix44 : IEquatable<Matrix44>
|
||||
{
|
||||
|
||||
[FieldOffset(2 * 64 * sizeof(float))] internal bool isTransposed;
|
||||
|
||||
[FieldOffset(0)] internal Mat4 mat;
|
||||
[FieldOffset(64 * sizeof(float))] internal Mat4 transpose;
|
||||
[FieldOffset(16 * sizeof(float))] internal Mat4 transpose;
|
||||
[FieldOffset(0 * sizeof(float))] public vec4d Colum0;
|
||||
[FieldOffset(4 * sizeof(float))] public vec4d Colum1;
|
||||
[FieldOffset(8 * sizeof(float))] public vec4d Colum2;
|
||||
[FieldOffset(12 * sizeof(float))] public vec4d Colum3;
|
||||
|
||||
internal Matrix4x4(Mat4 mat)
|
||||
internal Matrix44(Mat4 mat)
|
||||
{
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
internal Matrix4x4(
|
||||
internal Matrix44(
|
||||
Vector4 vec0,
|
||||
Vector4 vec1,
|
||||
Vector4 vec2,
|
||||
@@ -68,7 +73,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
|
||||
public unsafe Matrix4x4(
|
||||
public unsafe Matrix44(
|
||||
float a00, float a01, float a02, float a03,
|
||||
float a10, float a11, float a12, float a13,
|
||||
float a20, float a21, float a22, float a23,
|
||||
@@ -76,9 +81,9 @@ namespace StgSharp.Math
|
||||
)
|
||||
{
|
||||
mat.colum0 = new Vector4(a00, a10, a20, a30);
|
||||
mat.colum0 = new Vector4(a01, a11, a21, a31);
|
||||
mat.colum0 = new Vector4(a02, a12, a22, a32);
|
||||
mat.colum0 = new Vector4(a03, a13, a23, a33);
|
||||
mat.colum1 = new Vector4(a01, a11, a21, a31);
|
||||
mat.colum2 = new Vector4(a02, a12, a22, a32);
|
||||
mat.colum3 = new Vector4(a03, a13, a23, a33);
|
||||
|
||||
}
|
||||
|
||||
@@ -86,6 +91,7 @@ namespace StgSharp.Math
|
||||
{
|
||||
get
|
||||
{
|
||||
#if DEBUG
|
||||
if ((rowNum > 3) || (rowNum < 0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
@@ -94,6 +100,7 @@ namespace StgSharp.Math
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
#endif
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
@@ -105,7 +112,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
#if DEBUG
|
||||
if ((rowNum > 3) || (rowNum < 0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
@@ -114,6 +121,7 @@ namespace StgSharp.Math
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(columNum));
|
||||
}
|
||||
#endif
|
||||
InternalTranspose();
|
||||
fixed (float* p = &this.transpose.m00)
|
||||
{
|
||||
@@ -125,9 +133,25 @@ namespace StgSharp.Math
|
||||
isTransposed = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Matrix44 Transpose
|
||||
{
|
||||
get
|
||||
{
|
||||
InternalTranspose();
|
||||
return new Matrix44(this.transpose);
|
||||
}
|
||||
}
|
||||
|
||||
public static Matrix44 Unit
|
||||
=> new Matrix44(
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe float Det()
|
||||
{
|
||||
@@ -140,10 +164,10 @@ namespace StgSharp.Math
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return (obj is Matrix4x4 x) && Equals(x);
|
||||
return (obj is Matrix44 x) && Equals(x);
|
||||
}
|
||||
|
||||
public bool Equals(Matrix4x4 other)
|
||||
public bool Equals(Matrix44 other)
|
||||
{
|
||||
return mat.Equals(other.mat);
|
||||
}
|
||||
@@ -164,7 +188,6 @@ namespace StgSharp.Math
|
||||
return $"{transpose.colum0}{transpose.colum1}{transpose.colum2}{transpose.colum3}";
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal unsafe void InternalTranspose()
|
||||
{
|
||||
@@ -180,9 +203,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x4 operator -(Matrix4x4 left, Matrix4x4 right)
|
||||
public static unsafe Matrix44 operator -(Matrix44 left, Matrix44 right)
|
||||
{
|
||||
return new Matrix4x4(
|
||||
return new Matrix44(
|
||||
right.mat.colum0 - left.mat.colum0,
|
||||
right.mat.colum1 - left.mat.colum1,
|
||||
right.mat.colum2 - left.mat.colum2,
|
||||
@@ -190,15 +213,15 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
public static bool operator !=(Matrix4x4 left, Matrix4x4 right)
|
||||
public static bool operator !=(Matrix44 left, Matrix44 right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x4 operator *(Matrix4x4 mat, float value)
|
||||
public static unsafe Matrix44 operator *(Matrix44 mat, float value)
|
||||
{
|
||||
return new Matrix4x4(
|
||||
return new Matrix44(
|
||||
mat.mat.colum0 * value,
|
||||
mat.mat.colum1 * value,
|
||||
mat.mat.colum2 * value,
|
||||
@@ -207,10 +230,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x2 operator *(Matrix4x4 left, Matrix4x2 right)
|
||||
public static unsafe Matrix42 operator *(Matrix44 left, Matrix42 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x2(
|
||||
return new Matrix42(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
|
||||
@@ -226,10 +249,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x3 operator *(Matrix4x4 left, Matrix4x3 right)
|
||||
public static Matrix43 operator *(Matrix44 left, Matrix43 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x3(
|
||||
return new Matrix43(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -249,10 +272,10 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x4 operator *(Matrix4x4 left, Matrix4x4 right)
|
||||
public static Matrix44 operator *(Matrix44 left, Matrix44 right)
|
||||
{
|
||||
left.InternalTranspose();
|
||||
return new Matrix4x4(
|
||||
return new Matrix44(
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum0),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum1),
|
||||
Vector4.Dot(left.transpose.colum0, right.mat.colum2),
|
||||
@@ -277,9 +300,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe Matrix4x4 operator +(Matrix4x4 left, Matrix4x4 right)
|
||||
public static unsafe Matrix44 operator +(Matrix44 left, Matrix44 right)
|
||||
{
|
||||
return new Matrix4x4(
|
||||
return new Matrix44(
|
||||
right.mat.colum0 + left.mat.colum0,
|
||||
right.mat.colum1 + left.mat.colum1,
|
||||
right.mat.colum2 + left.mat.colum2,
|
||||
@@ -287,7 +310,7 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
public static bool operator ==(Matrix4x4 left, Matrix4x4 right)
|
||||
public static bool operator ==(Matrix44 left, Matrix44 right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Vector.Cross.cs"
|
||||
// file="Linear.Cross.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -30,7 +30,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static unsafe partial class Vector
|
||||
public static unsafe partial class Linear
|
||||
{
|
||||
|
||||
public static float Cross(Vec2d vec1, Vec2d vec2)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Vector.GetAngle.cs"
|
||||
// file="Linear.GetAngle.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -30,7 +30,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static unsafe partial class Vector
|
||||
public static unsafe partial class Linear
|
||||
{
|
||||
|
||||
public static float GetAngle(Vec2d vec1, Vec2d vec2)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Vector.GetLength.cs"
|
||||
// file="Linear.GetLength.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -30,7 +30,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static unsafe partial class Vector
|
||||
public static unsafe partial class Linear
|
||||
{
|
||||
|
||||
public static float GetLength(this vec3d vec)
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
|
||||
internal static partial class InternalIO
|
||||
{
|
||||
[DllImport(SSC_libname, EntryPoint = "normalize",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Normalize(M128* source, M128* target);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static partial class Linear
|
||||
{
|
||||
public static unsafe void Normalize(ref vec4d source, ref vec4d target)
|
||||
{
|
||||
Vector4 s = source.vec;
|
||||
Vector4 t = target.vec;
|
||||
|
||||
s = Vector4.Normalize(s);
|
||||
|
||||
float dotProduct = Vector4.Dot(s, t);
|
||||
Vector4 projection = Vector4.Multiply(s, t);
|
||||
|
||||
t -= projection;
|
||||
|
||||
source.vec = s;
|
||||
target.vec = t;
|
||||
}
|
||||
|
||||
public static unsafe void Normalize(ref vec3d source, ref vec3d target)
|
||||
{
|
||||
Vector4 s = source.vec;
|
||||
Vector4 t = target.vec;
|
||||
|
||||
s = Vector4.Normalize(s);
|
||||
|
||||
float dotProduct = Vector4.Dot(s, t);
|
||||
Vector4 projection = Vector4.Multiply(s, t);
|
||||
|
||||
t -= projection;
|
||||
|
||||
source.vec = s;
|
||||
target.vec = t;
|
||||
}
|
||||
|
||||
public static vec4d Normalize(vec4d vec)
|
||||
{
|
||||
return new vec4d() { vec = Vector4.Normalize(vec.vec) };
|
||||
}
|
||||
public static vec3d Normalize(vec3d vec)
|
||||
{
|
||||
return new vec3d() { vec = Vector4.Normalize(vec.vec) };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Vector.VectorTransform.cs"
|
||||
// file="Linear.VectorTransform.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
|
||||
@@ -34,7 +34,7 @@ using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math.Linear
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 5 * 4 * sizeof(float))]
|
||||
public struct mat5 : IMat
|
||||
|
||||
@@ -34,7 +34,7 @@ using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math.Linear
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct mat6 : IMat
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace StgSharp.Math
|
||||
[FieldOffset(0)]
|
||||
internal Vector4 vec;
|
||||
|
||||
[FieldOffset(0)] internal unsafe fixed float num[2];
|
||||
|
||||
[FieldOffset(0)]
|
||||
public float X;
|
||||
[FieldOffset(4)]
|
||||
|
||||
@@ -47,6 +47,10 @@ namespace StgSharp.Math
|
||||
|
||||
[FieldOffset(0)]
|
||||
internal Vector4 vec;
|
||||
[FieldOffset(0)]
|
||||
internal M128 reg;
|
||||
|
||||
[FieldOffset(0)] internal unsafe fixed float num[3];
|
||||
|
||||
[FieldOffset(0)] public float X;
|
||||
[FieldOffset(4)] public float Y;
|
||||
@@ -140,6 +144,12 @@ namespace StgSharp.Math
|
||||
return new vec3d(0, 0, 0);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static vec3d operator -(vec3d vec)
|
||||
{
|
||||
return new vec3d(-vec.vec);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static vec3d operator -(vec3d left, vec3d right)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Vec4d.cs"
|
||||
// file="vec4d.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -38,25 +38,32 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static class Vec4d
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
|
||||
public struct Vec4d
|
||||
public struct vec4d
|
||||
{
|
||||
|
||||
[FieldOffset(0)] internal M128 reg;
|
||||
|
||||
[FieldOffset(0)] internal Vector4 vec;
|
||||
[FieldOffset(12)] public float W;
|
||||
|
||||
[FieldOffset(0)] internal unsafe fixed float num[4];
|
||||
|
||||
[FieldOffset(0)] public float X;
|
||||
[FieldOffset(4)] public float Y;
|
||||
[FieldOffset(8)] public float Z;
|
||||
[FieldOffset(12)] public float W;
|
||||
|
||||
public Vec4d(float x, float y, float z, float w)
|
||||
public vec4d(float x, float y, float z, float w)
|
||||
{
|
||||
vec = new Vector4(x, y, z, w);
|
||||
}
|
||||
|
||||
public static implicit operator M128(Vec4d vec)
|
||||
public static implicit operator M128(vec4d vec)
|
||||
{
|
||||
return vec.reg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user