daily update on 20240506 by nitload youmu
This commit is contained in:
+206
-156
@@ -35,6 +35,7 @@ using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
@@ -43,29 +44,43 @@ namespace StgSharp.Graphics
|
||||
public sealed class Camera : IglConvertable
|
||||
{
|
||||
|
||||
internal Uniform<Matrix44> convertedUniform;
|
||||
internal bool _isLookAtAvailable;
|
||||
internal Matrix44 cameraAtt;
|
||||
internal vec3d _target, up, cameraCoord;
|
||||
private bool _isLookAtAvailable;
|
||||
internal Matrix44 _lookAt;
|
||||
internal Matrix44 _projection;
|
||||
internal Matrix44 cameraAtt;
|
||||
internal Matrix44 rotation;
|
||||
internal Matrix44 rotationAtt;
|
||||
internal Radius _pitch;
|
||||
internal Radius _row;
|
||||
internal Radius _yaw;
|
||||
internal Uniform<Matrix44> convertedUniform;
|
||||
internal vec3d _target, up;
|
||||
|
||||
|
||||
public Camera()
|
||||
{
|
||||
cameraAtt = Matrix44.Unit;
|
||||
_target = Vec3d.Zero;
|
||||
up = Vec3d.Zero;
|
||||
cameraCoord = new vec3d(0,0,1);
|
||||
_isLookAtAvailable = false;
|
||||
_lookAt = Matrix44.Unit;
|
||||
rotationAtt = Matrix44.Unit;
|
||||
_projection = new Matrix44();
|
||||
}
|
||||
|
||||
public Camera(vec3d position, vec3d target, vec3d up) : this()
|
||||
{
|
||||
rotationAtt = Matrix44.Unit;
|
||||
cameraAtt = new Matrix44();
|
||||
SetViewDirection(position, target, up);
|
||||
_pitch = Radius.Zero;
|
||||
_row = Radius.Zero;
|
||||
_yaw = Radius.Zero;
|
||||
}
|
||||
|
||||
public Matrix44 Projection
|
||||
=> _projection;
|
||||
|
||||
public Matrix44 View
|
||||
{
|
||||
get
|
||||
@@ -75,159 +90,13 @@ namespace StgSharp.Graphics
|
||||
return _lookAt;
|
||||
}
|
||||
Matrix44 move = Matrix44.Unit;
|
||||
move.colum3.vec -= cameraCoord.vec;
|
||||
_lookAt = cameraAtt.Transpose * move;
|
||||
move.colum3.vec -= cameraAtt.colum3.vec;
|
||||
_lookAt = rotationAtt.Transpose * move;
|
||||
_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 SetViewRange(Radius fovRadius, vec2d size, vec2d offset, (float front, float back) dephRange)
|
||||
{
|
||||
float
|
||||
distance = _target.GetLength(),
|
||||
near = distance - dephRange.front,
|
||||
far = distance + dephRange.back,
|
||||
offsetX = offset.X,
|
||||
offsetY = offset.Y,
|
||||
width = Scaler.Abs(GeometryScaler.Tan(fovRadius / 2) * near *2),
|
||||
height = width * size.Y / size.X;
|
||||
|
||||
_projection.colum0.X = 2 * near / width;
|
||||
_projection.colum1.Y = 2 * near / height;
|
||||
_projection.colum2.X = 2 * offsetX / width;
|
||||
_projection.colum2.Y = 2 * offsetY / height;
|
||||
_projection.colum2.Z = (far + near) / (near - far);
|
||||
_projection.colum2.W = -1;
|
||||
_projection.colum3.Z = 2 * near * far / (near - far);
|
||||
|
||||
}
|
||||
|
||||
public void Test(params vec4d[] vec)
|
||||
{
|
||||
Console.WriteLine(View);
|
||||
Console.WriteLine(Projection);
|
||||
Console.WriteLine(Projection * View);
|
||||
foreach (var item in vec)
|
||||
{
|
||||
Console.Write($"{Projection * View * item};");
|
||||
}
|
||||
}
|
||||
|
||||
public void Pitch(Radius r)
|
||||
{
|
||||
_isLookAtAvailable = false;
|
||||
Matrix32 partialCoord = new Matrix32(
|
||||
cameraAtt.colum1.vec,
|
||||
cameraAtt.colum2.vec
|
||||
);
|
||||
float angle = -r._radius;
|
||||
//Console.WriteLine(angle);
|
||||
Matrix22 rotation = new Matrix22(
|
||||
Scaler.Cos(angle), -Scaler.Sin(angle),
|
||||
Scaler.Sin(angle), Scaler.Cos( angle)
|
||||
);
|
||||
|
||||
partialCoord *= rotation;
|
||||
cameraAtt.colum1.vec = partialCoord.colum0.vec;
|
||||
cameraAtt.colum2.vec = partialCoord.colum1.vec;
|
||||
|
||||
cameraAtt.isTransposed = false;
|
||||
}
|
||||
|
||||
public void Row(Radius r)
|
||||
{
|
||||
_isLookAtAvailable = false;
|
||||
Matrix32 partialCoord = new Matrix32(
|
||||
cameraAtt.colum0.vec,
|
||||
cameraAtt.colum1.vec
|
||||
);
|
||||
float angle = -r._radius;
|
||||
//Console.WriteLine(angle);
|
||||
Matrix22 rotation = new Matrix22(
|
||||
Scaler.Cos(angle), -Scaler.Sin(angle),
|
||||
Scaler.Sin(angle), Scaler.Cos(angle)
|
||||
);
|
||||
|
||||
partialCoord *= rotation;
|
||||
cameraAtt.colum0.vec = partialCoord.colum0.vec;
|
||||
cameraAtt.colum1.vec = partialCoord.colum1.vec;
|
||||
|
||||
cameraAtt.isTransposed = false;
|
||||
}
|
||||
|
||||
public void Yaw(Radius r)
|
||||
{
|
||||
_isLookAtAvailable = false;
|
||||
Matrix32 partialCoord = new Matrix32(
|
||||
cameraAtt.colum0.vec,
|
||||
cameraAtt.colum2.vec
|
||||
);
|
||||
float angle = -r._radius;
|
||||
//Console.WriteLine(angle);
|
||||
Matrix22 rotation = new Matrix22(
|
||||
Scaler.Cos(angle), -Scaler.Sin(angle),
|
||||
Scaler.Sin(angle), Scaler.Cos(angle)
|
||||
);
|
||||
|
||||
partialCoord *= rotation;
|
||||
cameraAtt.colum0.vec = partialCoord.colum0.vec;
|
||||
cameraAtt.colum2.vec = partialCoord.colum1.vec;
|
||||
|
||||
cameraAtt.isTransposed = false;
|
||||
}
|
||||
|
||||
public void SetViewDirection(vec3d position, vec3d target, vec3d up)
|
||||
{
|
||||
vec3d direction = position - target;
|
||||
if (position == cameraCoord && this.up == up && cameraAtt.colum2.vec == direction.vec)
|
||||
{
|
||||
//no difference with precious value
|
||||
return;
|
||||
}
|
||||
if (direction.GetLength() == 0)
|
||||
{
|
||||
//deadlock
|
||||
throw new ArgumentException();
|
||||
}
|
||||
if (Vec3d.IsParallel(direction, up))
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
_target = direction;
|
||||
cameraCoord = position;
|
||||
this.up = up;
|
||||
|
||||
_isLookAtAvailable = false;
|
||||
|
||||
Linear.Normalize(ref direction, ref up);
|
||||
|
||||
vec3d right = Linear.Normalize(Linear.Cross(up,direction));
|
||||
|
||||
cameraAtt.colum0.vec = right.vec;
|
||||
cameraAtt.colum1.vec = up.vec;
|
||||
cameraAtt.colum2.vec = direction.vec;
|
||||
cameraAtt.isTransposed = false;
|
||||
}
|
||||
|
||||
public void DisplayGLtypeDefinition()
|
||||
{
|
||||
Console.WriteLine("uniform matrix4x4 cameraName;");
|
||||
@@ -244,23 +113,204 @@ namespace StgSharp.Graphics
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public unsafe void GainAllUniforms(ShaderProgram source, params string[] uniformName)
|
||||
{
|
||||
if (uniformName.Length!=1)
|
||||
if (uniformName.Length != 1)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
convertedUniform = source.GetUniform<Matrix44>(uniformName[0]);
|
||||
}
|
||||
|
||||
ShaderStruct IglConvertable.GetConvertedGLtype()
|
||||
public void MoveNear(float distance)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
cameraAtt.colum3.Z -= distance;
|
||||
_isLookAtAvailable = false;
|
||||
}
|
||||
|
||||
public void MoveRight(float distance)
|
||||
{
|
||||
cameraAtt.colum3.X -= distance;
|
||||
_isLookAtAvailable = false;
|
||||
}
|
||||
|
||||
public void MoveUp(float distance)
|
||||
{
|
||||
cameraAtt.colum3.Y -= distance;
|
||||
_isLookAtAvailable = false;
|
||||
}
|
||||
|
||||
|
||||
public unsafe void SetAllUniforms()
|
||||
{
|
||||
//Console.WriteLine(Projection * View);
|
||||
GL.SetValue(convertedUniform, Projection * View);
|
||||
}
|
||||
|
||||
public void SetViewDirection(vec3d position, vec3d target, vec3d up)
|
||||
{
|
||||
vec3d direction = position - target;
|
||||
if ((position.vec == cameraAtt.colum3.vec) && (this.up == up) && (cameraAtt.colum2.vec == direction.vec))
|
||||
{
|
||||
//no difference with precious value
|
||||
return;
|
||||
}
|
||||
if (direction.GetLength() == 0)
|
||||
{
|
||||
//deadlock
|
||||
throw new ArgumentException();
|
||||
}
|
||||
if (Vec3d.IsParallel(direction, up))
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
_target = direction;
|
||||
this.up = up;
|
||||
|
||||
_isLookAtAvailable = false;
|
||||
|
||||
Linear.Normalize(ref direction, ref up);
|
||||
|
||||
vec3d right = Linear.Normalize(Linear.Cross(up, direction));
|
||||
|
||||
cameraAtt.colum0.vec = right.vec;
|
||||
cameraAtt.colum1.vec = up.vec;
|
||||
cameraAtt.colum2.vec = direction.vec;
|
||||
cameraAtt.colum3.vec = position.vec;
|
||||
|
||||
InternalPitch();
|
||||
InternalRow();
|
||||
InternalYaw();
|
||||
|
||||
}
|
||||
|
||||
public void SetViewRange(Radius fovRadius, vec2d size, vec2d offset, (float front, float back) dephRange)
|
||||
{
|
||||
float
|
||||
distance = _target.GetLength(),
|
||||
near = distance - dephRange.front,
|
||||
far = distance + dephRange.back,
|
||||
offsetX = offset.X,
|
||||
offsetY = offset.Y,
|
||||
width = Scaler.Abs(GeometryScaler.Tan(fovRadius / 2) * near * 2),
|
||||
height = (width * size.Y) / size.X;
|
||||
|
||||
_projection.colum0.X = (2 * near) / width;
|
||||
_projection.colum1.Y = (2 * near) / height;
|
||||
_projection.colum2.X = (2 * offsetX) / width;
|
||||
_projection.colum2.Y = (2 * offsetY) / height;
|
||||
_projection.colum2.Z = (far + near) / (near - far);
|
||||
_projection.colum2.W = -1;
|
||||
_projection.colum3.Z = (2 * near * far) / (near - far);
|
||||
|
||||
}
|
||||
|
||||
public void Test(params vec4d[] vec)
|
||||
{
|
||||
Console.WriteLine(View);
|
||||
Console.WriteLine(Projection);
|
||||
Console.WriteLine(Projection * View);
|
||||
Console.WriteLine(View);
|
||||
foreach (var item in vec)
|
||||
{
|
||||
Console.Write($"{Projection * View * item};");
|
||||
}
|
||||
}
|
||||
|
||||
#region ratation
|
||||
|
||||
public void Yaw(Radius r)
|
||||
{
|
||||
_yaw -= r;
|
||||
//Console.WriteLine(_yaw._radius);
|
||||
//Console.WriteLine(rotationAtt);
|
||||
InternalYaw();
|
||||
}
|
||||
|
||||
public void Pitch(Radius r)
|
||||
{
|
||||
_pitch -= r;
|
||||
//Console.WriteLine(_pitch._radius);
|
||||
//Console.WriteLine(rotationAtt);
|
||||
InternalPitch();
|
||||
}
|
||||
|
||||
public void Row(Radius r)
|
||||
{
|
||||
_row -= r;
|
||||
//Console.WriteLine(_row._radius);
|
||||
//Console.WriteLine(rotationAtt);
|
||||
InternalRow();
|
||||
}
|
||||
|
||||
internal void InternalPitch()
|
||||
{
|
||||
_isLookAtAvailable = false;
|
||||
|
||||
Matrix32 partialCoord = new Matrix32(
|
||||
cameraAtt.colum1.vec,
|
||||
cameraAtt.colum2.vec
|
||||
);
|
||||
float angle = _pitch._radius;
|
||||
|
||||
Matrix22 rotation = new Matrix22(
|
||||
Scaler.Cos(angle), -Scaler.Sin(angle),
|
||||
Scaler.Sin(angle), Scaler.Cos(angle)
|
||||
);
|
||||
|
||||
partialCoord *= rotation;
|
||||
rotationAtt.colum1.vec = partialCoord.colum0.vec;
|
||||
rotationAtt.colum2.vec = partialCoord.colum1.vec;
|
||||
rotationAtt.isTransposed = false;
|
||||
}
|
||||
|
||||
internal void InternalRow()
|
||||
{
|
||||
_isLookAtAvailable = false;
|
||||
|
||||
Matrix32 partialCoord = new Matrix32(
|
||||
cameraAtt.colum0.vec,
|
||||
cameraAtt.colum1.vec
|
||||
);
|
||||
float angle = _row._radius;
|
||||
|
||||
Matrix22 rotation = new Matrix22(
|
||||
Scaler.Cos(angle), -Scaler.Sin(angle),
|
||||
Scaler.Sin(angle), Scaler.Cos(angle)
|
||||
);
|
||||
|
||||
partialCoord *= rotation;
|
||||
rotationAtt.colum0.vec = partialCoord.colum0.vec;
|
||||
rotationAtt.colum1.vec = partialCoord.colum1.vec;
|
||||
rotationAtt.isTransposed = false;
|
||||
}
|
||||
|
||||
internal void InternalYaw()
|
||||
{
|
||||
_isLookAtAvailable = false;
|
||||
|
||||
Matrix32 partialCoord = new Matrix32(
|
||||
cameraAtt.colum0.vec,
|
||||
cameraAtt.colum2.vec
|
||||
);
|
||||
float angle = _yaw._radius;
|
||||
Matrix22 rotation = new Matrix22(
|
||||
Scaler.Cos(angle), -Scaler.Sin(angle),
|
||||
Scaler.Sin(angle), Scaler.Cos(angle)
|
||||
);
|
||||
|
||||
partialCoord *= rotation;
|
||||
rotationAtt.colum0.vec = partialCoord.colum0.vec;
|
||||
rotationAtt.colum2.vec = partialCoord.colum1.vec;
|
||||
rotationAtt.isTransposed = false;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
ShaderStruct IglConvertable.GetConvertedGLtype()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
~Camera()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace StgSharp
|
||||
|
||||
internal static partial class InternalIO
|
||||
{
|
||||
[DllImport(SSC_libname, EntryPoint = "normalize",
|
||||
[DllImport(SSC_libName, EntryPoint = "normalize",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Normalize(M128* source, M128* target);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace StgSharp
|
||||
|
||||
#region add
|
||||
|
||||
[DllImport(InternalIO.SSC_libname, EntryPoint = "add_Mat2",
|
||||
[DllImport(InternalIO.SSC_libName, EntryPoint = "add_Mat2",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern Mat2* add_mat2(Mat2* left, Mat2* right);
|
||||
@@ -52,7 +52,7 @@ namespace StgSharp
|
||||
|
||||
#region deinit mat2
|
||||
|
||||
[DllImport(InternalIO.SSC_libname, EntryPoint = "deinit_mat2",
|
||||
[DllImport(InternalIO.SSC_libName, EntryPoint = "deinit_mat2",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe void deinit_mat2(Mat2* mat);
|
||||
@@ -61,7 +61,7 @@ namespace StgSharp
|
||||
|
||||
#region sub
|
||||
|
||||
[DllImport(InternalIO.SSC_libname, EntryPoint = "sub_mat2",
|
||||
[DllImport(InternalIO.SSC_libName, EntryPoint = "sub_mat2",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe Mat2* sub_mat2(Mat2* left, Mat2* right);
|
||||
@@ -71,12 +71,12 @@ namespace StgSharp
|
||||
#region transpose
|
||||
|
||||
|
||||
[DllImport(InternalIO.SSC_libname, EntryPoint = "transpose2to4",
|
||||
[DllImport(InternalIO.SSC_libName, EntryPoint = "transpose2to4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe void Transpose2to4_internal(Mat2* source, Mat4* target);
|
||||
|
||||
[DllImport(InternalIO.SSC_libname, EntryPoint = "transpose2to3",
|
||||
[DllImport(InternalIO.SSC_libName, EntryPoint = "transpose2to3",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe void Transpose2to3_internal(Mat2* source, Mat3* target);
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace StgSharp
|
||||
|
||||
#region det
|
||||
|
||||
[DllImport(InternalIO.SSC_libname, EntryPoint = "det_mat3",
|
||||
[DllImport(InternalIO.SSC_libName, EntryPoint = "det_mat3",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe float det_mat3(Mat3* mat);
|
||||
@@ -51,15 +51,15 @@ namespace StgSharp
|
||||
|
||||
#region transpose
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "transpose3to4",
|
||||
[DllImport(SSC_libName, EntryPoint = "transpose3to4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Transpose3to4_internal(Mat3* source, Mat4* target);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "transpose3to3",
|
||||
[DllImport(SSC_libName, EntryPoint = "transpose3to3",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Transpose3to3_internal(Mat3* source, Mat3* target);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "transpose3to2",
|
||||
[DllImport(SSC_libName, EntryPoint = "transpose3to2",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Transpose3to2_internal(Mat3* source, Mat2* target);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace StgSharp
|
||||
#region deinit_mat4
|
||||
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "deinit_mat4",
|
||||
[DllImport(SSC_libName, EntryPoint = "deinit_mat4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern void deinit_mat4(Mat4* mat);
|
||||
@@ -53,7 +53,7 @@ namespace StgSharp
|
||||
|
||||
#region det
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "det_mat4",
|
||||
[DllImport(SSC_libName, EntryPoint = "det_mat4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static extern unsafe float det_mat4(Mat4* matPtr, Mat4* transpose);
|
||||
@@ -63,15 +63,15 @@ namespace StgSharp
|
||||
|
||||
#region transpose
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "transpose4to4",
|
||||
[DllImport(SSC_libName, EntryPoint = "transpose4to4",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Transpose4to4_internal(Mat4* source, Mat4* target);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "transpose4to3",
|
||||
[DllImport(SSC_libName, EntryPoint = "transpose4to3",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Transpose4to3_internal(Mat4* source, Mat3* target);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "transpose4to2",
|
||||
[DllImport(SSC_libName, EntryPoint = "transpose4to2",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern unsafe void Transpose4to2_internal(Mat4* source, Mat2* target);
|
||||
|
||||
|
||||
@@ -29,10 +29,15 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Controlling;
|
||||
using StgSharp.Math.HighPrecession;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Intrinsics.Arm;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
@@ -77,14 +82,39 @@ namespace StgSharp.Math
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static byte[] randomSeed;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Random()
|
||||
public static T Random<T>() where T : struct, IConvertible
|
||||
#if NET8_0_OR_GREATER
|
||||
,INumber
|
||||
#endif
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (randomSeed==null)
|
||||
{
|
||||
randomSeed = new byte[64];
|
||||
var originSeed =
|
||||
$"{(Assembly.GetEntryAssembly()==null? Assembly.GetAssembly(typeof(StgSharp))!:
|
||||
Assembly.GetEntryAssembly())}" +
|
||||
$"{DateTime.UtcNow.ToString("o")}";
|
||||
using (SHA256 sha = SHA256.Create())
|
||||
{
|
||||
randomSeed = sha.ComputeHash(Encoding.UTF8.GetBytes(originSeed));
|
||||
}
|
||||
}
|
||||
using (SHA256 sha = SHA256.Create())
|
||||
{
|
||||
randomSeed = sha.ComputeHash(randomSeed);
|
||||
}
|
||||
fixed (byte* bptr = randomSeed)
|
||||
{
|
||||
return *(T*)bptr;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user