fishnet installed
This commit is contained in:
26
Assets/FishNet/Runtime/Serializing/Helping/Attributes.cs
Normal file
26
Assets/FishNet/Runtime/Serializing/Helping/Attributes.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using FishNet.Utility.Constant;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo(UtilityConstants.CODEGEN_ASSEMBLY_NAME)]
|
||||
namespace FishNet.Serializing.Helping
|
||||
{
|
||||
/// <summary>
|
||||
/// Method is a comparer for a value type.
|
||||
/// </summary>
|
||||
public class CustomComparerAttribute : Attribute { }
|
||||
/// <summary>
|
||||
/// Method or type will be made public by codegen.
|
||||
/// </summary>
|
||||
internal class CodegenMakePublicAttribute : Attribute { }
|
||||
/// <summary>
|
||||
/// Field or type will be excluded from codegen serialization.
|
||||
/// </summary>
|
||||
public class CodegenExcludeAttribute : Attribute { }
|
||||
/// <summary>
|
||||
/// THIS DOES NOT DO ANYTHING AT THIS TIME.
|
||||
/// It would do -> Type will be included in codegen serialization.
|
||||
/// </summary>
|
||||
internal class CodegenIncludeAttribute : Attribute { }
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce079c8f32bf87b46a44681ccc8578fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
38
Assets/FishNet/Runtime/Serializing/Helping/Broadcasts.cs
Normal file
38
Assets/FishNet/Runtime/Serializing/Helping/Broadcasts.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using FishNet.Managing.Scened;
|
||||
using FishNet.Managing.Server;
|
||||
using FishNet.Object.Helping;
|
||||
using FishNet.Transporting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FishNet.Serializing.Helping
|
||||
{
|
||||
|
||||
internal static class Broadcasts
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes a broadcast to writer.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="writer"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="channel"></param>
|
||||
/// <returns></returns>
|
||||
internal static PooledWriter WriteBroadcast<T>(PooledWriter writer, T message, Channel channel)
|
||||
{
|
||||
writer.WritePacketId(PacketId.Broadcast);
|
||||
writer.WriteUInt16(typeof(T).FullName.GetStableHash16()); //muchlater codegen this to pass in hash. use technique similar to rpcs to limit byte/shorts.
|
||||
//Write data to a new writer.
|
||||
PooledWriter dataWriter = WriterPool.GetWriter();
|
||||
dataWriter.Write<T>(message);
|
||||
//Write length of data.
|
||||
writer.WriteLength(dataWriter.Length);
|
||||
//Write data.
|
||||
writer.WriteArraySegment(dataWriter.GetArraySegment());
|
||||
|
||||
dataWriter.Dispose();
|
||||
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0636e29429649a24795091f80edbd892
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
66
Assets/FishNet/Runtime/Serializing/Helping/Comparers.cs
Normal file
66
Assets/FishNet/Runtime/Serializing/Helping/Comparers.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace FishNet.Serializing.Helping
|
||||
{
|
||||
|
||||
public class GeneratedComparer<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Compare if T is default.
|
||||
/// </summary>
|
||||
public static Func<T, bool> IsDefault { internal get; set; }
|
||||
/// <summary>
|
||||
/// Compare if T is the same as T2.
|
||||
/// </summary>
|
||||
public static Func<T, T, bool> Compare { internal get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class Comparers
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns if A equals B using EqualityCompare.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="a"></param>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
public static bool EqualityCompare<T>(T a, T b)
|
||||
{
|
||||
return EqualityComparer<T>.Default.Equals(a, b);
|
||||
}
|
||||
|
||||
public static bool IsDefault<T>(T t)
|
||||
{
|
||||
return t.Equals(default(T));
|
||||
}
|
||||
|
||||
public static bool IsEqualityCompareDefault<T>(T a)
|
||||
{
|
||||
return EqualityComparer<T>.Default.Equals(a, default(T));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal class SceneComparer : IEqualityComparer<Scene>
|
||||
{
|
||||
public bool Equals(Scene a, Scene b)
|
||||
{
|
||||
if (!a.IsValid() || !b.IsValid())
|
||||
return false;
|
||||
|
||||
if (a.handle != 0 || b.handle != 0)
|
||||
return (a.handle == b.handle);
|
||||
|
||||
return (a.name == b.name);
|
||||
}
|
||||
|
||||
public int GetHashCode(Scene obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/FishNet/Runtime/Serializing/Helping/Comparers.cs.meta
Normal file
11
Assets/FishNet/Runtime/Serializing/Helping/Comparers.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e912d0645f10b2c458cc2f01e24ecc27
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
163
Assets/FishNet/Runtime/Serializing/Helping/Quaternion32.cs
Normal file
163
Assets/FishNet/Runtime/Serializing/Helping/Quaternion32.cs
Normal file
@ -0,0 +1,163 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FishNet.Serializing.Helping
|
||||
{
|
||||
public static class Quaternion32Compression
|
||||
{
|
||||
private const float Maximum = +1.0f / 1.414214f;
|
||||
|
||||
private const int BitsPerAxis = 10;
|
||||
private const int LargestComponentShift = BitsPerAxis * 3;
|
||||
private const int AShift = BitsPerAxis * 2;
|
||||
private const int BShift = BitsPerAxis * 1;
|
||||
private const int IntScale = (1 << (BitsPerAxis - 1)) - 1;
|
||||
private const int IntMask = (1 << BitsPerAxis) - 1;
|
||||
|
||||
public static uint Compress(Quaternion quaternion)
|
||||
{
|
||||
float absX = Mathf.Abs(quaternion.x);
|
||||
float absY = Mathf.Abs(quaternion.y);
|
||||
float absZ = Mathf.Abs(quaternion.z);
|
||||
float absW = Mathf.Abs(quaternion.w);
|
||||
|
||||
ComponentType largestComponent = ComponentType.X;
|
||||
float largestAbs = absX;
|
||||
float largest = quaternion.x;
|
||||
|
||||
if (absY > largestAbs)
|
||||
{
|
||||
largestAbs = absY;
|
||||
largestComponent = ComponentType.Y;
|
||||
largest = quaternion.y;
|
||||
}
|
||||
if (absZ > largestAbs)
|
||||
{
|
||||
largestAbs = absZ;
|
||||
largestComponent = ComponentType.Z;
|
||||
largest = quaternion.z;
|
||||
}
|
||||
if (absW > largestAbs)
|
||||
{
|
||||
largestComponent = ComponentType.W;
|
||||
largest = quaternion.w;
|
||||
}
|
||||
|
||||
float a = 0;
|
||||
float b = 0;
|
||||
float c = 0;
|
||||
switch (largestComponent)
|
||||
{
|
||||
case ComponentType.X:
|
||||
a = quaternion.y;
|
||||
b = quaternion.z;
|
||||
c = quaternion.w;
|
||||
break;
|
||||
case ComponentType.Y:
|
||||
a = quaternion.x;
|
||||
b = quaternion.z;
|
||||
c = quaternion.w;
|
||||
break;
|
||||
case ComponentType.Z:
|
||||
a = quaternion.x;
|
||||
b = quaternion.y;
|
||||
c = quaternion.w;
|
||||
break;
|
||||
case ComponentType.W:
|
||||
a = quaternion.x;
|
||||
b = quaternion.y;
|
||||
c = quaternion.z;
|
||||
break;
|
||||
}
|
||||
|
||||
if (largest < 0)
|
||||
{
|
||||
a = -a;
|
||||
b = -b;
|
||||
c = -c;
|
||||
}
|
||||
|
||||
uint integerA = ScaleToUint(a);
|
||||
uint integerB = ScaleToUint(b);
|
||||
uint integerC = ScaleToUint(c);
|
||||
|
||||
return (((uint)largestComponent) << LargestComponentShift) | (integerA << AShift) | (integerB << BShift) | integerC;
|
||||
}
|
||||
|
||||
private static uint ScaleToUint(float v)
|
||||
{
|
||||
float normalized = v / Maximum;
|
||||
return (uint)Mathf.RoundToInt(normalized * IntScale) & IntMask;
|
||||
}
|
||||
|
||||
private static float ScaleToFloat(uint v)
|
||||
{
|
||||
float unscaled = v * Maximum / IntScale;
|
||||
|
||||
if (unscaled > Maximum)
|
||||
unscaled -= Maximum * 2;
|
||||
return unscaled;
|
||||
}
|
||||
|
||||
public static Quaternion Decompress(uint compressed)
|
||||
{
|
||||
var largestComponentType = (ComponentType)(compressed >> LargestComponentShift);
|
||||
uint integerA = (compressed >> AShift) & IntMask;
|
||||
uint integerB = (compressed >> BShift) & IntMask;
|
||||
uint integerC = compressed & IntMask;
|
||||
|
||||
float a = ScaleToFloat(integerA);
|
||||
float b = ScaleToFloat(integerB);
|
||||
float c = ScaleToFloat(integerC);
|
||||
|
||||
Quaternion rotation;
|
||||
switch (largestComponentType)
|
||||
{
|
||||
case ComponentType.X:
|
||||
// (?) y z w
|
||||
rotation.y = a;
|
||||
rotation.z = b;
|
||||
rotation.w = c;
|
||||
rotation.x = Mathf.Sqrt(1 - rotation.y * rotation.y
|
||||
- rotation.z * rotation.z
|
||||
- rotation.w * rotation.w);
|
||||
break;
|
||||
case ComponentType.Y:
|
||||
// x (?) z w
|
||||
rotation.x = a;
|
||||
rotation.z = b;
|
||||
rotation.w = c;
|
||||
rotation.y = Mathf.Sqrt(1 - rotation.x * rotation.x
|
||||
- rotation.z * rotation.z
|
||||
- rotation.w * rotation.w);
|
||||
break;
|
||||
case ComponentType.Z:
|
||||
// x y (?) w
|
||||
rotation.x = a;
|
||||
rotation.y = b;
|
||||
rotation.w = c;
|
||||
rotation.z = Mathf.Sqrt(1 - rotation.x * rotation.x
|
||||
- rotation.y * rotation.y
|
||||
- rotation.w * rotation.w);
|
||||
break;
|
||||
case ComponentType.W:
|
||||
// x y z (?)
|
||||
rotation.x = a;
|
||||
rotation.y = b;
|
||||
rotation.z = c;
|
||||
rotation.w = Mathf.Sqrt(1 - rotation.x * rotation.x
|
||||
- rotation.y * rotation.y
|
||||
- rotation.z * rotation.z);
|
||||
break;
|
||||
default:
|
||||
// Should never happen!
|
||||
throw new ArgumentOutOfRangeException("Unknown rotation component type: " +
|
||||
largestComponentType);
|
||||
}
|
||||
|
||||
return rotation;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f71e61ed84064a0429577ec462a8fa79
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
192
Assets/FishNet/Runtime/Serializing/Helping/Quaternion64.cs
Normal file
192
Assets/FishNet/Runtime/Serializing/Helping/Quaternion64.cs
Normal file
@ -0,0 +1,192 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FishNet.Serializing.Helping
|
||||
{
|
||||
/// <summary>
|
||||
/// Credit to https://github.com/viliwonka
|
||||
/// https://github.com/FirstGearGames/FishNet/pull/23
|
||||
/// </summary>
|
||||
public static class Quaternion64Compression
|
||||
{
|
||||
// 64 bit quaternion compression
|
||||
// [4 bits] largest component
|
||||
// [21 bits] higher res
|
||||
// [21 bits] higher res
|
||||
// [20 bits] higher res
|
||||
// sum is 64 bits
|
||||
private const float Maximum = +1.0f / 1.414214f;
|
||||
private const int BitsPerAxis_H = 21; // higher res, 21 bits
|
||||
private const int BitsPerAxis_L = 20; // lower res, 20 bits
|
||||
private const int LargestComponentShift = BitsPerAxis_H * 2 + BitsPerAxis_L * 1;
|
||||
private const int AShift = BitsPerAxis_H + BitsPerAxis_L;
|
||||
private const int BShift = BitsPerAxis_L;
|
||||
private const int IntScale_H = (1 << (BitsPerAxis_H - 1)) - 1;
|
||||
private const int IntMask_H = (1 << BitsPerAxis_H) - 1;
|
||||
private const int IntScale_L = (1 << (BitsPerAxis_L - 1)) - 1;
|
||||
private const int IntMask_L = (1 << BitsPerAxis_L) - 1;
|
||||
|
||||
public static ulong Compress(Quaternion quaternion)
|
||||
{
|
||||
float absX = Mathf.Abs(quaternion.x);
|
||||
float absY = Mathf.Abs(quaternion.y);
|
||||
float absZ = Mathf.Abs(quaternion.z);
|
||||
float absW = Mathf.Abs(quaternion.w);
|
||||
|
||||
ComponentType largestComponent = ComponentType.X;
|
||||
float largestAbs = absX;
|
||||
float largest = quaternion.x;
|
||||
|
||||
if (absY > largestAbs)
|
||||
{
|
||||
largestAbs = absY;
|
||||
largestComponent = ComponentType.Y;
|
||||
largest = quaternion.y;
|
||||
}
|
||||
if (absZ > largestAbs)
|
||||
{
|
||||
largestAbs = absZ;
|
||||
largestComponent = ComponentType.Z;
|
||||
largest = quaternion.z;
|
||||
}
|
||||
if (absW > largestAbs)
|
||||
{
|
||||
largestComponent = ComponentType.W;
|
||||
largest = quaternion.w;
|
||||
}
|
||||
|
||||
float a = 0;
|
||||
float b = 0;
|
||||
float c = 0;
|
||||
|
||||
switch (largestComponent)
|
||||
{
|
||||
case ComponentType.X:
|
||||
a = quaternion.y;
|
||||
b = quaternion.z;
|
||||
c = quaternion.w;
|
||||
break;
|
||||
case ComponentType.Y:
|
||||
a = quaternion.x;
|
||||
b = quaternion.z;
|
||||
c = quaternion.w;
|
||||
break;
|
||||
case ComponentType.Z:
|
||||
a = quaternion.x;
|
||||
b = quaternion.y;
|
||||
c = quaternion.w;
|
||||
break;
|
||||
case ComponentType.W:
|
||||
a = quaternion.x;
|
||||
b = quaternion.y;
|
||||
c = quaternion.z;
|
||||
break;
|
||||
}
|
||||
|
||||
if (largest < 0)
|
||||
{
|
||||
a = -a;
|
||||
b = -b;
|
||||
c = -c;
|
||||
}
|
||||
|
||||
ulong integerA = ScaleToUint_H(a);
|
||||
ulong integerB = ScaleToUint_H(b);
|
||||
ulong integerC = ScaleToUint_L(c);
|
||||
|
||||
return (((ulong)largestComponent) << LargestComponentShift) | (integerA << AShift) | (integerB << BShift) | integerC;
|
||||
}
|
||||
|
||||
private static ulong ScaleToUint_H(float v)
|
||||
{
|
||||
float normalized = v / Maximum;
|
||||
return (ulong)Mathf.RoundToInt(normalized * IntScale_H) & IntMask_H;
|
||||
}
|
||||
|
||||
private static ulong ScaleToUint_L(float v)
|
||||
{
|
||||
float normalized = v / Maximum;
|
||||
return (ulong)Mathf.RoundToInt(normalized * IntScale_L) & IntMask_L;
|
||||
}
|
||||
|
||||
private static float ScaleToFloat_H(ulong v)
|
||||
{
|
||||
float unscaled = v * Maximum / IntScale_H;
|
||||
|
||||
if (unscaled > Maximum)
|
||||
unscaled -= Maximum * 2;
|
||||
return unscaled;
|
||||
}
|
||||
|
||||
private static float ScaleToFloat_L(ulong v)
|
||||
{
|
||||
float unscaled = v * Maximum / IntScale_L;
|
||||
|
||||
if (unscaled > Maximum)
|
||||
unscaled -= Maximum * 2;
|
||||
return unscaled;
|
||||
}
|
||||
|
||||
public static Quaternion Decompress(ulong compressed)
|
||||
{
|
||||
var largestComponentType = (ComponentType)(compressed >> LargestComponentShift);
|
||||
ulong integerA = (compressed >> AShift) & IntMask_H;
|
||||
ulong integerB = (compressed >> BShift) & IntMask_H;
|
||||
ulong integerC = compressed & IntMask_L;
|
||||
|
||||
float a = ScaleToFloat_H(integerA);
|
||||
float b = ScaleToFloat_H(integerB);
|
||||
float c = ScaleToFloat_L(integerC);
|
||||
|
||||
Quaternion rotation;
|
||||
switch (largestComponentType)
|
||||
{
|
||||
case ComponentType.X:
|
||||
// (?) y z w
|
||||
rotation.y = a;
|
||||
rotation.z = b;
|
||||
rotation.w = c;
|
||||
rotation.x = Mathf.Sqrt(1 - rotation.y * rotation.y
|
||||
- rotation.z * rotation.z
|
||||
- rotation.w * rotation.w);
|
||||
break;
|
||||
case ComponentType.Y:
|
||||
// x (?) z w
|
||||
rotation.x = a;
|
||||
rotation.z = b;
|
||||
rotation.w = c;
|
||||
rotation.y = Mathf.Sqrt(1 - rotation.x * rotation.x
|
||||
- rotation.z * rotation.z
|
||||
- rotation.w * rotation.w);
|
||||
break;
|
||||
case ComponentType.Z:
|
||||
// x y (?) w
|
||||
rotation.x = a;
|
||||
rotation.y = b;
|
||||
rotation.w = c;
|
||||
rotation.z = Mathf.Sqrt(1 - rotation.x * rotation.x
|
||||
- rotation.y * rotation.y
|
||||
- rotation.w * rotation.w);
|
||||
break;
|
||||
case ComponentType.W:
|
||||
// x y z (?)
|
||||
rotation.x = a;
|
||||
rotation.y = b;
|
||||
rotation.z = c;
|
||||
rotation.w = Mathf.Sqrt(1 - rotation.x * rotation.x
|
||||
- rotation.y * rotation.y
|
||||
- rotation.z * rotation.z);
|
||||
break;
|
||||
default:
|
||||
// Should never happen!
|
||||
throw new ArgumentOutOfRangeException("Unknown rotation component type: " +
|
||||
largestComponentType);
|
||||
}
|
||||
|
||||
return rotation;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7afd33d2ca5433f4f831dfaf0169423c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,126 @@
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FishNet.Serializing.Helping
|
||||
{
|
||||
/// <summary>
|
||||
/// Static class used for fast conversion of quaternion structs. Not thread safe!
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct QuaternionConverter
|
||||
{
|
||||
// [FieldOffset(0)]
|
||||
// public Quaternion Q;
|
||||
// [FieldOffset(0)]
|
||||
// public Quaternion64 Q64;
|
||||
// [FieldOffset(0)]
|
||||
// public Quaternion128 Q128;
|
||||
|
||||
// public static QuaternionConverter StaticRef = new QuaternionConverter();
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
// public static Quaternion64 QtoQ64(Quaternion quaternion64)
|
||||
// {
|
||||
// StaticRef.Q = quaternion64;
|
||||
// return StaticRef.Q64;
|
||||
// }
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
// public static Quaternion Q64toQ(Quaternion64 quaternion)
|
||||
// {
|
||||
// StaticRef.Q64 = quaternion;
|
||||
// return StaticRef.Q;
|
||||
// }
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
// public static Quaternion128 QtoQ128(Quaternion quaternion128)
|
||||
// {
|
||||
// StaticRef.Q = quaternion128;
|
||||
// return StaticRef.Q128;
|
||||
// }
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
// public static Quaternion Q128toQ(Quaternion128 quaternion)
|
||||
// {
|
||||
// StaticRef.Q128 = quaternion;
|
||||
// return StaticRef.Q;
|
||||
// }
|
||||
//}
|
||||
|
||||
//public struct Quaternion64
|
||||
//{
|
||||
// public float x;
|
||||
// public float y;
|
||||
// public float z;
|
||||
// public float w;
|
||||
|
||||
// public Quaternion64(float x, float y, float z, float w)
|
||||
// {
|
||||
// this.x = x;
|
||||
// this.y = y;
|
||||
// this.z = z;
|
||||
// this.w = w;
|
||||
// }
|
||||
|
||||
// public Quaternion64(Quaternion q)
|
||||
// {
|
||||
// this.x = q.x;
|
||||
// this.y = q.y;
|
||||
// this.z = q.z;
|
||||
// this.w = q.w;
|
||||
// }
|
||||
|
||||
// /*[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
// public static implicit operator Quaternion64(Quaternion q) => new Quaternion64(q);
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
// public static implicit operator Quaternion(Quaternion64 q) => new Quaternion(q.x, q.y, q.z, q.w);*/
|
||||
//}
|
||||
|
||||
//public struct Quaternion128
|
||||
//{
|
||||
// public float x;
|
||||
// public float y;
|
||||
// public float z;
|
||||
// public float w;
|
||||
// public Quaternion128(float x, float y, float z, float w)
|
||||
// {
|
||||
// this.x = x;
|
||||
// this.y = y;
|
||||
// this.z = z;
|
||||
// this.w = w;
|
||||
// }
|
||||
|
||||
// public Quaternion128(Quaternion q)
|
||||
// {
|
||||
// x = q.x;
|
||||
// y = q.y;
|
||||
// z = q.z;
|
||||
// w = q.w;
|
||||
// }
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
// public static implicit operator Quaternion128(Quaternion q) => new Quaternion128(q);
|
||||
|
||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
// public static implicit operator Quaternion(Quaternion128 q) => new Quaternion(q.x, q.y, q.z, q.w);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Credit to this man for converting gaffer games c code to c#
|
||||
/// https://gist.github.com/fversnel/0497ad7ab3b81e0dc1dd
|
||||
/// </summary>
|
||||
}
|
||||
|
||||
public enum ComponentType : uint
|
||||
{
|
||||
X = 0,
|
||||
Y = 1,
|
||||
Z = 2,
|
||||
W = 3
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7ac59ce12259104fa28fc837fb17ccf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,41 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace FishNet.Serializing.Helping
|
||||
{
|
||||
|
||||
|
||||
// -- helpers for float conversion without allocations --
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
internal struct UIntFloat
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public float FloatValue;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public uint UIntValue;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
internal struct UIntDouble
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public double DoubleValue;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public ulong LongValue;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
internal struct UIntDecimal
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public ulong LongValue1;
|
||||
|
||||
[FieldOffset(8)]
|
||||
public ulong LongValue2;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public decimal DecimalValue;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 008e79d0f22a2674189acc7eff64408f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user