daily update on 20240407 by nitload youmu
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,8 @@ out vec4 TexColor;
|
||||
out vec2 TexCoord;
|
||||
|
||||
uniform vec4 color;
|
||||
uniform mat4x4 lookAt;
|
||||
uniform mat4x4 projection;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -19,10 +21,13 @@ void main()
|
||||
0,0,1,0,
|
||||
0,0,0,1
|
||||
);
|
||||
gl_Position = rotation * (vec4(aPos.xyz,1.0) + vec4(color.xyz-vec3(0.5,0.5,0.5),0.0));
|
||||
vec4 temp = (vec4(aPos.xyz,1.0) + vec4(color.yz-vec2(0.5,0.5),0.0,0.0)) * rotation;
|
||||
gl_Position = projection * lookAt * temp;
|
||||
TexColor = color;
|
||||
TexCoord = aTextCoord;
|
||||
}
|
||||
|
||||
//struct
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -278,12 +278,6 @@
|
||||
A handle to an OpenGL object.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.glHandleSet.Free">
|
||||
<summary>
|
||||
temporarily release the handle of GLhandle sets.
|
||||
Please call <see cref="M:StgSharp.Graphics.glHandleSet.Pin"/> method before indexing.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.glHandleSet.Release">
|
||||
<summary>
|
||||
Release all resource in this handle.
|
||||
@@ -291,6 +285,27 @@
|
||||
This <see langword="glHandle"/> will be not usable.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderEdit.IglConvertable.SetAllUniforms">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderEdit.IglConvertable.GainAllUniforms(StgSharp.Graphics.ShaderProgram,System.String[])">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderEdit.IglConvertable.DisplayGLtypeDefinition">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderEdit.IglConvertable.GetConvertedGLtype">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.Shader.AttachTo(System.Int32,StgSharp.Graphics.ShaderProgram)">
|
||||
<summary>
|
||||
Attach one shader code to a shader program.
|
||||
@@ -300,7 +315,7 @@
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderProgram.#ctor(StgSharp.Graphics.Form)">
|
||||
<summary>
|
||||
Inti a shader with no program attached.
|
||||
Init a program with no shader attached.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderProgram.GetUniform``1(System.String)">
|
||||
@@ -385,6 +400,74 @@
|
||||
<param name="message">A string contains information of how current evironment runs.</param>
|
||||
<param name="logType">The severity of current message.</param>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.GLclampf">
|
||||
<summary>
|
||||
OpenGL numeric type.
|
||||
An IEEE-754 floating-point value, clamped to the range [0,1].
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.GLclampd">
|
||||
<summary>
|
||||
OpenGL numeric type.
|
||||
An IEEE-754 double precision floating-point value, clamped to the range [0,1].
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.Vec2d">
|
||||
<summary>
|
||||
A two dimension vector defined by two elements.
|
||||
Vec2Ds in StgSharp are defaultly usaed as colum vector.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.ASin(System.Single)">
|
||||
<summary>
|
||||
Reurns the value of ArcSin(x)
|
||||
</summary>
|
||||
<param name="x">The sine value of the angle</param>
|
||||
<returns></returns>
|
||||
<exception cref="T:System.ArgumentException"></exception>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Exp(System.Single)">
|
||||
<summary>
|
||||
Get the value of E ^ x;
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Log(System.Single)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns>
|
||||
Returns the value of ln(x).
|
||||
</returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Pow(System.Single,System.Single)">
|
||||
<summary>
|
||||
calculate the value of x^y
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<param name="y"></param>
|
||||
<returns>Returns the value of x^y</returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.LowProceisionRandom">
|
||||
<summary>
|
||||
returns a random float number between 0 and 1.
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Random">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.RandomSeed">
|
||||
<summary>
|
||||
Generates a random seed in int value.
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:StgSharp.Geometries.Arc">
|
||||
<summary>
|
||||
Part of a circle. All points on a arc has the same distance to their center.
|
||||
@@ -585,74 +668,17 @@
|
||||
The method this <see cref="T:StgSharp.TimeSpanProvider"/> will call every time a new time span started.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.GLclampf">
|
||||
<member name="M:StgSharp.Graphic.Camera.GainAllUniforms(StgSharp.Graphics.ShaderProgram,System.String[])">
|
||||
<summary>
|
||||
OpenGL numeric type.
|
||||
An IEEE-754 floating-point value, clamped to the range [0,1].
|
||||
Get all uniform related to this <see cref="T:StgSharp.Graphic.Camera"/>.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.GLclampd">
|
||||
<summary>
|
||||
OpenGL numeric type.
|
||||
An IEEE-754 double precision floating-point value, clamped to the range [0,1].
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.Vec2d">
|
||||
<summary>
|
||||
A two dimension vector defined by two elements.
|
||||
Vec2Ds in StgSharp are defaultly usaed as colum vector.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.ASin(System.Single)">
|
||||
<summary>
|
||||
Reurns the value of ArcSin(x)
|
||||
</summary>
|
||||
<param name="x">The sine value of the angle</param>
|
||||
<returns></returns>
|
||||
<param name="source">Shader program requires this camera.</param>
|
||||
<param name="uniformName">
|
||||
Name of all related uniforms.
|
||||
If you fallow form from <see cref="M:StgSharp.Graphics.ShaderEdit.IglConvertable.DisplayGLtypeDefinition"/>
|
||||
</param>
|
||||
<exception cref="T:System.ArgumentException"></exception>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Exp(System.Single)">
|
||||
<summary>
|
||||
Get the value of E ^ x;
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Log(System.Single)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns>
|
||||
Returns the value of ln(x).
|
||||
</returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Pow(System.Single,System.Single)">
|
||||
<summary>
|
||||
calculate the value of x^y
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<param name="y"></param>
|
||||
<returns>Returns the value of x^y</returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.LowProceisionRandom">
|
||||
<summary>
|
||||
returns a random float number between 0 and 1.
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Random">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.RandomSeed">
|
||||
<summary>
|
||||
Generates a random seed in int value.
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Windows.Win32.Foundation.COLORREF">
|
||||
<summary>The COLORREF value is used to specify an RGB color.</summary>
|
||||
<remarks>
|
||||
|
||||
@@ -424,7 +424,7 @@ namespace StgSharp.Graphics
|
||||
internal unsafe delegate*<uint, double, double, int, int, double, double, int, int, double, double, int, int, double*, void> glDeformationMap3dSGIX;
|
||||
internal unsafe delegate*<uint, float, float, int, int, float, float, int, int, float, float, int, int, float*, void> glDeformationMap3fSGIX;
|
||||
internal unsafe delegate*<uint, uint, void> glDeleteAsyncMarkersSGIX;
|
||||
internal unsafe delegate*<uint, uint*, void> glDeleteBuffers;
|
||||
internal unsafe delegate*<int, uint*, void> glDeleteBuffers;
|
||||
internal unsafe delegate*<uint, uint*, void> glDeleteBuffersARB;
|
||||
internal unsafe delegate*<uint, uint*, void> glDeleteCommandListsNV;
|
||||
internal unsafe delegate*<uint, uint*, void> glDeleteFencesAPPLE;
|
||||
@@ -458,7 +458,7 @@ namespace StgSharp.Graphics
|
||||
internal unsafe delegate*<uint, uint*, void> glDeleteTexturesEXT;
|
||||
internal unsafe delegate*<uint, uint*, void> glDeleteTransformFeedbacks;
|
||||
internal unsafe delegate*<uint, uint*, void> glDeleteTransformFeedbacksNV;
|
||||
internal unsafe delegate*<uint, uint*, void> glDeleteVertexArrays;
|
||||
internal unsafe delegate*<int, uint*, void> glDeleteVertexArrays;
|
||||
internal unsafe delegate*<uint, uint*, void> glDeleteVertexArraysAPPLE;
|
||||
internal unsafe delegate*<uint, void> glDeleteVertexShaderEXT;
|
||||
internal unsafe delegate*<GLclampd, GLclampd, void> glDepthBoundsEXT;
|
||||
@@ -653,7 +653,7 @@ namespace StgSharp.Graphics
|
||||
internal unsafe delegate*<float, float, float, float, float, float, void> glFrustumfOES;
|
||||
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, void> glFrustumxOES;
|
||||
internal unsafe delegate*<uint, uint> glGenAsyncMarkersSGIX;
|
||||
internal unsafe delegate*<uint, uint*, void> glGenBuffers;
|
||||
internal unsafe delegate*<int, uint*, void> glGenBuffers;
|
||||
internal unsafe delegate*<uint, uint*, void> glGenBuffersARB;
|
||||
internal unsafe delegate*<uint, uint*, void> glGenFencesAPPLE;
|
||||
internal unsafe delegate*<uint, uint*, void> glGenFencesNV;
|
||||
@@ -679,7 +679,7 @@ namespace StgSharp.Graphics
|
||||
internal unsafe delegate*<uint, uint*, void> glGenTexturesEXT;
|
||||
internal unsafe delegate*<uint, uint*, void> glGenTransformFeedbacks;
|
||||
internal unsafe delegate*<uint, uint*, void> glGenTransformFeedbacksNV;
|
||||
internal unsafe delegate*<uint, uint*, void> glGenVertexArrays;
|
||||
internal unsafe delegate*<int, uint*, void> glGenVertexArrays;
|
||||
internal unsafe delegate*<uint, uint*, void> glGenVertexArraysAPPLE;
|
||||
internal unsafe delegate*<uint, uint> glGenVertexShadersEXT;
|
||||
internal unsafe delegate*<uint, void> glGenerateMipmap;
|
||||
@@ -2079,7 +2079,7 @@ namespace StgSharp.Graphics
|
||||
internal unsafe delegate*<int, uint, double*, void> glUniform1dv;
|
||||
internal unsafe delegate*<int, float, void> glUniform1f;
|
||||
internal unsafe delegate*<int, float, void> glUniform1fARB;
|
||||
internal unsafe delegate*<int, uint, Vec4d*, void> glUniform1fv;
|
||||
internal unsafe delegate*<int, uint, vec4d*, void> glUniform1fv;
|
||||
internal unsafe delegate*<int, uint, float*, void> glUniform1fvARB;
|
||||
internal unsafe delegate*<int, int, void> glUniform1i;
|
||||
internal unsafe delegate*<int, long, void> glUniform1i64ARB;
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static partial class GeometryScaler
|
||||
{
|
||||
internal const float DegToRad = 180 / Scaler.Pi;
|
||||
|
||||
public static Degree ToDegree(float value)
|
||||
{
|
||||
return new Degree(value);
|
||||
}
|
||||
|
||||
public static float Sin(Radius r)
|
||||
{
|
||||
return MathF.Sin(r._radius);
|
||||
}
|
||||
|
||||
public static float Tan(Radius r)
|
||||
{
|
||||
return MathF.Tan(r._radius);
|
||||
}
|
||||
public static float Cos(Radius r)
|
||||
{
|
||||
return MathF.Cos(r._radius);
|
||||
}
|
||||
|
||||
public static float Sin(Degree r)
|
||||
{
|
||||
return MathF.Sin(r._degree);
|
||||
}
|
||||
|
||||
public static float Tan(Degree r)
|
||||
{
|
||||
return MathF.Tan(r._degree);
|
||||
}
|
||||
|
||||
public static float Cos(Degree r)
|
||||
{
|
||||
return MathF.Cos(r._degree);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct Degree
|
||||
{
|
||||
internal float _degree;
|
||||
|
||||
internal Degree(float dgree)
|
||||
{
|
||||
_degree = dgree;
|
||||
}
|
||||
|
||||
public Radius ToRadius()
|
||||
{
|
||||
return new Radius(_degree / GeometryScaler.DegToRad);
|
||||
}
|
||||
}
|
||||
|
||||
public struct Radius
|
||||
{
|
||||
internal float _radius;
|
||||
|
||||
public static Radius Zero
|
||||
{
|
||||
get =>new Radius(0);
|
||||
}
|
||||
|
||||
public Radius(float radius)
|
||||
{
|
||||
_radius = radius;
|
||||
}
|
||||
|
||||
[Obsolete("Unsafe, you may forget this is radius.",true)]
|
||||
public Radius() { }
|
||||
|
||||
public Degree ToDegree()
|
||||
{
|
||||
return new Degree(_radius * 180 / Scaler.Pi);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Radius operator -(Radius r)
|
||||
{
|
||||
return new Radius(-r._radius);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Radius operator -(Radius left, Radius Right)
|
||||
{
|
||||
return new Radius(left._radius - Right._radius);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Radius operator +(Radius left, Radius Right)
|
||||
{
|
||||
return new Radius(left._radius + Right._radius);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Radius operator *(Radius left, float right)
|
||||
{
|
||||
return new Radius(left._radius * right);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Radius operator /(Radius left, float right)
|
||||
{
|
||||
return new Radius(left._radius / right);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(Radius left, Radius right)
|
||||
{
|
||||
return left._radius == right._radius;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(Radius left, Radius right)
|
||||
{
|
||||
return left._radius != right._radius;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace StgSharp.Geometries
|
||||
public struct PartialPlainCoordinate
|
||||
{
|
||||
|
||||
internal Matrix3x2 axis;
|
||||
internal Matrix32 axis;
|
||||
|
||||
/// <summary>
|
||||
/// The origin of this coordinate.
|
||||
@@ -59,7 +59,7 @@ namespace StgSharp.Geometries
|
||||
)
|
||||
{
|
||||
this.origin = origin;
|
||||
axis = new Matrix3x2();
|
||||
axis = new Matrix32();
|
||||
#if NET5_0_OR_GREATER
|
||||
Unsafe.SkipInit(out axis.mat);
|
||||
#endif
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace StgSharp.Geometries
|
||||
protected TimeSpanProvider time;
|
||||
|
||||
internal PartialPlainCoordinate coordinate;
|
||||
internal Matrix2x4 textureFrame;
|
||||
internal Matrix24 textureFrame;
|
||||
|
||||
public PlainGeometry()
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace StgSharp.Geometries
|
||||
internal readonly GetLocationHandler moveVertex2Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal readonly GetLocationHandler moveVertex3Operation = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
internal Matrix2x4 vertexMat;
|
||||
internal Matrix24 vertexMat;
|
||||
|
||||
internal Polygon4()
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Controlling;
|
||||
using StgSharp.Math;
|
||||
using StgSharp.Math.Linear;
|
||||
|
||||
|
||||
using System.Numerics;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Controlling;
|
||||
using StgSharp.Math;
|
||||
using StgSharp.Math.Linear;
|
||||
|
||||
|
||||
using System.Numerics;
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ namespace StgSharp.Geometries
|
||||
internal GetLocationHandler movVertex02Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
internal GetLocationHandler movVertex03Opearion = new GetLocationHandler(GeometryOperation.DefualtMotion);
|
||||
|
||||
internal Matrix3x3 vertexMat;
|
||||
internal Matrix33 vertexMat;
|
||||
|
||||
public Triangle()
|
||||
{
|
||||
vertexMat = new Matrix3x3();
|
||||
vertexMat = new Matrix33();
|
||||
}
|
||||
|
||||
public Triangle(
|
||||
|
||||
@@ -76,6 +76,8 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
Interlocked.Exchange(ref _frameSpeed, _frameCount);
|
||||
Interlocked.Exchange(ref _frameCount, 0);
|
||||
Console.Clear();
|
||||
Console.WriteLine(_frameSpeed);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ParamEnqueue(Vec4d v)
|
||||
public void ParamEnqueue(vec4d v)
|
||||
{
|
||||
paramQueue.Enqueue(v);
|
||||
}
|
||||
@@ -255,12 +255,12 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void TryDequeue(out Vec4d v)
|
||||
public unsafe void TryDequeue(out vec4d v)
|
||||
{
|
||||
M128 m;
|
||||
if (this.TryDequeue(out m))
|
||||
{
|
||||
v = *(Vec4d*)&m;
|
||||
v = *(vec4d*)&m;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -44,58 +44,146 @@ namespace StgSharp.Graphics
|
||||
/// <summary>
|
||||
/// A handle to an OpenGL object,
|
||||
/// must be indexed from a <see cref="glHandleSet"/>.
|
||||
/// Attempt at direct creating an instance will cause <see cref="InvalidOperationException"/>
|
||||
/// Direct call will cause <see langword="InvalidOperationException"/>
|
||||
/// </summary>
|
||||
public unsafe struct glHandle
|
||||
public unsafe class glHandle
|
||||
{
|
||||
private static uint* zeroHandle = (uint*)Marshal.AllocHGlobal(Marshal.SizeOf<uint>());
|
||||
|
||||
internal uint* source;
|
||||
internal uint* valuePtr;
|
||||
|
||||
internal glHandle(int index, GCHandle arrayHandle)
|
||||
private glHandle(IntPtr handle)
|
||||
{
|
||||
valuePtr = ((uint*)GCHandle.ToIntPtr(arrayHandle)) + index;
|
||||
this.valuePtr = (uint*)handle;
|
||||
source = (uint*)0;
|
||||
}
|
||||
|
||||
private glHandle(uint value)
|
||||
{
|
||||
source = (uint*)0;
|
||||
valuePtr = (uint*)Marshal.AllocHGlobal(sizeof(uint));
|
||||
*valuePtr = value;
|
||||
}
|
||||
|
||||
internal glHandle(uint* val, glHandleSet set)
|
||||
{
|
||||
source = set!=null ? set!.handle:(uint*)0;
|
||||
valuePtr = val;
|
||||
}
|
||||
|
||||
[Obsolete("Cannot init instance of this type", true)]
|
||||
public glHandle()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public IntPtr Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
return (IntPtr)valuePtr;
|
||||
}
|
||||
get=> (IntPtr)valuePtr;
|
||||
}
|
||||
|
||||
public bool IsIsolated
|
||||
{
|
||||
get => source == (uint*)0;
|
||||
}
|
||||
|
||||
public uint Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return *valuePtr;
|
||||
}
|
||||
set
|
||||
{
|
||||
*valuePtr = value;
|
||||
}
|
||||
get => *valuePtr;
|
||||
set => *valuePtr = value;
|
||||
}
|
||||
|
||||
public static glHandle Zero => Alloc(0);
|
||||
|
||||
internal uint DirectValue => *valuePtr;
|
||||
public static glHandle Alloc(uint value)
|
||||
{
|
||||
return new glHandle(value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static glHandle FromPtr(IntPtr p)
|
||||
{
|
||||
return new glHandle(p);
|
||||
}
|
||||
|
||||
~glHandle()
|
||||
{
|
||||
if (valuePtr != zeroHandle && IsIsolated)
|
||||
{
|
||||
Marshal.FreeHGlobal((IntPtr)valuePtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe struct glSHandle
|
||||
public unsafe class glSHandle
|
||||
{
|
||||
private static int* zeroHandle = (int*)Marshal.AllocHGlobal(Marshal.SizeOf<int>());
|
||||
|
||||
internal int* source;
|
||||
internal int* valuePtr;
|
||||
|
||||
internal glSHandle(int index, glHandleSet set)
|
||||
private glSHandle(IntPtr handle)
|
||||
{
|
||||
this.valuePtr = (int*)handle;
|
||||
source = (int*)0;
|
||||
}
|
||||
|
||||
private glSHandle(int value)
|
||||
{
|
||||
source = (int*)0;
|
||||
valuePtr = (int*)Marshal.AllocHGlobal(sizeof(int));
|
||||
*valuePtr = value;
|
||||
}
|
||||
|
||||
internal glSHandle(int* val, glHandleSet set)
|
||||
{
|
||||
source = set != null ? (int*)set!.handle : (int*)0;
|
||||
valuePtr = val;
|
||||
}
|
||||
|
||||
|
||||
[Obsolete("Cannot init instance of this type", true)]
|
||||
public glSHandle()
|
||||
{
|
||||
}
|
||||
|
||||
public IntPtr Handle
|
||||
{
|
||||
get => (IntPtr)valuePtr;
|
||||
}
|
||||
|
||||
public bool IsIsolated
|
||||
{
|
||||
get => source == (uint*)0;
|
||||
}
|
||||
|
||||
public int Value
|
||||
{
|
||||
get => *valuePtr;
|
||||
set => *valuePtr = value;
|
||||
}
|
||||
|
||||
public static glSHandle Zero => Alloc(0);
|
||||
|
||||
public static glSHandle Alloc(int value)
|
||||
{
|
||||
return new glSHandle(value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static glSHandle FromPtr(IntPtr p)
|
||||
{
|
||||
return new glSHandle(p);
|
||||
}
|
||||
|
||||
~glSHandle()
|
||||
{
|
||||
if (valuePtr != zeroHandle && IsIsolated)
|
||||
{
|
||||
Marshal.FreeHGlobal((IntPtr)valuePtr);
|
||||
}
|
||||
}
|
||||
|
||||
internal int DirectValue => *valuePtr;
|
||||
}
|
||||
|
||||
public unsafe class glArrayHandle
|
||||
@@ -151,20 +239,20 @@ namespace StgSharp.Graphics
|
||||
public unsafe class glHandleSet
|
||||
{
|
||||
|
||||
private uint[] _value;
|
||||
internal GCHandle handle;
|
||||
private readonly uint[] _value;
|
||||
internal uint* handle;
|
||||
internal int length;
|
||||
|
||||
public glHandleSet(int count)
|
||||
{
|
||||
_value = new uint[count];
|
||||
length = count;
|
||||
handle = GCHandle.Alloc(_value);
|
||||
handle = (uint*)GCHandle.Alloc(_value, GCHandleType.Pinned).AddrOfPinnedObject();
|
||||
}
|
||||
|
||||
public IntPtr Handle
|
||||
{
|
||||
get => GCHandle.ToIntPtr(handle);
|
||||
get => (IntPtr)handle;
|
||||
}
|
||||
|
||||
public glHandle this[int index]
|
||||
@@ -175,7 +263,7 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
return new glHandle(index, this.handle);
|
||||
return new glHandle(handle + index, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +275,7 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
return new glSHandle((int)index, this);
|
||||
return new glSHandle(((int*)handle) + index, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,6 +295,15 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
public void Pin()
|
||||
{
|
||||
if (_value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
handle = (uint*)GCHandle.Alloc(_value, GCHandleType.Pinned).AddrOfPinnedObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Release all resource in this handle.
|
||||
/// This will release all resource in this <see cref="glHandle"/>.
|
||||
@@ -214,24 +311,26 @@ namespace StgSharp.Graphics
|
||||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
if (handle == default)
|
||||
if (_value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
handle.Free();
|
||||
_value = null;
|
||||
GCHandle.FromIntPtr((IntPtr)handle).Free();
|
||||
handle = (uint*)IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetValue(int index, uint value)
|
||||
{
|
||||
_value[index] = value;
|
||||
}
|
||||
|
||||
~glHandleSet()
|
||||
{
|
||||
//unsafe, 不确定这个句柄组的单一索引是不是完全卸载
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,19 +53,19 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void AttachShader(glHandle program, glHandle shader)
|
||||
{
|
||||
api->glAttachShader(*program.valuePtr, shader.DirectValue);
|
||||
api->glAttachShader(program.Value, shader.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void BindBuffer(BufferType bufferType, glHandle handle)
|
||||
{
|
||||
api->glBindBuffer((uint)bufferType, handle.DirectValue);
|
||||
api->glBindBuffer((uint)bufferType, handle.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void BindTexture(uint type, glHandle texture)
|
||||
{
|
||||
api->glBindTexture(type, texture.DirectValue);
|
||||
api->glBindTexture(type, texture.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -95,7 +95,7 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void CompileShader(glHandle shaderhandle)
|
||||
{
|
||||
api->glCompileShader(shaderhandle.DirectValue);
|
||||
api->glCompileShader(shaderhandle.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -175,15 +175,15 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe public static void DeleteBuffers(glHandleSet handle)
|
||||
{
|
||||
api->glDeleteBuffers((uint)handle.length, handle.handle);
|
||||
handle.Free();
|
||||
api->glDeleteBuffers(handle.length, (uint*)handle.Handle);
|
||||
handle.Release();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe public static void DeleteVertexArrays(glHandleSet arrays)
|
||||
{
|
||||
api->glDeleteVertexArrays((uint)arrays.length, arrays.handle);
|
||||
arrays.Free();
|
||||
api->glDeleteVertexArrays(arrays.length, (uint*)arrays.Handle);
|
||||
arrays.Release();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -206,7 +206,7 @@ namespace StgSharp.Graphics
|
||||
|
||||
default:
|
||||
InternalIO.InternalWriteLog(
|
||||
$"{$"Parameter error in parameter {nameof(type)} method DrawElements. "}{$"Only {typeof(uint).Name},{typeof(ushort).Name},{typeof(byte).Name} types are suporrted."}",
|
||||
$"{$"Parameter error in parameter {nameof(type)} method DrawElements. "}{$"Only {typeof(uint).Name},{typeof(ushort).Name},{typeof(byte).Name} types are supported."}",
|
||||
LogType.Error);
|
||||
return;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ namespace StgSharp.Graphics
|
||||
public static unsafe glHandleSet GenBuffers(int count)
|
||||
{
|
||||
glHandleSet h = new glHandleSet(count);
|
||||
api->glGenBuffers((uint)count, h.handle);
|
||||
api->glGenBuffers(count, (uint*)h.Handle);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace StgSharp.Graphics
|
||||
public static unsafe glHandleSet GenVertexArrays(int count)
|
||||
{
|
||||
glHandleSet h = new glHandleSet(count);
|
||||
api->glGenVertexArrays((uint)count, h.handle);
|
||||
api->glGenVertexArrays(count, (uint*)h.Handle);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ namespace StgSharp.Graphics
|
||||
byte[] code = Encoding.UTF8.GetBytes(name);
|
||||
fixed (byte* ptr = code)
|
||||
{
|
||||
return glSHandle.Alloc(api->glGetUniformLocation(program.DirectValue, ptr));
|
||||
return glSHandle.Alloc(api->glGetUniformLocation(program.Value, ptr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,16 +253,16 @@ namespace StgSharp.Graphics
|
||||
byte[] stream = Encoding.UTF8.GetBytes(codeStream);
|
||||
fixed (byte* streamPtr = stream)
|
||||
{
|
||||
api->glShaderSource(shaderHandle.DirectValue, 1, &streamPtr, (void*)0);
|
||||
api->glShaderSource(shaderHandle.Value, 1, &streamPtr, (void*)0);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe static void MakeContexCurrent(Form form)
|
||||
public unsafe static void MakeContextCurrent(Form form)
|
||||
{
|
||||
if (form.WindowID == IntPtr.Zero)
|
||||
{
|
||||
InternalIO.InternalWriteLog($"From {nameof(form)} is not initted.", LogType.Warning);
|
||||
InternalIO.InternalWriteLog($"From {nameof(form)} is not inited.", LogType.Warning);
|
||||
return;
|
||||
}
|
||||
InternalIO.glfwMakeContextCurrent(form.id);
|
||||
@@ -323,7 +323,7 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void UseProgram(glHandle program)
|
||||
{
|
||||
api->glUseProgram(program.DirectValue);
|
||||
api->glUseProgram(program.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Graphics.ShaderEdit
|
||||
{
|
||||
public interface IglConvertable
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void SetAllUniforms();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void GainAllUniforms(ShaderProgram source, params string[] uniformName);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void DisplayGLtypeDefinition();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ShaderStruct GetConvertedGLtype();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,6 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
public partial class Form
|
||||
{
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected Shader CreateShader(ShaderType type, int count)
|
||||
{
|
||||
@@ -55,17 +54,16 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
return new ShaderProgram(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Shader
|
||||
{
|
||||
|
||||
private readonly IntPtr context;
|
||||
internal readonly GLhandle handle;
|
||||
internal readonly glHandleSet handle;
|
||||
public readonly ShaderType type;
|
||||
|
||||
internal unsafe Shader(uint[] handle, ShaderType usage)
|
||||
internal unsafe Shader(glHandleSet handle, ShaderType usage)
|
||||
{
|
||||
this.handle = handle;
|
||||
context = (IntPtr)GL.api;
|
||||
@@ -108,7 +106,7 @@ namespace StgSharp.Graphics
|
||||
internal readonly glHandle handle;
|
||||
|
||||
/// <summary>
|
||||
/// Inti a shader with no program attached.
|
||||
/// Init a program with no shader attached.
|
||||
/// </summary>
|
||||
internal unsafe ShaderProgram(Form binding)
|
||||
{
|
||||
@@ -201,5 +199,10 @@ namespace StgSharp.Graphics
|
||||
GL.UseProgram(handle);
|
||||
}
|
||||
|
||||
~ShaderProgram()
|
||||
{
|
||||
//handle.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -144,7 +144,7 @@ namespace StgSharp.Graphics.ShaderEdit
|
||||
}
|
||||
switch (typeof(T).Name)
|
||||
{
|
||||
case "Vec4d":
|
||||
case "vec4d":
|
||||
return InternalShaderType.Vector4;
|
||||
case "Matrix2x2":
|
||||
return InternalShaderType.Matrix2x2;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Graphics.ShaderEdit
|
||||
{
|
||||
public class ShaderStructMember
|
||||
{
|
||||
internal InternalShaderType type;
|
||||
internal object value;
|
||||
}
|
||||
|
||||
public class ShaderStruct
|
||||
{
|
||||
internal Dictionary<glSHandle, ShaderStructMember> uniformPair;
|
||||
|
||||
public ShaderStruct(params (glSHandle, ShaderStructMember)[] UniformPais)
|
||||
{
|
||||
uniformPair = new Dictionary<glSHandle, ShaderStructMember>();
|
||||
if (UniformPais.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var item in UniformPais)
|
||||
{
|
||||
uniformPair.Add(item.Item1,item.Item2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal ShaderStruct() { }
|
||||
|
||||
|
||||
public unsafe void SetAllUniforms()
|
||||
{
|
||||
GLcontext* gl = GL.api;
|
||||
foreach (var uniform in uniformPair)
|
||||
{
|
||||
int id = uniform.Key.Value;
|
||||
ShaderStructMember s = uniform.Value;
|
||||
switch (s.type)
|
||||
{
|
||||
case InternalShaderType.Struct: throw new ArgumentException(
|
||||
"Incorrect type \"Struct\" defined in this self define type");
|
||||
case InternalShaderType.Void:throw new ArgumentException(
|
||||
"Incorrect type \"Void\" defined in this self define type");
|
||||
case InternalShaderType.Float:
|
||||
gl->glUniform1f(id, (float)s.value);
|
||||
break;
|
||||
case InternalShaderType.Int:
|
||||
gl->glUniform1f(id, (int)s.value);
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
throw new ArgumentException(
|
||||
"Incorrect type \"Unknown\" defined in this self define type");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Graphic;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
@@ -39,12 +40,22 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public class Uniform<T> where T : struct
|
||||
public class Uniform
|
||||
{
|
||||
|
||||
private IntPtr binding;
|
||||
protected IntPtr binding;
|
||||
internal glSHandle id;
|
||||
|
||||
|
||||
public glSHandle Handle
|
||||
{
|
||||
get => id;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Uniform<T> : Uniform
|
||||
where T : struct
|
||||
{
|
||||
|
||||
internal unsafe Uniform(glSHandle id)
|
||||
{
|
||||
this.id = id;
|
||||
@@ -56,6 +67,7 @@ namespace StgSharp.Graphics
|
||||
this.binding = binding.graphicContextID;
|
||||
id = GL.GetUniformLocation(program.handle, name);
|
||||
}
|
||||
|
||||
internal unsafe Uniform(
|
||||
ShaderProgram program, string name, IntPtr binding)
|
||||
{
|
||||
@@ -63,16 +75,23 @@ namespace StgSharp.Graphics
|
||||
id = GL.GetUniformLocation(program.handle, name);
|
||||
}
|
||||
|
||||
internal Uniform()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal static Uniform<T> FromHandle(glSHandle handle)
|
||||
{
|
||||
return new Uniform<T>() { id = handle };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Uniform<T, U>
|
||||
public sealed class Uniform<T, U>: Uniform
|
||||
where T : struct
|
||||
where U : struct
|
||||
{
|
||||
|
||||
private IntPtr binding;
|
||||
internal glSHandle id;
|
||||
|
||||
internal unsafe Uniform(glSHandle id)
|
||||
{
|
||||
this.id = id;
|
||||
@@ -92,17 +111,24 @@ namespace StgSharp.Graphics
|
||||
id = GL.GetUniformLocation(program.handle, name);
|
||||
}
|
||||
|
||||
internal Uniform()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal static Uniform<T,U> FromHandle(glSHandle handle)
|
||||
{
|
||||
return new Uniform<T, U>() { id = handle };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Uniform<T, U, V>
|
||||
public sealed class Uniform<T, U, V>:Uniform
|
||||
where T : struct
|
||||
where U : struct
|
||||
where V : struct
|
||||
{
|
||||
|
||||
private IntPtr binding;
|
||||
internal glSHandle id;
|
||||
|
||||
internal unsafe Uniform(glSHandle id)
|
||||
{
|
||||
this.id = id;
|
||||
@@ -121,17 +147,25 @@ namespace StgSharp.Graphics
|
||||
id = GL.GetUniformLocation(program.handle, name);
|
||||
}
|
||||
|
||||
internal Uniform()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal static Uniform<T,U,V> FromHandle(glSHandle handle)
|
||||
{
|
||||
return new Uniform<T, U, V>() { id = handle };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Uniform<T, U, V, W>
|
||||
public sealed class Uniform<T, U, V, W>:Uniform
|
||||
where T : struct
|
||||
where U : struct
|
||||
where V : struct
|
||||
where W : struct
|
||||
{
|
||||
|
||||
private IntPtr binding;
|
||||
internal glSHandle id;
|
||||
|
||||
internal unsafe Uniform(glSHandle id)
|
||||
{
|
||||
@@ -151,51 +185,69 @@ namespace StgSharp.Graphics
|
||||
id = GL.GetUniformLocation(program.handle, name);
|
||||
}
|
||||
|
||||
internal Uniform()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal static Uniform<T, U, V, W> FromHandle(glSHandle handle)
|
||||
{
|
||||
return new Uniform<T, U, V, W>() { id = handle };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal static partial class GL
|
||||
{
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe static void SetValue(Uniform<float, float, float, float> uniform, Vec4d vec)
|
||||
public unsafe static void SetValue(Uniform<Matrix44> uniform, Matrix44 mat)
|
||||
{
|
||||
api->glUniform1fv(uniform.id.DirectValue , 4, &vec);
|
||||
Matrix44 temp = mat;
|
||||
api->glUniformMatrix4fv(uniform.Handle.Value, 16, false, (float*)&mat);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe static void SetValue(Uniform<Vec4d> uniform, Vec4d vec)
|
||||
public unsafe static void SetValue(Uniform<float, float, float, float> uniform, vec4d vec)
|
||||
{
|
||||
api->glUniform1fv(uniform.id.DirectValue , 4, &vec);
|
||||
vec4d temp = vec;
|
||||
api->glUniform1fv(uniform.id.Value , 4, &temp);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe static void SetValue(Uniform<vec4d> uniform, vec4d vec)
|
||||
{
|
||||
vec4d temp = vec;
|
||||
api->glUniform1fv(uniform.id.Value , 4, &temp);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe void SetValue(Uniform<float> uniform, float v0)
|
||||
{
|
||||
api->glUniform1f(uniform.id.DirectValue , v0);
|
||||
api->glUniform1f(uniform.id.Value , v0);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe void SetValue(Uniform<int> uniform, int i0)
|
||||
{
|
||||
api->glUniform1i(uniform.id.DirectValue , i0);
|
||||
api->glUniform1i(uniform.id.Value , i0);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe void SetValue(Uniform<float, float> uniform, float v0, float v1)
|
||||
{
|
||||
api->glUniform2f(uniform.id.DirectValue , v0, v1);
|
||||
api->glUniform2f(uniform.id.Value , v0, v1);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe void SetValue(Uniform<float, float, float> uniform, float v0, float v1, float v2)
|
||||
{
|
||||
api->glUniform3f(uniform.id.DirectValue , v0, v1, v2);
|
||||
api->glUniform3f(uniform.id.Value , v0, v1, v2);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe void SetValue(Uniform<float, float, float, float> uniform, float v0, float v1, float v2, float v3)
|
||||
{
|
||||
api->glUniform4f(uniform.id.DirectValue , v0, v1, v2, v3);
|
||||
api->glUniform4f(uniform.id.Value , v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1081,7 +1081,7 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glDeleteTextures = (delegate*<uint, uint*, void>)load("glDeleteTextures");
|
||||
contextPtr->glDrawArrays = (delegate*<uint, int, uint, void>)load("glDrawArrays");
|
||||
contextPtr->glDrawElements = (delegate*<uint, uint, uint, void*, void>)load("glDrawElements");
|
||||
contextPtr->glGenTextures = (delegate*<uint, uint*, void>)load("glGenTextures");
|
||||
contextPtr->glGenTextures = (delegate*<int, uint*, void>)load("glGenTextures");
|
||||
contextPtr->glGetPointerv = (delegate*<uint, void**, void>)load("glGetPointerv");
|
||||
contextPtr->glIsTexture = (delegate*<uint, bool>)load("glIsTexture");
|
||||
contextPtr->glPolygonOffset = (delegate*<float, float, void>)load("glPolygonOffset");
|
||||
@@ -1177,10 +1177,10 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glBindBuffer = (delegate*<uint, uint, void>)load("glBindBuffer");
|
||||
contextPtr->glBufferData = (delegate*<uint, IntPtr, IntPtr, uint, void>)load("glBufferData");
|
||||
contextPtr->glBufferSubData = (delegate*<uint, IntPtr, UIntPtr, void*, void>)load("glBufferSubData");
|
||||
contextPtr->glDeleteBuffers = (delegate*<uint, uint*, void>)load("glDeleteBuffers");
|
||||
contextPtr->glDeleteBuffers = (delegate*<int, uint*, void>)load("glDeleteBuffers");
|
||||
contextPtr->glDeleteQueries = (delegate*<uint, uint*, void>)load("glDeleteQueries");
|
||||
contextPtr->glEndQuery = (delegate*<uint, void>)load("glEndQuery");
|
||||
contextPtr->glGenBuffers = (delegate*<uint, uint*, void>)load("glGenBuffers");
|
||||
contextPtr->glGenBuffers = (delegate*<int, uint*, void>)load("glGenBuffers");
|
||||
contextPtr->glGenQueries = (delegate*<uint, uint*, void>)load("glGenQueries");
|
||||
contextPtr->glGetBufferParameteriv = (delegate*<uint, uint, int*, void>)load("glGetBufferParameteriv");
|
||||
contextPtr->glGetBufferPointerv = (delegate*<uint, uint, void**, void>)load("glGetBufferPointerv");
|
||||
@@ -1244,7 +1244,7 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glStencilMaskSeparate = (delegate*<uint, uint, void>)load("glStencilMaskSeparate");
|
||||
contextPtr->glStencilOpSeparate = (delegate*<uint, uint, uint, uint, void>)load("glStencilOpSeparate");
|
||||
contextPtr->glUniform1f = (delegate*<int, float, void>)load("glUniform1f");
|
||||
contextPtr->glUniform1fv = (delegate*<int, uint, Vec4d*, void>)load("glUniform1fv");
|
||||
contextPtr->glUniform1fv = (delegate*<int, uint, vec4d*, void>)load("glUniform1fv");
|
||||
contextPtr->glUniform1i = (delegate*<int, int, void>)load("glUniform1i");
|
||||
contextPtr->glUniform1iv = (delegate*<int, uint, int*, void>)load("glUniform1iv");
|
||||
contextPtr->glUniform2f = (delegate*<int, float, float, void>)load("glUniform2f");
|
||||
@@ -1357,7 +1357,7 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glColorMaski = (delegate*<uint, bool, bool, bool, bool, void>)load("glColorMaski");
|
||||
contextPtr->glDeleteFramebuffers = (delegate*<uint, uint*, void>)load("glDeleteFramebuffers");
|
||||
contextPtr->glDeleteRenderbuffers = (delegate*<uint, uint*, void>)load("glDeleteRenderbuffers");
|
||||
contextPtr->glDeleteVertexArrays = (delegate*<uint, uint*, void>)load("glDeleteVertexArrays");
|
||||
contextPtr->glDeleteVertexArrays = (delegate*<int, uint*, void>)load("glDeleteVertexArrays");
|
||||
contextPtr->glDisablei = (delegate*<uint, uint, void>)load("glDisablei");
|
||||
contextPtr->glEnablei = (delegate*<uint, uint, void>)load("glEnablei");
|
||||
contextPtr->glEndConditionalRender = (delegate*<void>)load("glEndConditionalRender");
|
||||
@@ -1370,7 +1370,7 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glFramebufferTextureLayer = (delegate*<uint, uint, uint, int, int, void>)load("glFramebufferTextureLayer");
|
||||
contextPtr->glGenFramebuffers = (delegate*<uint, uint*, void>)load("glGenFramebuffers");
|
||||
contextPtr->glGenRenderbuffers = (delegate*<uint, uint*, void>)load("glGenRenderbuffers");
|
||||
contextPtr->glGenVertexArrays = (delegate*<uint, uint*, void>)load("glGenVertexArrays");
|
||||
contextPtr->glGenVertexArrays = (delegate*<int, uint*, void>)load("glGenVertexArrays");
|
||||
contextPtr->glGenerateMipmap = (delegate*<uint, void>)load("glGenerateMipmap");
|
||||
contextPtr->glGetBooleani_v = (delegate*<uint, uint, bool*, void>)load("glGetBooleani_v");
|
||||
contextPtr->glGetFragDataLocation = (delegate*<uint, byte*, int>)load("glGetFragDataLocation");
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
info = information;
|
||||
int length = info.width * info.height * info.channel;
|
||||
pixelArrayHandle = glHandle.Alloc(information.pixelPtr);
|
||||
pixelArrayHandle = glHandle.FromPtr(information.pixelPtr);
|
||||
}
|
||||
|
||||
public unsafe Image()
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace StgSharp.Logic
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Enqueue(Vec4d v)
|
||||
public void Enqueue(vec4d v)
|
||||
{
|
||||
paramQueue.Enqueue(v);
|
||||
}
|
||||
@@ -231,12 +231,12 @@ namespace StgSharp.Logic
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TryDequeue(out Vec4d v)
|
||||
public void TryDequeue(out vec4d v)
|
||||
{
|
||||
M128 m;
|
||||
if (this.TryDequeue(out m))
|
||||
{
|
||||
v = *(Vec4d*)&m;
|
||||
v = *(vec4d*)&m;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -278,12 +278,6 @@
|
||||
A handle to an OpenGL object.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.glHandleSet.Free">
|
||||
<summary>
|
||||
temporarily release the handle of GLhandle sets.
|
||||
Please call <see cref="M:StgSharp.Graphics.glHandleSet.Pin"/> method before indexing.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.glHandleSet.Release">
|
||||
<summary>
|
||||
Release all resource in this handle.
|
||||
@@ -291,6 +285,27 @@
|
||||
This <see langword="glHandle"/> will be not usable.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderEdit.IglConvertable.SetAllUniforms">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderEdit.IglConvertable.GainAllUniforms(StgSharp.Graphics.ShaderProgram,System.String[])">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderEdit.IglConvertable.DisplayGLtypeDefinition">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderEdit.IglConvertable.GetConvertedGLtype">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.Shader.AttachTo(System.Int32,StgSharp.Graphics.ShaderProgram)">
|
||||
<summary>
|
||||
Attach one shader code to a shader program.
|
||||
@@ -300,7 +315,7 @@
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderProgram.#ctor(StgSharp.Graphics.Form)">
|
||||
<summary>
|
||||
Inti a shader with no program attached.
|
||||
Init a program with no shader attached.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderProgram.GetUniform``1(System.String)">
|
||||
@@ -385,6 +400,74 @@
|
||||
<param name="message">A string contains information of how current evironment runs.</param>
|
||||
<param name="logType">The severity of current message.</param>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.GLclampf">
|
||||
<summary>
|
||||
OpenGL numeric type.
|
||||
An IEEE-754 floating-point value, clamped to the range [0,1].
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.GLclampd">
|
||||
<summary>
|
||||
OpenGL numeric type.
|
||||
An IEEE-754 double precision floating-point value, clamped to the range [0,1].
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.Vec2d">
|
||||
<summary>
|
||||
A two dimension vector defined by two elements.
|
||||
Vec2Ds in StgSharp are defaultly usaed as colum vector.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.ASin(System.Single)">
|
||||
<summary>
|
||||
Reurns the value of ArcSin(x)
|
||||
</summary>
|
||||
<param name="x">The sine value of the angle</param>
|
||||
<returns></returns>
|
||||
<exception cref="T:System.ArgumentException"></exception>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Exp(System.Single)">
|
||||
<summary>
|
||||
Get the value of E ^ x;
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Log(System.Single)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns>
|
||||
Returns the value of ln(x).
|
||||
</returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Pow(System.Single,System.Single)">
|
||||
<summary>
|
||||
calculate the value of x^y
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<param name="y"></param>
|
||||
<returns>Returns the value of x^y</returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.LowProceisionRandom">
|
||||
<summary>
|
||||
returns a random float number between 0 and 1.
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Random">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.RandomSeed">
|
||||
<summary>
|
||||
Generates a random seed in int value.
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:StgSharp.Geometries.Arc">
|
||||
<summary>
|
||||
Part of a circle. All points on a arc has the same distance to their center.
|
||||
@@ -585,74 +668,17 @@
|
||||
The method this <see cref="T:StgSharp.TimeSpanProvider"/> will call every time a new time span started.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.GLclampf">
|
||||
<member name="M:StgSharp.Graphic.Camera.GainAllUniforms(StgSharp.Graphics.ShaderProgram,System.String[])">
|
||||
<summary>
|
||||
OpenGL numeric type.
|
||||
An IEEE-754 floating-point value, clamped to the range [0,1].
|
||||
Get all uniform related to this <see cref="T:StgSharp.Graphic.Camera"/>.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.GLclampd">
|
||||
<summary>
|
||||
OpenGL numeric type.
|
||||
An IEEE-754 double precision floating-point value, clamped to the range [0,1].
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.Vec2d">
|
||||
<summary>
|
||||
A two dimension vector defined by two elements.
|
||||
Vec2Ds in StgSharp are defaultly usaed as colum vector.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.ASin(System.Single)">
|
||||
<summary>
|
||||
Reurns the value of ArcSin(x)
|
||||
</summary>
|
||||
<param name="x">The sine value of the angle</param>
|
||||
<returns></returns>
|
||||
<param name="source">Shader program requires this camera.</param>
|
||||
<param name="uniformName">
|
||||
Name of all related uniforms.
|
||||
If you fallow form from <see cref="M:StgSharp.Graphics.ShaderEdit.IglConvertable.DisplayGLtypeDefinition"/>
|
||||
</param>
|
||||
<exception cref="T:System.ArgumentException"></exception>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Exp(System.Single)">
|
||||
<summary>
|
||||
Get the value of E ^ x;
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Log(System.Single)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns>
|
||||
Returns the value of ln(x).
|
||||
</returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Pow(System.Single,System.Single)">
|
||||
<summary>
|
||||
calculate the value of x^y
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<param name="y"></param>
|
||||
<returns>Returns the value of x^y</returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.LowProceisionRandom">
|
||||
<summary>
|
||||
returns a random float number between 0 and 1.
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Random">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.RandomSeed">
|
||||
<summary>
|
||||
Generates a random seed in int value.
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Windows.Win32.Foundation.COLORREF">
|
||||
<summary>The COLORREF value is used to specify an RGB color.</summary>
|
||||
<remarks>
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b207f16616b7bd967d647a809cc27e7174063451")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+127fcdbfd32fd1caa4a55ced77c7e738f038a59c")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
a0b25d34befb618bddac619894a529483765dd39f7d959957c7d20a1f2155e03
|
||||
5bdfaeb828f7a682fca2531a3fe7bdbf99d72f6a17b3554b2957f0377659471f
|
||||
|
||||
@@ -1 +1 @@
|
||||
94c4d184424dd46368a7fbc005f339c0cfff874369d50f1c86133ae4d9ae2bb1
|
||||
22685e6e651dc0dffa71da397e1fde84f3b8a45e5faf79b0982e58cbaad38609
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/b207f16616b7bd967d647a809cc27e7174063451/*"}}
|
||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/127fcdbfd32fd1caa4a55ced77c7e738f038a59c/*"}}
|
||||
@@ -278,12 +278,6 @@
|
||||
A handle to an OpenGL object.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.glHandleSet.Free">
|
||||
<summary>
|
||||
temporarily release the handle of GLhandle sets.
|
||||
Please call <see cref="M:StgSharp.Graphics.glHandleSet.Pin"/> method before indexing.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.glHandleSet.Release">
|
||||
<summary>
|
||||
Release all resource in this handle.
|
||||
@@ -291,6 +285,27 @@
|
||||
This <see langword="glHandle"/> will be not usable.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderEdit.IglConvertable.SetAllUniforms">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderEdit.IglConvertable.GainAllUniforms(StgSharp.Graphics.ShaderProgram,System.String[])">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderEdit.IglConvertable.DisplayGLtypeDefinition">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderEdit.IglConvertable.GetConvertedGLtype">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.Shader.AttachTo(System.Int32,StgSharp.Graphics.ShaderProgram)">
|
||||
<summary>
|
||||
Attach one shader code to a shader program.
|
||||
@@ -300,7 +315,7 @@
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderProgram.#ctor(StgSharp.Graphics.Form)">
|
||||
<summary>
|
||||
Inti a shader with no program attached.
|
||||
Init a program with no shader attached.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Graphics.ShaderProgram.GetUniform``1(System.String)">
|
||||
@@ -385,6 +400,74 @@
|
||||
<param name="message">A string contains information of how current evironment runs.</param>
|
||||
<param name="logType">The severity of current message.</param>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.GLclampf">
|
||||
<summary>
|
||||
OpenGL numeric type.
|
||||
An IEEE-754 floating-point value, clamped to the range [0,1].
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.GLclampd">
|
||||
<summary>
|
||||
OpenGL numeric type.
|
||||
An IEEE-754 double precision floating-point value, clamped to the range [0,1].
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.Vec2d">
|
||||
<summary>
|
||||
A two dimension vector defined by two elements.
|
||||
Vec2Ds in StgSharp are defaultly usaed as colum vector.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.ASin(System.Single)">
|
||||
<summary>
|
||||
Reurns the value of ArcSin(x)
|
||||
</summary>
|
||||
<param name="x">The sine value of the angle</param>
|
||||
<returns></returns>
|
||||
<exception cref="T:System.ArgumentException"></exception>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Exp(System.Single)">
|
||||
<summary>
|
||||
Get the value of E ^ x;
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Log(System.Single)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns>
|
||||
Returns the value of ln(x).
|
||||
</returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Pow(System.Single,System.Single)">
|
||||
<summary>
|
||||
calculate the value of x^y
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<param name="y"></param>
|
||||
<returns>Returns the value of x^y</returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.LowProceisionRandom">
|
||||
<summary>
|
||||
returns a random float number between 0 and 1.
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Random">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.RandomSeed">
|
||||
<summary>
|
||||
Generates a random seed in int value.
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:StgSharp.Geometries.Arc">
|
||||
<summary>
|
||||
Part of a circle. All points on a arc has the same distance to their center.
|
||||
@@ -585,74 +668,17 @@
|
||||
The method this <see cref="T:StgSharp.TimeSpanProvider"/> will call every time a new time span started.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.GLclampf">
|
||||
<member name="M:StgSharp.Graphic.Camera.GainAllUniforms(StgSharp.Graphics.ShaderProgram,System.String[])">
|
||||
<summary>
|
||||
OpenGL numeric type.
|
||||
An IEEE-754 floating-point value, clamped to the range [0,1].
|
||||
Get all uniform related to this <see cref="T:StgSharp.Graphic.Camera"/>.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.GLclampd">
|
||||
<summary>
|
||||
OpenGL numeric type.
|
||||
An IEEE-754 double precision floating-point value, clamped to the range [0,1].
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:StgSharp.Math.Vec2d">
|
||||
<summary>
|
||||
A two dimension vector defined by two elements.
|
||||
Vec2Ds in StgSharp are defaultly usaed as colum vector.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.ASin(System.Single)">
|
||||
<summary>
|
||||
Reurns the value of ArcSin(x)
|
||||
</summary>
|
||||
<param name="x">The sine value of the angle</param>
|
||||
<returns></returns>
|
||||
<param name="source">Shader program requires this camera.</param>
|
||||
<param name="uniformName">
|
||||
Name of all related uniforms.
|
||||
If you fallow form from <see cref="M:StgSharp.Graphics.ShaderEdit.IglConvertable.DisplayGLtypeDefinition"/>
|
||||
</param>
|
||||
<exception cref="T:System.ArgumentException"></exception>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Exp(System.Single)">
|
||||
<summary>
|
||||
Get the value of E ^ x;
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Log(System.Single)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<returns>
|
||||
Returns the value of ln(x).
|
||||
</returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Pow(System.Single,System.Single)">
|
||||
<summary>
|
||||
calculate the value of x^y
|
||||
</summary>
|
||||
<param name="x"></param>
|
||||
<param name="y"></param>
|
||||
<returns>Returns the value of x^y</returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.LowProceisionRandom">
|
||||
<summary>
|
||||
returns a random float number between 0 and 1.
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.Random">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:StgSharp.Math.Scaler.RandomSeed">
|
||||
<summary>
|
||||
Generates a random seed in int value.
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Windows.Win32.Foundation.COLORREF">
|
||||
<summary>The COLORREF value is used to specify an RGB color.</summary>
|
||||
<remarks>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -69,6 +69,13 @@ extern "C"
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Vector
|
||||
|
||||
SSCAPI void SSCDECL normalize(__m128* source, __m128* target);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region mat2
|
||||
|
||||
SSCAPI _inline void __cdecl transpose2to3(matrix2map* source, matrix3map* target);
|
||||
|
||||
@@ -159,6 +159,7 @@
|
||||
<ClCompile Include="mat4.c" />
|
||||
<ClCompile Include="stb_image.c" />
|
||||
<ClCompile Include="StgSharpC.c" />
|
||||
<ClCompile Include="vector.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="gl.h" />
|
||||
|
||||
@@ -44,6 +44,9 @@
|
||||
<ClCompile Include="StgSharpC.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="vector.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="glfw3.h">
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// header.h: 标准系统包含文件的包含文件,
|
||||
// 或特定于项目的包含文件
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
|
||||
// Windows 头文件
|
||||
#include <windows.h>
|
||||
#if _WIN32
|
||||
|
||||
|
||||
|
||||
#endif // __WIN32
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
#define SSG_INTERNAL
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
|
||||
// Windows 头文件
|
||||
#include <windows.h>
|
||||
|
||||
#define SSCAPI __declspec(dllexport)
|
||||
#elif defined _LINUX_
|
||||
#define SSCAPI __attribute__ ((dllexport))
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "StgSharpC.h"
|
||||
#include "ssgc_internal.h"
|
||||
|
||||
SSCAPI void SSCDECL normalize(__m128* source, __m128* target)
|
||||
{
|
||||
// 计算source的长度的平方
|
||||
__m128 a_length_sq = _mm_mul_ps(*source, *source); // 向量点乘自身
|
||||
a_length_sq = _mm_add_ps(a_length_sq, _mm_shuffle_ps(a_length_sq, a_length_sq, _MM_SHUFFLE(2, 3, 0, 1)));
|
||||
a_length_sq = _mm_add_ss(a_length_sq, _mm_shuffle_ps(a_length_sq, a_length_sq, _MM_SHUFFLE(0, 0, 3, 2)));
|
||||
|
||||
// 归一化向量source
|
||||
__m128 a_inv_length = _mm_rsqrt_ps(a_length_sq); // 计算source长度的倒数平方根
|
||||
*source = _mm_mul_ps(*source, a_inv_length); // 用source乘以其长度的倒数平方根得到单位向量
|
||||
|
||||
// 计算target与source的点积
|
||||
__m128 dot_product = _mm_mul_ps(*target, *source);
|
||||
dot_product = _mm_add_ps(dot_product, _mm_shuffle_ps(dot_product, dot_product, _MM_SHUFFLE(2, 3, 0, 1)));
|
||||
dot_product = _mm_add_ss(dot_product, _mm_shuffle_ps(dot_product, dot_product, _MM_SHUFFLE(0, 0, 3, 2)));
|
||||
|
||||
// 从target中减去source的方向分量,使其垂直于source
|
||||
__m128 b_orthogonal = _mm_sub_ps(*target, _mm_mul_ps(*source, dot_product));
|
||||
|
||||
// 归一化向量b_orthogonal
|
||||
__m128 b_length_sq = _mm_mul_ps(b_orthogonal, b_orthogonal);
|
||||
b_length_sq = _mm_add_ps(b_length_sq, _mm_shuffle_ps(b_length_sq, b_length_sq, _MM_SHUFFLE(2, 3, 0, 1)));
|
||||
b_length_sq = _mm_add_ss(b_length_sq, _mm_shuffle_ps(b_length_sq, b_length_sq, _MM_SHUFFLE(0, 0, 3, 2)));
|
||||
|
||||
__m128 b_inv_length = _mm_rsqrt_ps(b_length_sq);
|
||||
*target = _mm_mul_ps(b_orthogonal, b_inv_length);
|
||||
|
||||
}
|
||||
@@ -19,6 +19,9 @@ d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharp
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpc\x64\debug\mat2.cod
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpc\x64\debug\dllmain.obj
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpc\x64\debug\dllmain.cod
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpc\x64\debug\vector.sbr
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpc\x64\debug\vector.obj
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpc\x64\debug\vector.cod
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpc.dll
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpc.pdb
|
||||
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\源代码\stgsharpc.lib
|
||||
|
||||
@@ -13,13 +13,23 @@ _DATA SEGMENT
|
||||
COMM currentContext:QWORD
|
||||
_DATA ENDS
|
||||
msvcjmc SEGMENT
|
||||
__A19B9DB6_ssgc_framework@h DB 01H
|
||||
__0ED14FEE_winpackagefamily@h DB 01H
|
||||
__F92EF742_winapifamily@h DB 01H
|
||||
__22E515EB_sdkddkver@h DB 01H
|
||||
__4B783B3C_concurrencysal@h DB 01H
|
||||
__137BB1BE_sal@h DB 01H
|
||||
__805F4069_vadefs@h DB 01H
|
||||
__1EAACA9B_vcruntime@h DB 01H
|
||||
__F8522E0F_stdint@h DB 01H
|
||||
__874AB8BA_khrplatform@h DB 01H
|
||||
__8DCB230D_gl@h DB 01H
|
||||
__1B0272D9_corecrt@h DB 01H
|
||||
__13F5961F_stddef@h DB 01H
|
||||
__5BC5AF51_mmintrin@h DB 01H
|
||||
__45DED006_corecrt_malloc@h DB 01H
|
||||
__FA77ED4C_malloc@h DB 01H
|
||||
__9E7FA6CF_xmmintrin@h DB 01H
|
||||
__22E515EB_sdkddkver@h DB 01H
|
||||
__1227BCE2_excpt@h DB 01H
|
||||
__CC8D90C0_stdarg@h DB 01H
|
||||
__29F49F40_specstrings_undef@h DB 01H
|
||||
@@ -27,7 +37,6 @@ __D0F42932_specstrings_strict@h DB 01H
|
||||
__F00405FD_sdv_driverspecs@h DB 01H
|
||||
__173E09CA_driverspecs@h DB 01H
|
||||
__9A452361_specstrings@h DB 01H
|
||||
__1B0272D9_corecrt@h DB 01H
|
||||
__74484FB3_corecrt_wctype@h DB 01H
|
||||
__1EC467ED_ctype@h DB 01H
|
||||
__98517906_kernelspecs@h DB 01H
|
||||
@@ -108,15 +117,6 @@ __11C07376_mcx@h DB 01H
|
||||
__577CE3E7_ime_cmodes@h DB 01H
|
||||
__1E72C31E_imm@h DB 01H
|
||||
__E15BF856_windows@h DB 01H
|
||||
__A19B9DB6_ssgc_framework@h DB 01H
|
||||
__F8522E0F_stdint@h DB 01H
|
||||
__874AB8BA_khrplatform@h DB 01H
|
||||
__8DCB230D_gl@h DB 01H
|
||||
__13F5961F_stddef@h DB 01H
|
||||
__5BC5AF51_mmintrin@h DB 01H
|
||||
__45DED006_corecrt_malloc@h DB 01H
|
||||
__FA77ED4C_malloc@h DB 01H
|
||||
__9E7FA6CF_xmmintrin@h DB 01H
|
||||
__61B03275_ssgc_internal@h DB 01H
|
||||
__B47D1049_glfw3@h DB 01H
|
||||
__5F89FF5A_wgl@h DB 01H
|
||||
|
||||
Binary file not shown.
@@ -1,7 +1,4 @@
|
||||
StgSharpC.c
|
||||
dllmain.c
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC\StgSharpC.c(23,18): warning C4047: “=”:“char”与“char [27]”的间接级别不同
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC\StgSharpC.c(67,5): warning C4047: “return”:“char *”与“char (*)[512]”的间接级别不同
|
||||
dllmain.c
|
||||
mat2.c
|
||||
mat3.c
|
||||
mat4.c
|
||||
@@ -30,6 +27,22 @@ D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharp
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC\mat4.c(44,18): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC\mat4.c(45,18): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC\mat4.c(53,32): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容
|
||||
stb_image.c
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC\stb_image.c(832,17): warning C4047: “=”:“stbi_uc”与“char [33]”的间接级别不同
|
||||
StgSharpC.c
|
||||
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(130,1): warning C4005: “APIENTRY”: 宏重定义
|
||||
(编译源文件“StgSharpC.c”)
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC\glfw3.h(123,1):
|
||||
参见“APIENTRY”的前一个定义
|
||||
|
||||
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\wingdi.h(36,1): warning C4005: “WINGDIAPI”: 宏重定义
|
||||
(编译源文件“StgSharpC.c”)
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC\glfw3.h(133,1):
|
||||
参见“WINGDIAPI”的前一个定义
|
||||
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC\StgSharpC.c(23,18): warning C4047: “=”:“char”与“char [27]”的间接级别不同
|
||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC\StgSharpC.c(67,5): warning C4047: “return”:“char *”与“char (*)[512]”的间接级别不同
|
||||
vector.c
|
||||
正在生成代码...
|
||||
正在创建库 D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC.lib 和对象 D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC.exp
|
||||
LINK : warning LNK4098: 默认库“MSVCRT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user