Daily update on 20230505 by nitload youmu, confuse on OpenGL
This commit is contained in:
@@ -90,6 +90,10 @@ namespace StgSharp.Math
|
||||
return new vec2d(vec.X/x, vec.Y/x);
|
||||
}
|
||||
|
||||
public static implicit operator float[](vec2d vec)
|
||||
{
|
||||
return new float[2] {vec.X,vec.Y };
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using StgSharp.Optimization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -6,7 +7,7 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
[StructLayout(LayoutKind.Explicit,Size =12,Pack =16)]
|
||||
public struct vec3d : IEquatable<vec3d>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
@@ -129,5 +130,20 @@ namespace StgSharp.Math
|
||||
vec.Z / x
|
||||
);
|
||||
}
|
||||
|
||||
public static implicit operator float[](vec3d vec)
|
||||
{
|
||||
return new float[3] { vec.X, vec.Y, vec.Y };
|
||||
}
|
||||
|
||||
public static implicit operator m128(vec3d vec)
|
||||
{
|
||||
return new m128()
|
||||
{
|
||||
float0 = vec.X,
|
||||
float1 = vec.Y,
|
||||
float2 = vec.Z,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,10 @@ namespace StgSharp.Math
|
||||
return new vec4d(vec.X / x, vec.Y / x, vec.Z / x, vec.W / x);
|
||||
}
|
||||
|
||||
|
||||
public static implicit operator float[](vec4d vec)
|
||||
{
|
||||
return new float[] { vec.X, vec.Y, vec.Z, vec.W };
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace StgSharp.Math
|
||||
{
|
||||
public static partial class Calc
|
||||
{
|
||||
private static m128 sqrtCache;
|
||||
|
||||
public static unsafe float Sqrt(float x)
|
||||
{
|
||||
@@ -21,7 +20,7 @@ namespace StgSharp.Math
|
||||
|
||||
if (x < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
throw new ArgumentOutOfRangeException("Input is smaller than zero!");
|
||||
}
|
||||
if (x == 0)
|
||||
{
|
||||
@@ -71,18 +70,6 @@ namespace StgSharp.Math
|
||||
float result = *(float*)&e;
|
||||
result = (result + x / result) / 2;
|
||||
return (result + x / result) / 2;
|
||||
/**/
|
||||
/*
|
||||
fixed (m128* p = &sqrtCache)
|
||||
{
|
||||
sqrtCache.float0 = x;
|
||||
return (SSE.Sqrtss(p)).float0;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
[DllImport("xmmintrin.h",EntryPoint = "_mm_sqrt_ss")]
|
||||
public static extern m128 Sqrtss(m128 a);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user