x) Implement SizeOf
x) And clamp and PerlinToContinent x) Optimize loaded scripts as Release
This commit is contained in:
parent
82ab55c672
commit
efe517abea
@ -144,7 +144,7 @@ namespace lib
|
|||||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||||
public static int SizeOf<T>()
|
public static int SizeOf<T>()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return System.Runtime.InteropServices.Marshal.SizeOf(typeof( T ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe void* Write<T>( void* pDest, ref T data ) where T : struct
|
public static unsafe void* Write<T>( void* pDest, ref T data ) where T : struct
|
||||||
|
|||||||
39
math/fn.cs
39
math/fn.cs
@ -32,6 +32,45 @@ namespace math
|
|||||||
|
|
||||||
static public class fn
|
static public class fn
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static public float Clamp( float v, float min, float max )
|
||||||
|
{
|
||||||
|
return v < min ? min : v > max ? max : v;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Tracked these down in Desmos
|
||||||
|
static public float s_a = 0.0f;
|
||||||
|
static public float s_b = 0.155f;
|
||||||
|
static public float s_c = 1.03f;
|
||||||
|
static public float s_d = 6.13f;
|
||||||
|
static public float s_f = -10.2f;
|
||||||
|
static public float s_g = 4.06f;
|
||||||
|
|
||||||
|
static public float Quintic( float v )
|
||||||
|
{
|
||||||
|
var vv = v * v;
|
||||||
|
var vvv = vv * v;
|
||||||
|
var vvvv = vvv * v;
|
||||||
|
var vvvvv= vvvv * v;
|
||||||
|
|
||||||
|
var res = s_a + s_b*v + s_c*vv + s_d*vvv + s_f*vvvv + s_g * vvvvv;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static public float s_p = 0.37f;
|
||||||
|
static public float s_o = 0.15f;
|
||||||
|
static public float s_m = 2.11f;
|
||||||
|
static public float s_n = -0.57f;
|
||||||
|
|
||||||
|
static public float PerlinToContinent( float h )
|
||||||
|
{
|
||||||
|
var res = Quintic( s_m * h + s_n ) * s_o + s_p;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static public float SmoothStepCos( float v )
|
static public float SmoothStepCos( float v )
|
||||||
{
|
{
|
||||||
var dV = (double)v;
|
var dV = (double)v;
|
||||||
|
|||||||
@ -196,8 +196,6 @@ public static class scr
|
|||||||
{
|
{
|
||||||
var fullpath = Path.GetFullPath( filename );
|
var fullpath = Path.GetFullPath( filename );
|
||||||
|
|
||||||
//string text = System.IO.File.ReadAllText( fullpath );
|
|
||||||
|
|
||||||
var stream = File.OpenRead( fullpath );
|
var stream = File.OpenRead( fullpath );
|
||||||
|
|
||||||
var sourceText = SourceText.From( stream );
|
var sourceText = SourceText.From( stream );
|
||||||
@ -221,8 +219,6 @@ public static class scr
|
|||||||
|
|
||||||
SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText( sourceText, options, uniquePath );
|
SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText( sourceText, options, uniquePath );
|
||||||
|
|
||||||
//SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(sourceText, options, uniquePath, encoding: System.Text.Encoding.UTF8);
|
|
||||||
|
|
||||||
var memRef = new MemoryRefResolver();
|
var memRef = new MemoryRefResolver();
|
||||||
|
|
||||||
|
|
||||||
@ -266,13 +262,14 @@ public static class scr
|
|||||||
{
|
{
|
||||||
var memRef = new MemoryRefResolver();
|
var memRef = new MemoryRefResolver();
|
||||||
|
|
||||||
|
// @@@@ TODO :: Config release / debug
|
||||||
CSharpCompilation compilation = CSharpCompilation.Create(
|
CSharpCompilation compilation = CSharpCompilation.Create(
|
||||||
assemblyName,
|
assemblyName,
|
||||||
syntaxTrees: syntaxTrees,
|
syntaxTrees: syntaxTrees,
|
||||||
references: RefCache.References,
|
references: RefCache.References,
|
||||||
options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary,
|
options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary,
|
||||||
sourceReferenceResolver: memRef,
|
sourceReferenceResolver: memRef,
|
||||||
optimizationLevel: OptimizationLevel.Debug,
|
optimizationLevel: OptimizationLevel.Release,
|
||||||
platform: platform,
|
platform: platform,
|
||||||
specificDiagnosticOptions: new Dictionary<string, ReportDiagnostic>
|
specificDiagnosticOptions: new Dictionary<string, ReportDiagnostic>
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user