hlsf goes bad
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="Vec2"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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
|
||||
@@ -25,6 +25,7 @@
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||
using StgSharp.Mathematics;
|
||||
using StgSharp.Mathematics.Numeric;
|
||||
using System.Net.Http.Headers;
|
||||
@@ -55,7 +56,9 @@ namespace StgSharp.Mathematics.Graphics
|
||||
[FieldOffset(4)]
|
||||
public float Y;
|
||||
|
||||
internal Vec2(Vector2 vec)
|
||||
internal Vec2(
|
||||
Vector2 vec
|
||||
)
|
||||
{
|
||||
Unsafe.SkipInit(out reg);
|
||||
Unsafe.SkipInit(out X);
|
||||
@@ -63,7 +66,9 @@ namespace StgSharp.Mathematics.Graphics
|
||||
v = vec;
|
||||
}
|
||||
|
||||
internal Vec2(M128 vec)
|
||||
internal Vec2(
|
||||
M128 vec
|
||||
)
|
||||
{
|
||||
Unsafe.SkipInit(out reg);
|
||||
Unsafe.SkipInit(out X);
|
||||
@@ -72,7 +77,10 @@ namespace StgSharp.Mathematics.Graphics
|
||||
reg.Member<ulong>(1) = 0;
|
||||
}
|
||||
|
||||
public Vec2(float x, float y)
|
||||
public Vec2(
|
||||
float x,
|
||||
float y
|
||||
)
|
||||
{
|
||||
v = new Vector2(x, y);
|
||||
}
|
||||
@@ -81,11 +89,7 @@ namespace StgSharp.Mathematics.Graphics
|
||||
|
||||
public static Vec2 Zero => new Vec2(0, 0);
|
||||
|
||||
public static Vec2 One
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => new Vec2(1, 1);
|
||||
}
|
||||
public static Vec2 One => new Vec2(1, 1);
|
||||
|
||||
public Vec2 XY
|
||||
{
|
||||
@@ -104,56 +108,83 @@ namespace StgSharp.Mathematics.Graphics
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public float Cross(Vec2 right)
|
||||
public float Cross(
|
||||
Vec2 right
|
||||
)
|
||||
{
|
||||
return X * right.Y - Y * right.X;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public float Dot(Vec2 vec)
|
||||
public float Dot(
|
||||
Vec2 vec
|
||||
)
|
||||
{
|
||||
return Vector2.Dot(v, vec.v);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vec2 operator -(Vec2 left, Vec2 right)
|
||||
public static Vec2 operator -(
|
||||
Vec2 left,
|
||||
Vec2 right
|
||||
)
|
||||
{
|
||||
return new Vec2(left.v - right.v);
|
||||
}
|
||||
|
||||
public static bool operator !=(Vec2 left, Vec2 right)
|
||||
public static bool operator !=(
|
||||
Vec2 left,
|
||||
Vec2 right
|
||||
)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public static Vec2 operator *(Vec2 vec, float value)
|
||||
public static Vec2 operator *(
|
||||
Vec2 vec,
|
||||
float value
|
||||
)
|
||||
{
|
||||
return new Vec2(vec.v * value);
|
||||
}
|
||||
public static Vec2 operator *(float value, Vec2 vec)
|
||||
public static Vec2 operator *(
|
||||
float value,
|
||||
Vec2 vec
|
||||
)
|
||||
{
|
||||
return new Vec2(vec.v * value);
|
||||
}
|
||||
|
||||
public static Vec2 operator /(Vec2 vec, float value)
|
||||
public static Vec2 operator /(
|
||||
Vec2 vec,
|
||||
float value
|
||||
)
|
||||
{
|
||||
return new Vec2(vec.v / value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vec2 operator +(Vec2 left, Vec2 right)
|
||||
public static Vec2 operator +(
|
||||
Vec2 left,
|
||||
Vec2 right
|
||||
)
|
||||
{
|
||||
return new Vec2(left.v + right.v);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(Vec2 left, Vec2 right)
|
||||
public static bool operator ==(
|
||||
Vec2 left,
|
||||
Vec2 right
|
||||
)
|
||||
{
|
||||
return left.v == right.v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator Vec2((float, float) tuple)
|
||||
public static implicit operator Vec2(
|
||||
(float, float) tuple
|
||||
)
|
||||
{
|
||||
return new Vec2(tuple.Item1, tuple.Item2);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="Vec3"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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
|
||||
@@ -25,6 +25,7 @@
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||
using StgSharp.Mathematics;
|
||||
using StgSharp.Mathematics.Numeric;
|
||||
using System;
|
||||
@@ -50,14 +51,18 @@ namespace StgSharp.Mathematics.Graphics
|
||||
[FieldOffset(4)] public float Y;
|
||||
[FieldOffset(8)] public float Z;
|
||||
|
||||
internal Vec3(M128 vector)
|
||||
internal Vec3(
|
||||
M128 vector
|
||||
)
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
reg = vector;
|
||||
reg.Member<uint>(3) = 0;
|
||||
}
|
||||
|
||||
internal Vec3(Vector3 vector)
|
||||
internal Vec3(
|
||||
Vector3 vector
|
||||
)
|
||||
{
|
||||
v = vector;
|
||||
}
|
||||
@@ -67,14 +72,21 @@ namespace StgSharp.Mathematics.Graphics
|
||||
Unsafe.SkipInit(out this);
|
||||
}
|
||||
|
||||
public Vec3(Vec2 xy, float z)
|
||||
public Vec3(
|
||||
Vec2 xy,
|
||||
float z
|
||||
)
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
reg = xy.reg;
|
||||
Z = z;
|
||||
}
|
||||
|
||||
public Vec3(float x, float y, float z)
|
||||
public Vec3(
|
||||
float x,
|
||||
float y,
|
||||
float z
|
||||
)
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
v = new Vector3(x, y, z);
|
||||
@@ -107,28 +119,39 @@ namespace StgSharp.Mathematics.Graphics
|
||||
public static Vec3 UnitZ => new(0, 0, 1);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vec3 Cross(Vec3 left, Vec3 right)
|
||||
public static Vec3 Cross(
|
||||
Vec3 left,
|
||||
Vec3 right
|
||||
)
|
||||
{
|
||||
return Linear.Cross(left, right);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly float Dot(Vec3 right)
|
||||
public readonly float Dot(
|
||||
Vec3 right
|
||||
)
|
||||
{
|
||||
return Vector3.Dot(v, right.v);
|
||||
}
|
||||
|
||||
public readonly bool Equals(Vec3 other)
|
||||
public readonly bool Equals(
|
||||
Vec3 other
|
||||
)
|
||||
{
|
||||
return reg == other.reg;
|
||||
}
|
||||
|
||||
public override readonly bool Equals(object obj)
|
||||
public override readonly bool Equals(
|
||||
object obj
|
||||
)
|
||||
{
|
||||
return obj is not null && obj is Vec3 vec && this == vec;
|
||||
}
|
||||
|
||||
public static Vec3 FromSpan(ReadOnlySpan<float> span)
|
||||
public static Vec3 FromSpan(
|
||||
ReadOnlySpan<float> span
|
||||
)
|
||||
{
|
||||
Vec3 v = new();
|
||||
span.CopyTo(MemoryMarshal.CreateSpan(ref v.X, 3));
|
||||
@@ -158,7 +181,10 @@ namespace StgSharp.Mathematics.Graphics
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static bool IsParallel(Vec3 left, Vec3 right)
|
||||
public static bool IsParallel(
|
||||
Vec3 left,
|
||||
Vec3 right
|
||||
)
|
||||
{
|
||||
return Cross(left, right) == Zero;
|
||||
}
|
||||
@@ -168,61 +194,88 @@ namespace StgSharp.Mathematics.Graphics
|
||||
return $"[{X},{Y},{Z}]";
|
||||
}
|
||||
|
||||
public readonly string ToString(string sample)
|
||||
public readonly string ToString(
|
||||
string sample
|
||||
)
|
||||
{
|
||||
return $"[{X.ToString(sample)},{Y.ToString(sample)},{Z.ToString(sample)}]";
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vec3 operator -(Vec3 vec)
|
||||
public static Vec3 operator -(
|
||||
Vec3 vec
|
||||
)
|
||||
{
|
||||
return new Vec3(-vec.v);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vec3 operator -(Vec3 left, Vec3 right)
|
||||
public static Vec3 operator -(
|
||||
Vec3 left,
|
||||
Vec3 right
|
||||
)
|
||||
{
|
||||
return new Vec3(left.v - right.v);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(Vec3 left, Vec3 right)
|
||||
public static bool operator !=(
|
||||
Vec3 left,
|
||||
Vec3 right
|
||||
)
|
||||
{
|
||||
return left.v != right.v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vec3 operator *(Vec3 vec, float value)
|
||||
public static Vec3 operator *(
|
||||
Vec3 vec,
|
||||
float value
|
||||
)
|
||||
{
|
||||
return new Vec3(vec.v * value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float operator *(Vec3 left, Vec3 right)
|
||||
public static float operator *(
|
||||
Vec3 left,
|
||||
Vec3 right
|
||||
)
|
||||
{
|
||||
return Vector3.Dot(left.v, right.v);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vec3 operator /(Vec3 vec, float value)
|
||||
public static Vec3 operator /(
|
||||
Vec3 vec,
|
||||
float value
|
||||
)
|
||||
{
|
||||
return new Vec3(vec.v / value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vec3 operator +(Vec3 left, Vec3 right)
|
||||
public static Vec3 operator +(
|
||||
Vec3 left,
|
||||
Vec3 right
|
||||
)
|
||||
{
|
||||
return new Vec3(left.v + right.v);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(Vec3 left, Vec3 right)
|
||||
public static bool operator ==(
|
||||
Vec3 left,
|
||||
Vec3 right
|
||||
)
|
||||
{
|
||||
return left.v == right.v;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe implicit operator Vec3((float, float, float) tuple)
|
||||
public static unsafe implicit operator Vec3(
|
||||
(float, float, float) tuple
|
||||
)
|
||||
{
|
||||
return Unsafe.As<(float,float,float), Vec3>(ref tuple);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||
using StgSharp.Mathematics;
|
||||
using StgSharp.Mathematics.Internal;
|
||||
using StgSharp.Mathematics.Numeric;
|
||||
@@ -240,4 +241,4 @@ namespace StgSharp.Mathematics.Graphics
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user