daily update on 20240513 by nitload youmu, instancing render added

This commit is contained in:
YoumuLiu
2024-05-13 03:39:54 +08:00
parent 56459deec5
commit a3506c96a3
78 changed files with 2562 additions and 1098 deletions
-6
View File
@@ -28,12 +28,6 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
//
//
// some of the code is rewritten from the AMD code:
// https://github.com/amd/aocl-libm-ose/blob/a43e092b03213eb0e129a1cc129900e6e4475778/src/ref/asinf.c
using System;
+39
View File
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Math
{
public static partial class Scaler
{
public static float MaxOf(params float[] stream)
{
float ret = stream[0];
foreach (var num in stream)
{
if (ret < num)
{
ret = num;
}
}
return ret;
}
public static float MinOf(params float[] stream)
{
float ret = stream[0];
foreach (var num in stream)
{
if (ret > num)
{
ret = num;
}
}
return ret;
}
}
}
+1
View File
@@ -35,6 +35,7 @@ namespace StgSharp.Math
{
public static partial class Scaler
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Cos(float x)
{
+14 -14
View File
@@ -44,13 +44,7 @@ namespace StgSharp.Math
public static unsafe partial class Scaler
{
internal static float currentSeed
#if DEBUG
= 0.5f;
#else
= Abs(System.DateTime.UtcNow.GetHashCode());
#endif
private static byte[] randomSeed;
/// <summary>
/// returns a random float number between 0 and 1.
@@ -82,8 +76,6 @@ namespace StgSharp.Math
}
private static byte[] randomSeed;
/// <summary>
///
/// </summary>
@@ -94,13 +86,13 @@ namespace StgSharp.Math
,INumber
#endif
{
if (randomSeed==null)
if (randomSeed == null)
{
randomSeed = new byte[64];
var originSeed =
$"{(Assembly.GetEntryAssembly()==null? Assembly.GetAssembly(typeof(StgSharp))!:
Assembly.GetEntryAssembly())}" +
$"{DateTime.UtcNow.ToString("o")}";
string 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));
@@ -131,5 +123,13 @@ namespace StgSharp.Math
return *(int*)&seedValue;
}
internal static float currentSeed
#if DEBUG
= 0.5f;
#else
= Abs(System.DateTime.UtcNow.GetHashCode());
#endif
}
}
+34 -2
View File
@@ -1,4 +1,34 @@
using System;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="SignOf.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 System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
@@ -9,6 +39,7 @@ namespace StgSharp.Math
{
public static unsafe partial class Scaler
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe int SignOf(float x)
{
@@ -16,7 +47,7 @@ namespace StgSharp.Math
{
return 0;
}
if (x>0)
if (x > 0)
{
return 1;
}
@@ -35,5 +66,6 @@ namespace StgSharp.Math
}
return -1;
}
}
}