提交Unity 联机Pro

This commit is contained in:
PC-20230316NUNE\Administrator
2024-08-17 14:27:18 +08:00
parent f00193b000
commit 894100ae37
7448 changed files with 854473 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e0546f91227845db8711cbd928005e6b
timeCreated: 1715335323

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 109919afddd1401d9087b46e76532e90
timeCreated: 1715335324

View File

@@ -0,0 +1,274 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net.Security;
namespace DotRecast.Core.Buffers
{
// https://github.com/joaoportela/CircularBuffer-CSharp/blob/master/CircularBuffer/CircularBuffer.cs
public class RcCyclicBuffer<T> : IEnumerable<T>
{
public struct Enumerator : IEnumerator<T>
{
private readonly RcCyclicBuffer<T> _cb;
private int _index;
private readonly int _size;
internal Enumerator(RcCyclicBuffer<T> cb)
{
_cb = cb;
_size = _cb._size;
_index = default;
Reset();
}
public bool MoveNext()
{
return ++_index < _size;
}
public void Reset()
{
_index = -1;
}
public T Current => _cb[_index];
object IEnumerator.Current => Current;
public void Dispose()
{
// This could be used to unlock write access to collection
}
}
private readonly T[] _buffer;
private int _start;
private int _end;
private int _size;
public RcCyclicBuffer(int capacity)
: this(capacity, new T[] { })
{
}
public RcCyclicBuffer(int capacity, T[] items)
{
if (capacity < 1)
{
throw new ArgumentException("RcCyclicBuffer cannot have negative or zero capacity.", nameof(capacity));
}
if (items == null)
{
throw new ArgumentNullException(nameof(items));
}
if (items.Length > capacity)
{
throw new ArgumentException("Too many items to fit RcCyclicBuffer", nameof(items));
}
_buffer = new T[capacity];
Array.Copy(items, _buffer, items.Length);
_size = items.Length;
_start = 0;
_end = _size == capacity ? 0 : _size;
}
public int Capacity => _buffer.Length;
public bool IsFull => Size == Capacity;
public bool IsEmpty => Size == 0;
public int Size => _size;
public T Front()
{
ThrowIfEmpty();
return _buffer[_start];
}
public T Back()
{
ThrowIfEmpty();
return _buffer[(_end != 0 ? _end : Capacity) - 1];
}
public T this[int index]
{
get
{
if (IsEmpty)
{
throw new IndexOutOfRangeException($"Cannot access index {index}. Buffer is empty");
}
if (index >= _size)
{
throw new IndexOutOfRangeException($"Cannot access index {index}. Buffer size is {_size}");
}
int actualIndex = InternalIndex(index);
return _buffer[actualIndex];
}
set
{
if (IsEmpty)
{
throw new IndexOutOfRangeException($"Cannot access index {index}. Buffer is empty");
}
if (index >= _size)
{
throw new IndexOutOfRangeException($"Cannot access index {index}. Buffer size is {_size}");
}
int actualIndex = InternalIndex(index);
_buffer[actualIndex] = value;
}
}
public void PushBack(T item)
{
if (IsFull)
{
_buffer[_end] = item;
Increment(ref _end);
_start = _end;
}
else
{
_buffer[_end] = item;
Increment(ref _end);
++_size;
}
}
public void PushFront(T item)
{
if (IsFull)
{
Decrement(ref _start);
_end = _start;
_buffer[_start] = item;
}
else
{
Decrement(ref _start);
_buffer[_start] = item;
++_size;
}
}
public void PopBack()
{
ThrowIfEmpty("Cannot take elements from an empty buffer.");
Decrement(ref _end);
_buffer[_end] = default(T);
--_size;
}
public void PopFront()
{
ThrowIfEmpty("Cannot take elements from an empty buffer.");
_buffer[_start] = default(T);
Increment(ref _start);
--_size;
}
public void Clear()
{
// to clear we just reset everything.
_start = 0;
_end = 0;
_size = 0;
Array.Clear(_buffer, 0, _buffer.Length);
}
public T[] ToArray()
{
T[] newArray = new T[Size];
CopyTo(newArray);
return newArray;
}
public void CopyTo(Span<T> destination)
{
var span1 = ArrayOne();
span1.CopyTo(destination);
ArrayTwo().CopyTo(destination[span1.Length..]);
}
private void ThrowIfEmpty(string message = "Cannot access an empty buffer.")
{
if (IsEmpty)
{
throw new InvalidOperationException(message);
}
}
private void Increment(ref int index)
{
if (++index == Capacity)
{
index = 0;
}
}
private void Decrement(ref int index)
{
if (index == 0)
{
index = Capacity;
}
index--;
}
private int InternalIndex(int index)
{
return _start + (index < (Capacity - _start)
? index
: index - Capacity);
}
internal Span<T> ArrayOne()
{
if (IsEmpty)
{
return new Span<T>(Array.Empty<T>());
}
if (_start < _end)
{
return new Span<T>(_buffer, _start, _end - _start);
}
return new Span<T>(_buffer, _start, _buffer.Length - _start);
}
internal Span<T> ArrayTwo()
{
if (IsEmpty)
{
return new Span<T>(Array.Empty<T>());
}
if (_start < _end)
{
return new Span<T>(_buffer, _end, 0);
}
return new Span<T>(_buffer, 0, _end);
}
public Enumerator GetEnumerator() => new Enumerator(this);
IEnumerator<T> IEnumerable<T>.GetEnumerator() => GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1e9219e3d1874d829d9d3ed342f36981
timeCreated: 1715335324

View File

@@ -0,0 +1,120 @@
using System;
using System.Numerics;
using System.Runtime.InteropServices;
using JNGame.Math;
namespace DotRecast.Core.Buffers
{
public static class RcCyclicBuffers
{
public static long Sum(this ReadOnlySpan<long> source)
{
var buffer = source;
var result = 0L;
if (Vector.IsHardwareAccelerated)
{
var vectors = MemoryMarshal.Cast<long, Vector<long>>(buffer);
var vecSum = Vector<long>.Zero;
foreach (var vec in vectors)
vecSum += vec;
result = Vector.Dot(vecSum, Vector<long>.One);
var remainder = source.Length % Vector<long>.Count;
buffer = buffer[^remainder..];
}
foreach (var val in buffer)
result += val;
return result;
}
public static LFloat Average(this ReadOnlySpan<long> source)
{
if (0 >= source.Length)
return 0;
return source.Sum() / (LFloat)source.Length;
}
private static long Min(this ReadOnlySpan<long> source)
{
var buffer = source;
var result = long.MaxValue;
if (Vector.IsHardwareAccelerated)
{
var vectors = MemoryMarshal.Cast<long, Vector<long>>(buffer);
var vecMin = Vector<long>.One * result;
foreach (var vec in vectors)
vecMin = Vector.Min(vecMin, vec);
for (int i = 0; i < Vector<long>.Count; i++)
result = LMath.Min(result, vecMin[i]);
var remainder = source.Length % Vector<long>.Count;
buffer = buffer[^remainder..];
}
foreach (var val in buffer)
result = LMath.Min(result, val);
return result;
}
private static long Max(this ReadOnlySpan<long> source)
{
var buffer = source;
var result = long.MinValue;
if (Vector.IsHardwareAccelerated)
{
var vectors = MemoryMarshal.Cast<long, Vector<long>>(buffer);
var vecMax = Vector<long>.One * result;
foreach (var vec in vectors)
vecMax = Vector.Max(vecMax, vec);
for (int i = 0; i < Vector<long>.Count; i++)
result = LMath.Max(result, vecMax[i]);
var remainder = source.Length % Vector<long>.Count;
buffer = buffer[^remainder..];
}
foreach (var val in buffer)
result = LMath.Max(result, val);
return result;
}
public static long Sum(this RcCyclicBuffer<long> source)
{
return Sum(source.ArrayOne()) + Sum(source.ArrayTwo());
}
public static LFloat Average(this RcCyclicBuffer<long> source)
{
return Sum(source) / (LFloat)source.Size;
}
public static long Min(this RcCyclicBuffer<long> source)
{
var firstHalf = source.ArrayOne();
var secondHalf = source.ArrayTwo();
var a = firstHalf.Length > 0 ? Min(firstHalf) : long.MaxValue;
var b = secondHalf.Length > 0 ? Min(secondHalf) : long.MaxValue;
return LMath.Min(a, b);
}
public static long Max(this RcCyclicBuffer<long> source)
{
var firstHalf = source.ArrayOne();
var secondHalf = source.ArrayTwo();
var a = firstHalf.Length > 0 ? Max(firstHalf) : long.MinValue;
var b = secondHalf.Length > 0 ? Max(secondHalf) : long.MinValue;
return LMath.Max(a, b);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2feb2734ce084ed78c3ed26b729eaddb
timeCreated: 1715335324

View File

@@ -0,0 +1,57 @@
using System;
using System.Buffers;
using System.Runtime.CompilerServices;
namespace DotRecast.Core.Buffers
{
public static class RcRentedArray
{
public static RcRentedArray<T> Rent<T>(int minimumLength)
{
var array = ArrayPool<T>.Shared.Rent(minimumLength);
return new RcRentedArray<T>(ArrayPool<T>.Shared, array, minimumLength);
}
}
public class RcRentedArray<T> : IDisposable
{
private ArrayPool<T> _owner;
private T[] _array;
public int Length { get; }
public bool IsDisposed => null == _owner || null == _array;
internal RcRentedArray(ArrayPool<T> owner, T[] array, int length)
{
_owner = owner;
_array = array;
Length = length;
}
public ref T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
return ref _array[index];
}
}
public T[] AsArray()
{
return _array;
}
public void Dispose()
{
if (null != _owner && null != _array)
{
_owner.Return(_array, true);
_owner = null;
_array = null;
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1d2bbd30d7a14dedb1d02ec3dfc84549
timeCreated: 1715335324

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d39a1676557d4a07b4132cfda6597a2f
timeCreated: 1715335324

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
namespace DotRecast.Core.Collections
{
public static class CollectionExtensions
{
/// Sorts the given data in-place using insertion sort.
///
/// @param data The data to sort
/// @param dataLength The number of elements in @p data
public static void InsertSort(this int[] data)
{
for (int valueIndex = 1; valueIndex < data.Length; valueIndex++)
{
int value = data[valueIndex];
int insertionIndex;
for (insertionIndex = valueIndex - 1; insertionIndex >= 0 && data[insertionIndex] > value; insertionIndex--)
{
// Shift over values
data[insertionIndex + 1] = data[insertionIndex];
}
// Insert the value in sorted order.
data[insertionIndex + 1] = value;
}
}
public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action)
{
foreach (var item in collection)
{
action.Invoke(item);
}
}
public static void Shuffle<T>(this IList<T> list)
{
JNGame.Math.Random random = new JNGame.Math.Random();
int n = list.Count;
while (n > 1)
{
n--;
int k = random.Next(n + 1);
(list[k], list[n]) = (list[n], list[k]);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 20942d7eee5249cf846b3249f705095b
timeCreated: 1715335324

View File

@@ -0,0 +1,83 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace DotRecast.Core.Collections
{
public readonly partial struct RcImmutableArray<T>
{
public IEnumerator<T> GetEnumerator()
{
return EnumeratorObject.Create(_array);
}
IEnumerator IEnumerable.GetEnumerator()
{
return EnumeratorObject.Create(_array);
}
private sealed class EnumeratorObject : IEnumerator<T>
{
private static readonly IEnumerator<T> EmptyEnumerator = new EnumeratorObject(Empty._array!);
private readonly T[] _array;
private int _index;
internal static IEnumerator<T> Create(T[] array)
{
if (array.Length != 0)
{
return new EnumeratorObject(array);
}
else
{
return EmptyEnumerator;
}
}
private EnumeratorObject(T[] array)
{
_index = -1;
_array = array;
}
public T Current
{
get
{
if (unchecked((uint)_index) < (uint)_array.Length)
{
return _array[_index];
}
throw new InvalidOperationException();
}
}
object IEnumerator.Current => this.Current;
public void Dispose()
{
}
public bool MoveNext()
{
int newIndex = _index + 1;
int length = _array.Length;
if ((uint)newIndex <= (uint)length)
{
_index = newIndex;
return (uint)newIndex < (uint)length;
}
return false;
}
void IEnumerator.Reset()
{
_index = -1;
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a8ad3ba1cbae49ff97ae32d0a104b439
timeCreated: 1715335324

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
namespace DotRecast.Core.Collections
{
public readonly partial struct RcImmutableArray<T> : IList<T>
{
public int Count => Length;
public bool IsReadOnly => true;
T IList<T>.this[int index]
{
get
{
var self = this;
return self[index];
}
set => throw new NotSupportedException();
}
public int IndexOf(T item)
{
for (int i = 0; i < Count; ++i)
{
if (_array![i].Equals(item))
return i;
}
return -1;
}
public bool Contains(T item)
{
return IndexOf(item) >= 0;
}
public void CopyTo(T[] array, int arrayIndex)
{
var self = this;
RcArrays.Copy(self._array!, 0, array, arrayIndex, self.Length);
}
public void Add(T item)
{
throw new NotSupportedException();
}
public void Clear()
{
throw new NotSupportedException();
}
public bool Remove(T item)
{
throw new NotSupportedException();
}
public void Insert(int index, T item)
{
throw new NotSupportedException();
}
public void RemoveAt(int index)
{
throw new NotSupportedException();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 10969565c461452babaab57192ab7b27
timeCreated: 1715335324

View File

@@ -0,0 +1,19 @@
namespace DotRecast.Core.Collections
{
public readonly partial struct RcImmutableArray<T>
{
#pragma warning disable CA1825
public static readonly RcImmutableArray<T> Empty = new RcImmutableArray<T>(new T[0]);
#pragma warning restore CA1825
private readonly T[] _array;
internal RcImmutableArray(T[] items)
{
_array = items;
}
public T this[int index] => _array![index];
public int Length => _array!.Length;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9da9862cffc84b6ea948ddd33a266734
timeCreated: 1715335324

View File

@@ -0,0 +1,48 @@
using System;
namespace DotRecast.Core.Collections
{
public static class RcImmutableArray
{
public static RcImmutableArray<T> Create<T>()
{
return RcImmutableArray<T>.Empty;
}
public static RcImmutableArray<T> Create<T>(T item1)
{
T[] array = new[] { item1 };
return new RcImmutableArray<T>(array);
}
public static RcImmutableArray<T> Create<T>(T item1, T item2)
{
T[] array = new[] { item1, item2 };
return new RcImmutableArray<T>(array);
}
public static RcImmutableArray<T> Create<T>(T item1, T item2, T item3)
{
T[] array = new[] { item1, item2, item3 };
return new RcImmutableArray<T>(array);
}
public static RcImmutableArray<T> Create<T>(T item1, T item2, T item3, T item4)
{
T[] array = new[] { item1, item2, item3, item4 };
return new RcImmutableArray<T>(array);
}
public static RcImmutableArray<T> Create<T>(params T[] items)
{
if (items == null || items.Length == 0)
{
return RcImmutableArray<T>.Empty;
}
var tmp = new T[items.Length];
RcArrays.Copy(items, tmp, items.Length);
return new RcImmutableArray<T>(tmp);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 791dfec48cc5499488a03342e775c818
timeCreated: 1715335324

View File

@@ -0,0 +1,108 @@
/*
Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org
DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
using System;
using System.Collections.Generic;
namespace DotRecast.Core.Collections
{
public class RcSortedQueue<T>
{
private bool _dirty;
private readonly List<T> _items;
private readonly Comparer<T> _comparer;
public RcSortedQueue(Comparison<T> comp)
{
_items = new List<T>();
_comparer = Comparer<T>.Create((x, y) => comp.Invoke(x, y) * -1);
}
public int Count()
{
return _items.Count;
}
public bool IsEmpty()
{
return 0 == _items.Count;
}
public void Clear()
{
_items.Clear();
_dirty = false;
}
private void Balance()
{
if (_dirty)
{
_items.Sort(_comparer); // reverse
_dirty = false;
}
}
public T Peek()
{
Balance();
return _items[^1];
}
public T Dequeue()
{
var node = Peek();
_items.RemoveAt(_items.Count - 1);
return node;
}
public void Enqueue(T item)
{
if (null == item)
return;
_items.Add(item);
_dirty = true;
}
public bool Remove(T item)
{
if (null == item)
return false;
//int idx = _items.BinarySearch(item, _comparer); // don't use this! Because reference types can be reused externally.
int idx = _items.FindLastIndex(x => item.Equals(x));
if (0 > idx)
return false;
_items.RemoveAt(idx);
return true;
}
public List<T> ToList()
{
Balance();
var temp = new List<T>(_items);
temp.Reverse();
return temp;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6099a4d887984cdcbdea9ac5381be246
timeCreated: 1715335324

View File

@@ -0,0 +1,421 @@
using System;
using System.Runtime.CompilerServices;
namespace DotRecast.Core.Collections
{
public struct RcStackArray128<T>
{
public static RcStackArray128<T> Empty => new RcStackArray128<T>();
private const int Size = 128;
public int Length => Size;
public T V0;
public T V1;
public T V2;
public T V3;
public T V4;
public T V5;
public T V6;
public T V7;
public T V8;
public T V9;
public T V10;
public T V11;
public T V12;
public T V13;
public T V14;
public T V15;
public T V16;
public T V17;
public T V18;
public T V19;
public T V20;
public T V21;
public T V22;
public T V23;
public T V24;
public T V25;
public T V26;
public T V27;
public T V28;
public T V29;
public T V30;
public T V31;
public T V32;
public T V33;
public T V34;
public T V35;
public T V36;
public T V37;
public T V38;
public T V39;
public T V40;
public T V41;
public T V42;
public T V43;
public T V44;
public T V45;
public T V46;
public T V47;
public T V48;
public T V49;
public T V50;
public T V51;
public T V52;
public T V53;
public T V54;
public T V55;
public T V56;
public T V57;
public T V58;
public T V59;
public T V60;
public T V61;
public T V62;
public T V63;
public T V64;
public T V65;
public T V66;
public T V67;
public T V68;
public T V69;
public T V70;
public T V71;
public T V72;
public T V73;
public T V74;
public T V75;
public T V76;
public T V77;
public T V78;
public T V79;
public T V80;
public T V81;
public T V82;
public T V83;
public T V84;
public T V85;
public T V86;
public T V87;
public T V88;
public T V89;
public T V90;
public T V91;
public T V92;
public T V93;
public T V94;
public T V95;
public T V96;
public T V97;
public T V98;
public T V99;
public T V100;
public T V101;
public T V102;
public T V103;
public T V104;
public T V105;
public T V106;
public T V107;
public T V108;
public T V109;
public T V110;
public T V111;
public T V112;
public T V113;
public T V114;
public T V115;
public T V116;
public T V117;
public T V118;
public T V119;
public T V120;
public T V121;
public T V122;
public T V123;
public T V124;
public T V125;
public T V126;
public T V127;
public T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
return index switch
{
0 => V0,
1 => V1,
2 => V2,
3 => V3,
4 => V4,
5 => V5,
6 => V6,
7 => V7,
8 => V8,
9 => V9,
10 => V10,
11 => V11,
12 => V12,
13 => V13,
14 => V14,
15 => V15,
16 => V16,
17 => V17,
18 => V18,
19 => V19,
20 => V20,
21 => V21,
22 => V22,
23 => V23,
24 => V24,
25 => V25,
26 => V26,
27 => V27,
28 => V28,
29 => V29,
30 => V30,
31 => V31,
32 => V32,
33 => V33,
34 => V34,
35 => V35,
36 => V36,
37 => V37,
38 => V38,
39 => V39,
40 => V40,
41 => V41,
42 => V42,
43 => V43,
44 => V44,
45 => V45,
46 => V46,
47 => V47,
48 => V48,
49 => V49,
50 => V50,
51 => V51,
52 => V52,
53 => V53,
54 => V54,
55 => V55,
56 => V56,
57 => V57,
58 => V58,
59 => V59,
60 => V60,
61 => V61,
62 => V62,
63 => V63,
64 => V64,
65 => V65,
66 => V66,
67 => V67,
68 => V68,
69 => V69,
70 => V70,
71 => V71,
72 => V72,
73 => V73,
74 => V74,
75 => V75,
76 => V76,
77 => V77,
78 => V78,
79 => V79,
80 => V80,
81 => V81,
82 => V82,
83 => V83,
84 => V84,
85 => V85,
86 => V86,
87 => V87,
88 => V88,
89 => V89,
90 => V90,
91 => V91,
92 => V92,
93 => V93,
94 => V94,
95 => V95,
96 => V96,
97 => V97,
98 => V98,
99 => V99,
100 => V100,
101 => V101,
102 => V102,
103 => V103,
104 => V104,
105 => V105,
106 => V106,
107 => V107,
108 => V108,
109 => V109,
110 => V110,
111 => V111,
112 => V112,
113 => V113,
114 => V114,
115 => V115,
116 => V116,
117 => V117,
118 => V118,
119 => V119,
120 => V120,
121 => V121,
122 => V122,
123 => V123,
124 => V124,
125 => V125,
126 => V126,
127 => V127,
_ => throw new ArgumentOutOfRangeException(nameof(index), index, null)
};
}
set
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
switch (index)
{
case 0: V0 = value; break;
case 1: V1 = value; break;
case 2: V2 = value; break;
case 3: V3 = value; break;
case 4: V4 = value; break;
case 5: V5 = value; break;
case 6: V6 = value; break;
case 7: V7 = value; break;
case 8: V8 = value; break;
case 9: V9 = value; break;
case 10: V10 = value; break;
case 11: V11 = value; break;
case 12: V12 = value; break;
case 13: V13 = value; break;
case 14: V14 = value; break;
case 15: V15 = value; break;
case 16: V16 = value; break;
case 17: V17 = value; break;
case 18: V18 = value; break;
case 19: V19 = value; break;
case 20: V20 = value; break;
case 21: V21 = value; break;
case 22: V22 = value; break;
case 23: V23 = value; break;
case 24: V24 = value; break;
case 25: V25 = value; break;
case 26: V26 = value; break;
case 27: V27 = value; break;
case 28: V28 = value; break;
case 29: V29 = value; break;
case 30: V30 = value; break;
case 31: V31 = value; break;
case 32 : V32 = value; break;
case 33 : V33 = value; break;
case 34 : V34 = value; break;
case 35 : V35 = value; break;
case 36 : V36 = value; break;
case 37 : V37 = value; break;
case 38 : V38 = value; break;
case 39 : V39 = value; break;
case 40 : V40 = value; break;
case 41 : V41 = value; break;
case 42 : V42 = value; break;
case 43 : V43 = value; break;
case 44 : V44 = value; break;
case 45 : V45 = value; break;
case 46 : V46 = value; break;
case 47 : V47 = value; break;
case 48 : V48 = value; break;
case 49 : V49 = value; break;
case 50 : V50 = value; break;
case 51 : V51 = value; break;
case 52 : V52 = value; break;
case 53 : V53 = value; break;
case 54 : V54 = value; break;
case 55 : V55 = value; break;
case 56 : V56 = value; break;
case 57 : V57 = value; break;
case 58 : V58 = value; break;
case 59 : V59 = value; break;
case 60 : V60 = value; break;
case 61 : V61 = value; break;
case 62 : V62 = value; break;
case 63 : V63 = value; break;
case 64 : V64 = value; break;
case 65 : V65 = value; break;
case 66 : V66 = value; break;
case 67 : V67 = value; break;
case 68 : V68 = value; break;
case 69 : V69 = value; break;
case 70 : V70 = value; break;
case 71 : V71 = value; break;
case 72 : V72 = value; break;
case 73 : V73 = value; break;
case 74 : V74 = value; break;
case 75 : V75 = value; break;
case 76 : V76 = value; break;
case 77 : V77 = value; break;
case 78 : V78 = value; break;
case 79 : V79 = value; break;
case 80 : V80 = value; break;
case 81 : V81 = value; break;
case 82 : V82 = value; break;
case 83 : V83 = value; break;
case 84 : V84 = value; break;
case 85 : V85 = value; break;
case 86 : V86 = value; break;
case 87 : V87 = value; break;
case 88 : V88 = value; break;
case 89 : V89 = value; break;
case 90 : V90 = value; break;
case 91 : V91 = value; break;
case 92 : V92 = value; break;
case 93 : V93 = value; break;
case 94 : V94 = value; break;
case 95 : V95 = value; break;
case 96 : V96 = value; break;
case 97 : V97 = value; break;
case 98 : V98 = value; break;
case 99 : V99 = value; break;
case 100 : V100 = value; break;
case 101 : V101 = value; break;
case 102 : V102 = value; break;
case 103 : V103 = value; break;
case 104 : V104 = value; break;
case 105 : V105 = value; break;
case 106 : V106 = value; break;
case 107 : V107 = value; break;
case 108 : V108 = value; break;
case 109 : V109 = value; break;
case 110 : V110 = value; break;
case 111 : V111 = value; break;
case 112 : V112 = value; break;
case 113 : V113 = value; break;
case 114 : V114 = value; break;
case 115 : V115 = value; break;
case 116 : V116 = value; break;
case 117 : V117 = value; break;
case 118 : V118 = value; break;
case 119 : V119 = value; break;
case 120 : V120 = value; break;
case 121 : V121 = value; break;
case 122 : V122 = value; break;
case 123 : V123 = value; break;
case 124 : V124 = value; break;
case 125 : V125 = value; break;
case 126 : V126 = value; break;
case 127 : V127 = value; break;
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f8538d9529264580a5d63414beb6cdf1
timeCreated: 1715335324

View File

@@ -0,0 +1,85 @@
using System;
using System.Runtime.CompilerServices;
namespace DotRecast.Core.Collections
{
public struct RcStackArray16<T>
{
public static RcStackArray16<T> Empty => new RcStackArray16<T>();
private const int Size = 16;
public int Length => Size;
public T V0;
public T V1;
public T V2;
public T V3;
public T V4;
public T V5;
public T V6;
public T V7;
public T V8;
public T V9;
public T V10;
public T V11;
public T V12;
public T V13;
public T V14;
public T V15;
public T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
return index switch
{
0 => V0,
1 => V1,
2 => V2,
3 => V3,
4 => V4,
5 => V5,
6 => V6,
7 => V7,
8 => V8,
9 => V9,
10 => V10,
11 => V11,
12 => V12,
13 => V13,
14 => V14,
15 => V15,
_ => throw new IndexOutOfRangeException($"{index}")
};
}
set
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
switch (index)
{
case 0: V0 = value; break;
case 1: V1 = value; break;
case 2: V2 = value; break;
case 3: V3 = value; break;
case 4: V4 = value; break;
case 5: V5 = value; break;
case 6: V6 = value; break;
case 7: V7 = value; break;
case 8: V8 = value; break;
case 9: V9 = value; break;
case 10: V10 = value; break;
case 11: V11 = value; break;
case 12: V12 = value; break;
case 13: V13 = value; break;
case 14: V14 = value; break;
case 15: V15 = value; break;
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4f3790702aac4786911ba2d61020bec1
timeCreated: 1715335324

View File

@@ -0,0 +1,43 @@
using System;
using System.Runtime.CompilerServices;
namespace DotRecast.Core.Collections
{
public struct RcStackArray2<T>
{
public static RcStackArray2<T> Empty => new RcStackArray2<T>();
private const int Size = 2;
public int Length => Size;
public T V0;
public T V1;
public T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
return index switch
{
0 => V0,
1 => V1,
_ => throw new IndexOutOfRangeException($"{index}")
};
}
set
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
switch (index)
{
case 0: V0 = value; break;
case 1: V1 = value; break;
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: add4a773088941a2a12c0e026aea9f5f
timeCreated: 1715335324

View File

@@ -0,0 +1,805 @@
using System;
using System.Runtime.CompilerServices;
namespace DotRecast.Core.Collections
{
public struct RcStackArray256<T>
{
public static RcStackArray256<T> Empty => new RcStackArray256<T>();
private const int Size = 256;
public int Length => Size;
public T V0;
public T V1;
public T V2;
public T V3;
public T V4;
public T V5;
public T V6;
public T V7;
public T V8;
public T V9;
public T V10;
public T V11;
public T V12;
public T V13;
public T V14;
public T V15;
public T V16;
public T V17;
public T V18;
public T V19;
public T V20;
public T V21;
public T V22;
public T V23;
public T V24;
public T V25;
public T V26;
public T V27;
public T V28;
public T V29;
public T V30;
public T V31;
public T V32;
public T V33;
public T V34;
public T V35;
public T V36;
public T V37;
public T V38;
public T V39;
public T V40;
public T V41;
public T V42;
public T V43;
public T V44;
public T V45;
public T V46;
public T V47;
public T V48;
public T V49;
public T V50;
public T V51;
public T V52;
public T V53;
public T V54;
public T V55;
public T V56;
public T V57;
public T V58;
public T V59;
public T V60;
public T V61;
public T V62;
public T V63;
public T V64;
public T V65;
public T V66;
public T V67;
public T V68;
public T V69;
public T V70;
public T V71;
public T V72;
public T V73;
public T V74;
public T V75;
public T V76;
public T V77;
public T V78;
public T V79;
public T V80;
public T V81;
public T V82;
public T V83;
public T V84;
public T V85;
public T V86;
public T V87;
public T V88;
public T V89;
public T V90;
public T V91;
public T V92;
public T V93;
public T V94;
public T V95;
public T V96;
public T V97;
public T V98;
public T V99;
public T V100;
public T V101;
public T V102;
public T V103;
public T V104;
public T V105;
public T V106;
public T V107;
public T V108;
public T V109;
public T V110;
public T V111;
public T V112;
public T V113;
public T V114;
public T V115;
public T V116;
public T V117;
public T V118;
public T V119;
public T V120;
public T V121;
public T V122;
public T V123;
public T V124;
public T V125;
public T V126;
public T V127;
public T V128;
public T V129;
public T V130;
public T V131;
public T V132;
public T V133;
public T V134;
public T V135;
public T V136;
public T V137;
public T V138;
public T V139;
public T V140;
public T V141;
public T V142;
public T V143;
public T V144;
public T V145;
public T V146;
public T V147;
public T V148;
public T V149;
public T V150;
public T V151;
public T V152;
public T V153;
public T V154;
public T V155;
public T V156;
public T V157;
public T V158;
public T V159;
public T V160;
public T V161;
public T V162;
public T V163;
public T V164;
public T V165;
public T V166;
public T V167;
public T V168;
public T V169;
public T V170;
public T V171;
public T V172;
public T V173;
public T V174;
public T V175;
public T V176;
public T V177;
public T V178;
public T V179;
public T V180;
public T V181;
public T V182;
public T V183;
public T V184;
public T V185;
public T V186;
public T V187;
public T V188;
public T V189;
public T V190;
public T V191;
public T V192;
public T V193;
public T V194;
public T V195;
public T V196;
public T V197;
public T V198;
public T V199;
public T V200;
public T V201;
public T V202;
public T V203;
public T V204;
public T V205;
public T V206;
public T V207;
public T V208;
public T V209;
public T V210;
public T V211;
public T V212;
public T V213;
public T V214;
public T V215;
public T V216;
public T V217;
public T V218;
public T V219;
public T V220;
public T V221;
public T V222;
public T V223;
public T V224;
public T V225;
public T V226;
public T V227;
public T V228;
public T V229;
public T V230;
public T V231;
public T V232;
public T V233;
public T V234;
public T V235;
public T V236;
public T V237;
public T V238;
public T V239;
public T V240;
public T V241;
public T V242;
public T V243;
public T V244;
public T V245;
public T V246;
public T V247;
public T V248;
public T V249;
public T V250;
public T V251;
public T V252;
public T V253;
public T V254;
public T V255;
public T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
return index switch
{
0 => V0,
1 => V1,
2 => V2,
3 => V3,
4 => V4,
5 => V5,
6 => V6,
7 => V7,
8 => V8,
9 => V9,
10 => V10,
11 => V11,
12 => V12,
13 => V13,
14 => V14,
15 => V15,
16 => V16,
17 => V17,
18 => V18,
19 => V19,
20 => V20,
21 => V21,
22 => V22,
23 => V23,
24 => V24,
25 => V25,
26 => V26,
27 => V27,
28 => V28,
29 => V29,
30 => V30,
31 => V31,
32 => V32,
33 => V33,
34 => V34,
35 => V35,
36 => V36,
37 => V37,
38 => V38,
39 => V39,
40 => V40,
41 => V41,
42 => V42,
43 => V43,
44 => V44,
45 => V45,
46 => V46,
47 => V47,
48 => V48,
49 => V49,
50 => V50,
51 => V51,
52 => V52,
53 => V53,
54 => V54,
55 => V55,
56 => V56,
57 => V57,
58 => V58,
59 => V59,
60 => V60,
61 => V61,
62 => V62,
63 => V63,
64 => V64,
65 => V65,
66 => V66,
67 => V67,
68 => V68,
69 => V69,
70 => V70,
71 => V71,
72 => V72,
73 => V73,
74 => V74,
75 => V75,
76 => V76,
77 => V77,
78 => V78,
79 => V79,
80 => V80,
81 => V81,
82 => V82,
83 => V83,
84 => V84,
85 => V85,
86 => V86,
87 => V87,
88 => V88,
89 => V89,
90 => V90,
91 => V91,
92 => V92,
93 => V93,
94 => V94,
95 => V95,
96 => V96,
97 => V97,
98 => V98,
99 => V99,
100 => V100,
101 => V101,
102 => V102,
103 => V103,
104 => V104,
105 => V105,
106 => V106,
107 => V107,
108 => V108,
109 => V109,
110 => V110,
111 => V111,
112 => V112,
113 => V113,
114 => V114,
115 => V115,
116 => V116,
117 => V117,
118 => V118,
119 => V119,
120 => V120,
121 => V121,
122 => V122,
123 => V123,
124 => V124,
125 => V125,
126 => V126,
127 => V127,
128 => V128,
129 => V129,
130 => V130,
131 => V131,
132 => V132,
133 => V133,
134 => V134,
135 => V135,
136 => V136,
137 => V137,
138 => V138,
139 => V139,
140 => V140,
141 => V141,
142 => V142,
143 => V143,
144 => V144,
145 => V145,
146 => V146,
147 => V147,
148 => V148,
149 => V149,
150 => V150,
151 => V151,
152 => V152,
153 => V153,
154 => V154,
155 => V155,
156 => V156,
157 => V157,
158 => V158,
159 => V159,
160 => V160,
161 => V161,
162 => V162,
163 => V163,
164 => V164,
165 => V165,
166 => V166,
167 => V167,
168 => V168,
169 => V169,
170 => V170,
171 => V171,
172 => V172,
173 => V173,
174 => V174,
175 => V175,
176 => V176,
177 => V177,
178 => V178,
179 => V179,
180 => V180,
181 => V181,
182 => V182,
183 => V183,
184 => V184,
185 => V185,
186 => V186,
187 => V187,
188 => V188,
189 => V189,
190 => V190,
191 => V191,
192 => V192,
193 => V193,
194 => V194,
195 => V195,
196 => V196,
197 => V197,
198 => V198,
199 => V199,
200 => V200,
201 => V201,
202 => V202,
203 => V203,
204 => V204,
205 => V205,
206 => V206,
207 => V207,
208 => V208,
209 => V209,
210 => V210,
211 => V211,
212 => V212,
213 => V213,
214 => V214,
215 => V215,
216 => V216,
217 => V217,
218 => V218,
219 => V219,
220 => V220,
221 => V221,
222 => V222,
223 => V223,
224 => V224,
225 => V225,
226 => V226,
227 => V227,
228 => V228,
229 => V229,
230 => V230,
231 => V231,
232 => V232,
233 => V233,
234 => V234,
235 => V235,
236 => V236,
237 => V237,
238 => V238,
239 => V239,
240 => V240,
241 => V241,
242 => V242,
243 => V243,
244 => V244,
245 => V245,
246 => V246,
247 => V247,
248 => V248,
249 => V249,
250 => V250,
251 => V251,
252 => V252,
253 => V253,
254 => V254,
255 => V255,
_ => throw new ArgumentOutOfRangeException(nameof(index), index, null)
};
}
set
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
switch (index)
{
case 0: V0 = value; break;
case 1: V1 = value; break;
case 2: V2 = value; break;
case 3: V3 = value; break;
case 4: V4 = value; break;
case 5: V5 = value; break;
case 6: V6 = value; break;
case 7: V7 = value; break;
case 8: V8 = value; break;
case 9: V9 = value; break;
case 10: V10 = value; break;
case 11: V11 = value; break;
case 12: V12 = value; break;
case 13: V13 = value; break;
case 14: V14 = value; break;
case 15: V15 = value; break;
case 16: V16 = value; break;
case 17: V17 = value; break;
case 18: V18 = value; break;
case 19: V19 = value; break;
case 20: V20 = value; break;
case 21: V21 = value; break;
case 22: V22 = value; break;
case 23: V23 = value; break;
case 24: V24 = value; break;
case 25: V25 = value; break;
case 26: V26 = value; break;
case 27: V27 = value; break;
case 28: V28 = value; break;
case 29: V29 = value; break;
case 30: V30 = value; break;
case 31: V31 = value; break;
case 32: V32 = value; break;
case 33: V33 = value; break;
case 34: V34 = value; break;
case 35: V35 = value; break;
case 36: V36 = value; break;
case 37: V37 = value; break;
case 38: V38 = value; break;
case 39: V39 = value; break;
case 40: V40 = value; break;
case 41: V41 = value; break;
case 42: V42 = value; break;
case 43: V43 = value; break;
case 44: V44 = value; break;
case 45: V45 = value; break;
case 46: V46 = value; break;
case 47: V47 = value; break;
case 48: V48 = value; break;
case 49: V49 = value; break;
case 50: V50 = value; break;
case 51: V51 = value; break;
case 52: V52 = value; break;
case 53: V53 = value; break;
case 54: V54 = value; break;
case 55: V55 = value; break;
case 56: V56 = value; break;
case 57: V57 = value; break;
case 58: V58 = value; break;
case 59: V59 = value; break;
case 60: V60 = value; break;
case 61: V61 = value; break;
case 62: V62 = value; break;
case 63: V63 = value; break;
case 64: V64 = value; break;
case 65: V65 = value; break;
case 66: V66 = value; break;
case 67: V67 = value; break;
case 68: V68 = value; break;
case 69: V69 = value; break;
case 70: V70 = value; break;
case 71: V71 = value; break;
case 72: V72 = value; break;
case 73: V73 = value; break;
case 74: V74 = value; break;
case 75: V75 = value; break;
case 76: V76 = value; break;
case 77: V77 = value; break;
case 78: V78 = value; break;
case 79: V79 = value; break;
case 80: V80 = value; break;
case 81: V81 = value; break;
case 82: V82 = value; break;
case 83: V83 = value; break;
case 84: V84 = value; break;
case 85: V85 = value; break;
case 86: V86 = value; break;
case 87: V87 = value; break;
case 88: V88 = value; break;
case 89: V89 = value; break;
case 90: V90 = value; break;
case 91: V91 = value; break;
case 92: V92 = value; break;
case 93: V93 = value; break;
case 94: V94 = value; break;
case 95: V95 = value; break;
case 96: V96 = value; break;
case 97: V97 = value; break;
case 98: V98 = value; break;
case 99: V99 = value; break;
case 100: V100 = value; break;
case 101: V101 = value; break;
case 102: V102 = value; break;
case 103: V103 = value; break;
case 104: V104 = value; break;
case 105: V105 = value; break;
case 106: V106 = value; break;
case 107: V107 = value; break;
case 108: V108 = value; break;
case 109: V109 = value; break;
case 110: V110 = value; break;
case 111: V111 = value; break;
case 112: V112 = value; break;
case 113: V113 = value; break;
case 114: V114 = value; break;
case 115: V115 = value; break;
case 116: V116 = value; break;
case 117: V117 = value; break;
case 118: V118 = value; break;
case 119: V119 = value; break;
case 120: V120 = value; break;
case 121: V121 = value; break;
case 122: V122 = value; break;
case 123: V123 = value; break;
case 124: V124 = value; break;
case 125: V125 = value; break;
case 126: V126 = value; break;
case 127: V127 = value; break;
case 128: V128 = value; break;
case 129: V129 = value; break;
case 130: V130 = value; break;
case 131: V131 = value; break;
case 132: V132 = value; break;
case 133: V133 = value; break;
case 134: V134 = value; break;
case 135: V135 = value; break;
case 136: V136 = value; break;
case 137: V137 = value; break;
case 138: V138 = value; break;
case 139: V139 = value; break;
case 140: V140 = value; break;
case 141: V141 = value; break;
case 142: V142 = value; break;
case 143: V143 = value; break;
case 144: V144 = value; break;
case 145: V145 = value; break;
case 146: V146 = value; break;
case 147: V147 = value; break;
case 148: V148 = value; break;
case 149: V149 = value; break;
case 150: V150 = value; break;
case 151: V151 = value; break;
case 152: V152 = value; break;
case 153: V153 = value; break;
case 154: V154 = value; break;
case 155: V155 = value; break;
case 156: V156 = value; break;
case 157: V157 = value; break;
case 158: V158 = value; break;
case 159: V159 = value; break;
case 160: V160 = value; break;
case 161: V161 = value; break;
case 162: V162 = value; break;
case 163: V163 = value; break;
case 164: V164 = value; break;
case 165: V165 = value; break;
case 166: V166 = value; break;
case 167: V167 = value; break;
case 168: V168 = value; break;
case 169: V169 = value; break;
case 170: V170 = value; break;
case 171: V171 = value; break;
case 172: V172 = value; break;
case 173: V173 = value; break;
case 174: V174 = value; break;
case 175: V175 = value; break;
case 176: V176 = value; break;
case 177: V177 = value; break;
case 178: V178 = value; break;
case 179: V179 = value; break;
case 180: V180 = value; break;
case 181: V181 = value; break;
case 182: V182 = value; break;
case 183: V183 = value; break;
case 184: V184 = value; break;
case 185: V185 = value; break;
case 186: V186 = value; break;
case 187: V187 = value; break;
case 188: V188 = value; break;
case 189: V189 = value; break;
case 190: V190 = value; break;
case 191: V191 = value; break;
case 192: V192 = value; break;
case 193: V193 = value; break;
case 194: V194 = value; break;
case 195: V195 = value; break;
case 196: V196 = value; break;
case 197: V197 = value; break;
case 198: V198 = value; break;
case 199: V199 = value; break;
case 200: V200 = value; break;
case 201: V201 = value; break;
case 202: V202 = value; break;
case 203: V203 = value; break;
case 204: V204 = value; break;
case 205: V205 = value; break;
case 206: V206 = value; break;
case 207: V207 = value; break;
case 208: V208 = value; break;
case 209: V209 = value; break;
case 210: V210 = value; break;
case 211: V211 = value; break;
case 212: V212 = value; break;
case 213: V213 = value; break;
case 214: V214 = value; break;
case 215: V215 = value; break;
case 216: V216 = value; break;
case 217: V217 = value; break;
case 218: V218 = value; break;
case 219: V219 = value; break;
case 220: V220 = value; break;
case 221: V221 = value; break;
case 222: V222 = value; break;
case 223: V223 = value; break;
case 224: V224 = value; break;
case 225: V225 = value; break;
case 226: V226 = value; break;
case 227: V227 = value; break;
case 228: V228 = value; break;
case 229: V229 = value; break;
case 230: V230 = value; break;
case 231: V231 = value; break;
case 232: V232 = value; break;
case 233: V233 = value; break;
case 234: V234 = value; break;
case 235: V235 = value; break;
case 236: V236 = value; break;
case 237: V237 = value; break;
case 238: V238 = value; break;
case 239: V239 = value; break;
case 240: V240 = value; break;
case 241: V241 = value; break;
case 242: V242 = value; break;
case 243: V243 = value; break;
case 244: V244 = value; break;
case 245: V245 = value; break;
case 246: V246 = value; break;
case 247: V247 = value; break;
case 248: V248 = value; break;
case 249: V249 = value; break;
case 250: V250 = value; break;
case 251: V251 = value; break;
case 252: V252 = value; break;
case 253: V253 = value; break;
case 254: V254 = value; break;
case 255: V255 = value; break;
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c52c604b53db4204bef88c52a4bd9f80
timeCreated: 1715335324

View File

@@ -0,0 +1,133 @@
using System;
using System.Runtime.CompilerServices;
namespace DotRecast.Core.Collections
{
public struct RcStackArray32<T>
{
public static RcStackArray32<T> Empty => new RcStackArray32<T>();
private const int Size = 32;
public int Length => Size;
public T V0;
public T V1;
public T V2;
public T V3;
public T V4;
public T V5;
public T V6;
public T V7;
public T V8;
public T V9;
public T V10;
public T V11;
public T V12;
public T V13;
public T V14;
public T V15;
public T V16;
public T V17;
public T V18;
public T V19;
public T V20;
public T V21;
public T V22;
public T V23;
public T V24;
public T V25;
public T V26;
public T V27;
public T V28;
public T V29;
public T V30;
public T V31;
public T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
return index switch
{
0 => V0,
1 => V1,
2 => V2,
3 => V3,
4 => V4,
5 => V5,
6 => V6,
7 => V7,
8 => V8,
9 => V9,
10 => V10,
11 => V11,
12 => V12,
13 => V13,
14 => V14,
15 => V15,
16 => V16,
17 => V17,
18 => V18,
19 => V19,
20 => V20,
21 => V21,
22 => V22,
23 => V23,
24 => V24,
25 => V25,
26 => V26,
27 => V27,
28 => V28,
29 => V29,
30 => V30,
31 => V31,
_ => throw new IndexOutOfRangeException($"{index}")
};
}
set
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
switch (index)
{
case 0: V0 = value; break;
case 1: V1 = value; break;
case 2: V2 = value; break;
case 3: V3 = value; break;
case 4: V4 = value; break;
case 5: V5 = value; break;
case 6: V6 = value; break;
case 7: V7 = value; break;
case 8: V8 = value; break;
case 9: V9 = value; break;
case 10: V10 = value; break;
case 11: V11 = value; break;
case 12: V12 = value; break;
case 13: V13 = value; break;
case 14: V14 = value; break;
case 15: V15 = value; break;
case 16: V16 = value; break;
case 17: V17 = value; break;
case 18: V18 = value; break;
case 19: V19 = value; break;
case 20: V20 = value; break;
case 21: V21 = value; break;
case 22: V22 = value; break;
case 23: V23 = value; break;
case 24: V24 = value; break;
case 25: V25 = value; break;
case 26: V26 = value; break;
case 27: V27 = value; break;
case 28: V28 = value; break;
case 29: V29 = value; break;
case 30: V30 = value; break;
case 31: V31 = value; break;
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8c5110de30e54d92b6fa8a7ef1785de0
timeCreated: 1715335324

View File

@@ -0,0 +1,49 @@
using System;
using System.Runtime.CompilerServices;
namespace DotRecast.Core.Collections
{
public struct RcStackArray4<T>
{
public static RcStackArray4<T> Empty => new RcStackArray4<T>();
private const int Size = 4;
public int Length => Size;
public T V0;
public T V1;
public T V2;
public T V3;
public T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
return index switch
{
0 => V0,
1 => V1,
2 => V2,
3 => V3,
_ => throw new IndexOutOfRangeException($"{index}")
};
}
set
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
switch (index)
{
case 0: V0 = value; break;
case 1: V1 = value; break;
case 2: V2 = value; break;
case 3: V3 = value; break;
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 08b071290e9345109b4a91f63756d166
timeCreated: 1715335324

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: be8c2c11e1614045923bbb5fe960cea6
timeCreated: 1715335324

View File

@@ -0,0 +1,229 @@
using System;
using System.Runtime.CompilerServices;
namespace DotRecast.Core.Collections
{
public struct RcStackArray64<T>
{
public static RcStackArray64<T> Empty => new RcStackArray64<T>();
private const int Size = 64;
public int Length => Size;
public T V0;
public T V1;
public T V2;
public T V3;
public T V4;
public T V5;
public T V6;
public T V7;
public T V8;
public T V9;
public T V10;
public T V11;
public T V12;
public T V13;
public T V14;
public T V15;
public T V16;
public T V17;
public T V18;
public T V19;
public T V20;
public T V21;
public T V22;
public T V23;
public T V24;
public T V25;
public T V26;
public T V27;
public T V28;
public T V29;
public T V30;
public T V31;
public T V32;
public T V33;
public T V34;
public T V35;
public T V36;
public T V37;
public T V38;
public T V39;
public T V40;
public T V41;
public T V42;
public T V43;
public T V44;
public T V45;
public T V46;
public T V47;
public T V48;
public T V49;
public T V50;
public T V51;
public T V52;
public T V53;
public T V54;
public T V55;
public T V56;
public T V57;
public T V58;
public T V59;
public T V60;
public T V61;
public T V62;
public T V63;
public T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
return index switch
{
0 => V0,
1 => V1,
2 => V2,
3 => V3,
4 => V4,
5 => V5,
6 => V6,
7 => V7,
8 => V8,
9 => V9,
10 => V10,
11 => V11,
12 => V12,
13 => V13,
14 => V14,
15 => V15,
16 => V16,
17 => V17,
18 => V18,
19 => V19,
20 => V20,
21 => V21,
22 => V22,
23 => V23,
24 => V24,
25 => V25,
26 => V26,
27 => V27,
28 => V28,
29 => V29,
30 => V30,
31 => V31,
32 => V32,
33 => V33,
34 => V34,
35 => V35,
36 => V36,
37 => V37,
38 => V38,
39 => V39,
40 => V40,
41 => V41,
42 => V42,
43 => V43,
44 => V44,
45 => V45,
46 => V46,
47 => V47,
48 => V48,
49 => V49,
50 => V50,
51 => V51,
52 => V52,
53 => V53,
54 => V54,
55 => V55,
56 => V56,
57 => V57,
58 => V58,
59 => V59,
60 => V60,
61 => V61,
62 => V62,
63 => V63,
_ => throw new ArgumentOutOfRangeException(nameof(index), index, null)
};
}
set
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
switch (index)
{
case 0: V0 = value; break;
case 1: V1 = value; break;
case 2: V2 = value; break;
case 3: V3 = value; break;
case 4: V4 = value; break;
case 5: V5 = value; break;
case 6: V6 = value; break;
case 7: V7 = value; break;
case 8: V8 = value; break;
case 9: V9 = value; break;
case 10: V10 = value; break;
case 11: V11 = value; break;
case 12: V12 = value; break;
case 13: V13 = value; break;
case 14: V14 = value; break;
case 15: V15 = value; break;
case 16: V16 = value; break;
case 17: V17 = value; break;
case 18: V18 = value; break;
case 19: V19 = value; break;
case 20: V20 = value; break;
case 21: V21 = value; break;
case 22: V22 = value; break;
case 23: V23 = value; break;
case 24: V24 = value; break;
case 25: V25 = value; break;
case 26: V26 = value; break;
case 27: V27 = value; break;
case 28: V28 = value; break;
case 29: V29 = value; break;
case 30: V30 = value; break;
case 31: V31 = value; break;
case 32 : V32 = value; break;
case 33 : V33 = value; break;
case 34 : V34 = value; break;
case 35 : V35 = value; break;
case 36 : V36 = value; break;
case 37 : V37 = value; break;
case 38 : V38 = value; break;
case 39 : V39 = value; break;
case 40 : V40 = value; break;
case 41 : V41 = value; break;
case 42 : V42 = value; break;
case 43 : V43 = value; break;
case 44 : V44 = value; break;
case 45 : V45 = value; break;
case 46 : V46 = value; break;
case 47 : V47 = value; break;
case 48 : V48 = value; break;
case 49 : V49 = value; break;
case 50 : V50 = value; break;
case 51 : V51 = value; break;
case 52 : V52 = value; break;
case 53 : V53 = value; break;
case 54 : V54 = value; break;
case 55 : V55 = value; break;
case 56 : V56 = value; break;
case 57 : V57 = value; break;
case 58 : V58 = value; break;
case 59 : V59 = value; break;
case 60 : V60 = value; break;
case 61 : V61 = value; break;
case 62 : V62 = value; break;
case 63 : V63 = value; break;
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8095a86a2f2f48369ebc8f527b169e14
timeCreated: 1715335324

View File

@@ -0,0 +1,61 @@
using System;
using System.Runtime.CompilerServices;
namespace DotRecast.Core.Collections
{
public struct RcStackArray8<T>
{
public static RcStackArray8<T> Empty => new RcStackArray8<T>();
private const int Size = 8;
public int Length => Size;
public T V0;
public T V1;
public T V2;
public T V3;
public T V4;
public T V5;
public T V6;
public T V7;
public T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
return index switch
{
0 => V0,
1 => V1,
2 => V2,
3 => V3,
4 => V4,
5 => V5,
6 => V6,
7 => V7,
_ => throw new IndexOutOfRangeException($"{index}")
};
}
set
{
RcThrowHelper.ThrowExceptionIfIndexOutOfRange(index, Length);
switch (index)
{
case 0: V0 = value; break;
case 1: V1 = value; break;
case 2: V2 = value; break;
case 3: V3 = value; break;
case 4: V4 = value; break;
case 5: V5 = value; break;
case 6: V6 = value; break;
case 7: V7 = value; break;
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0341000510e842fb9b5e4ea739f19cb6
timeCreated: 1715335324

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 696b89df3c7b4e2db6d23b70729a11b2
timeCreated: 1715335324

View File

@@ -0,0 +1,664 @@
/*
FastLZ - Byte-aligned LZ77 compression library
Copyright (C) 2005-2020 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2023 Choi Ikpil <ikpil@naver.com> https://github.com/ikpil/DotFastLZ
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 JNGame.Math;
namespace DotRecast.Core.Compression
{
public static class FastLZ
{
public const int FASTLZ_VERSION = 0x000500;
public const int FASTLZ_VERSION_MAJOR = 0;
public const int FASTLZ_VERSION_MINOR = 5;
public const int FASTLZ_VERSION_REVISION = 0;
public const string FASTLZ_VERSION_STRING = "0.5.0";
public const int MAX_COPY = 32;
public const int MAX_LEN = 264; /* 256 + 8 */
public const int MAX_L1_DISTANCE = 8192;
public const int MAX_L2_DISTANCE = 8191;
public const int MAX_FARDISTANCE = (65535 + MAX_L2_DISTANCE - 1);
public const int HASH_LOG = 13;
public const int HASH_SIZE = (1 << HASH_LOG);
public const int HASH_MASK = (HASH_SIZE - 1);
/**
Compress a block of data in the input buffer and returns the size of
compressed block. The size of input buffer is specified by length. The
minimum input buffer size is 16.
The output buffer must be at least 5% larger than the input buffer
and can not be smaller than 66 bytes.
If the input is not compressible, the return value might be larger than
length (input buffer size).
The input buffer and the output buffer can not overlap.
Compression level can be specified in parameter level. At the moment,
only level 1 and level 2 are supported.
Level 1 is the fastest compression and generally useful for short data.
Level 2 is slightly slower but it gives better compression ratio.
Note that the compressed data, regardless of the level, can always be
decompressed using the function fastlz_decompress below.
*/
// fastlz_compress
public static long CompressLevel(int level, byte[] input, long length, byte[] output)
{
return CompressLevel(level, input, 0, length, output);
}
public static long CompressLevel(int level, byte[] input, long inputOffset, long length, byte[] output)
{
if (level == 1)
{
return CompressLevel1(input, inputOffset, length, output);
}
if (level == 2)
{
return CompressLevel2(input, inputOffset, length, output);
}
throw new Exception($"invalid level: {level} (expected: 1 or 2)");
}
// fastlz1_compress
public static long CompressLevel1(byte[] input, long inputOffset, long length, byte[] output)
{
long ip = inputOffset;
long ip_start = ip;
long ip_bound = ip + length - 4;
long ip_limit = ip + length - 12 - 1;
long op = 0;
long[] htab = new long[HASH_SIZE];
long seq, hash;
// Initializes hash table
for (hash = 0; hash < HASH_SIZE; ++hash)
{
htab[hash] = 0;
}
// We start with literal copy
long anchor = ip;
ip += 2;
// Main loop
while (ip < ip_limit)
{
long refIdx;
long distance, cmp;
// Find potential match
do
{
seq = ReadUInt32(input, ip) & 0xffffff;
hash = Hash(seq);
refIdx = ip_start + htab[hash];
htab[hash] = ip - ip_start;
distance = ip - refIdx;
cmp = distance < MAX_L1_DISTANCE
? ReadUInt32(input, refIdx) & 0xffffff
: 0x1000000;
if (ip >= ip_limit)
{
break;
}
++ip;
} while (seq != cmp);
if (ip >= ip_limit)
{
break;
}
--ip;
if (ip > anchor)
{
op = Literals(ip - anchor, input, anchor, output, op);
}
long len = MemCompare(input, refIdx + 3, input, ip + 3, ip_bound);
op = MatchLevel1(len, distance, output, op);
// Update the hash at the match boundary
ip += len;
seq = ReadUInt32(input, ip);
hash = Hash(seq & 0xffffff);
htab[hash] = ip++ - ip_start;
seq >>= 8;
hash = Hash(seq);
htab[hash] = ip++ - ip_start;
anchor = ip;
}
long copy = length - anchor;
op = Literals(copy, input, anchor, output, op);
return op;
}
// fastlz2_compress
public static long CompressLevel2(byte[] input, long inputOffset, long length, byte[] output)
{
long ip = inputOffset;
long ip_start = ip;
long ip_bound = ip + length - 4; /* because readU32 */
long ip_limit = ip + length - 12 - 1;
long op = 0;
long[] htab = new long[HASH_SIZE];
long seq, hash;
/* initializes hash table */
for (hash = 0; hash < HASH_SIZE; ++hash)
{
htab[hash] = 0;
}
/* we start with literal copy */
long anchor = ip;
ip += 2;
/* main loop */
while (ip < ip_limit)
{
long refs;
long distance, cmp;
/* find potential match */
do
{
seq = ReadUInt32(input, ip) & 0xffffff;
hash = Hash(seq);
refs = ip_start + htab[hash];
htab[hash] = ip - ip_start;
distance = ip - refs;
cmp = distance < MAX_FARDISTANCE
? ReadUInt32(input, refs) & 0xffffff
: 0x1000000;
if (ip >= ip_limit)
{
break;
}
++ip;
} while (seq != cmp);
if (ip >= ip_limit)
{
break;
}
--ip;
/* far, needs at least 5-byte match */
if (distance >= MAX_L2_DISTANCE)
{
if (input[refs + 3] != input[ip + 3] || input[refs + 4] != input[ip + 4])
{
++ip;
continue;
}
}
if (ip > anchor)
{
op = Literals(ip - anchor, input, anchor, output, op);
}
long len = MemCompare(input, refs + 3, input, ip + 3, ip_bound);
op = MatchLevel2(len, distance, output, op);
/* update the hash at match boundary */
ip += len;
seq = ReadUInt32(input, ip);
hash = Hash(seq & 0xffffff);
htab[hash] = ip++ - ip_start;
seq >>= 8;
hash = Hash(seq);
htab[hash] = ip++ - ip_start;
anchor = ip;
}
long copy = length - anchor;
op = Literals(copy, input, anchor, output, op);
/* marker for fastlz2 */
output[inputOffset] |= (1 << 5);
return op;
}
/**
Decompress a block of compressed data and returns the size of the
decompressed block. If error occurs, e.g. the compressed data is
corrupted or the output buffer is not large enough, then 0 (zero)
will be returned instead.
The input buffer and the output buffer can not overlap.
Decompression is memory safe and guaranteed not to write the output buffer
more than what is specified in maxout.
Note that the decompression will always work, regardless of the
compression level specified in fastlz_compress_level above (when
producing the compressed block).
*/
// fastlz_decompress
public static long Decompress(byte[] input, long length, byte[] output, long maxout)
{
return Decompress(input, 0, length, output, 0, maxout);
}
public static long Decompress(byte[] input, long inputOffset, long length, byte[] output, long outputOffset, long maxout)
{
/* magic identifier for compression level */
int level = (input[inputOffset] >> 5) + 1;
if (level == 1)
{
return DecompressLevel1(input, inputOffset, length, output, outputOffset, maxout);
}
if (level == 2)
{
return DecompressLevel2(input, inputOffset, length, output, outputOffset, maxout);
}
throw new Exception($"invalid level: {level} (expected: 1 or 2)");
}
// fastlz1_decompress
public static long DecompressLevel1(byte[] input, long inputOffset, long length, byte[] output, long outputOffset, long maxout)
{
long ip = inputOffset;
long ip_limit = ip + length;
long ip_bound = ip_limit - 2;
long op = outputOffset;
long op_limit = op + maxout;
long ctrl = input[ip++] & 31;
while (true)
{
if (ctrl >= 32)
{
long len = (ctrl >> 5) - 1;
long ofs = (ctrl & 31) << 8;
long refs = op - ofs - 1;
if (len == 7 - 1)
{
if (!(ip <= ip_bound))
{
return 0;
}
len += input[ip++];
}
refs -= input[ip++];
len += 3;
if (!(op + len <= op_limit))
{
return 0;
}
if (!(refs >= outputOffset))
{
return 0;
}
MemMove(output, op, output, refs, len);
op += len;
}
else
{
ctrl++;
if (!(op + ctrl <= op_limit))
{
return 0;
}
if (!(ip + ctrl <= ip_limit))
{
return 0;
}
RcArrays.Copy(input, ip, output, op, ctrl);
ip += ctrl;
op += ctrl;
}
if (ip > ip_bound)
{
break;
}
ctrl = input[ip++];
}
return op;
}
// fastlz2_decompress
public static long DecompressLevel2(byte[] input, long inputOffset, long length, byte[] output, long outputOffset, long maxout)
{
long ip = inputOffset;
long ip_limit = ip + length;
long ip_bound = ip_limit - 2;
long op = outputOffset;
long op_limit = op + maxout;
long ctrl = input[ip++] & 31;
while (true)
{
if (ctrl >= 32)
{
long len = (ctrl >> 5) - 1;
long ofs = (ctrl & 31) << 8;
long refIdx = op - ofs - 1;
long code;
if (len == 7 - 1)
{
do
{
if (!(ip <= ip_bound))
{
return 0;
}
code = input[ip++];
len += code;
} while (code == 255);
}
code = input[ip++];
refIdx -= code;
len += 3;
/* match from 16-bit distance */
if (code == 255)
{
if (ofs == (31 << 8))
{
if (!(ip < ip_bound))
{
return 0;
}
ofs = input[ip++] << 8;
ofs += input[ip++];
refIdx = op - ofs - MAX_L2_DISTANCE - 1;
}
}
if (!(op + len <= op_limit))
{
return 0;
}
if (!(refIdx >= outputOffset))
{
return 0;
}
MemMove(output, op, output, refIdx, len);
op += len;
}
else
{
ctrl++;
if (!(op + ctrl <= op_limit))
{
return 0;
}
if (!(ip + ctrl <= ip_limit))
{
return 0;
}
RcArrays.Copy(input, ip, output, op, ctrl);
ip += ctrl;
op += ctrl;
}
if (ip >= ip_limit)
{
break;
}
ctrl = input[ip++];
}
return op;
}
// flz_readu32
public static uint ReadUInt32(byte[] data, long offset)
{
return ((uint)data[offset + 3] & 0xff) << 24 |
((uint)data[offset + 2] & 0xff) << 16 |
((uint)data[offset + 1] & 0xff) << 8 |
((uint)data[offset + 0] & 0xff);
}
public static ushort ReadUInt16(byte[] data, long offset)
{
var u16 = ((uint)data[offset + 1] << 8) |
((uint)data[offset + 0]);
return (ushort)u16;
}
// flz_hash
public static ushort Hash(long v)
{
ulong h = ((ulong)v * 2654435769UL) >> (32 - HASH_LOG);
return (ushort)(h & HASH_MASK);
}
// special case of memcpy: at most MAX_COPY bytes
// flz_smallcopy
public static void SmallCopy(byte[] dest, long destOffset, byte[] src, long srcOffset, long count)
{
// if (count >= 4)
// {
// count -= count % 4;
// RcArrays.Copy(src, srcOffset, dest, destOffset, count);
// }
RcArrays.Copy(src, srcOffset, dest, destOffset, count);
}
// special case of memcpy: exactly MAX_COPY bytes
// flz_maxcopy
static void MaxCopy(byte[] dest, long destOffset, byte[] src, long secOffset)
{
RcArrays.Copy(src, secOffset, dest, destOffset, MAX_COPY);
}
// flz_literals
public static long Literals(long runs, byte[] src, long srcOffset, byte[] dest, long destOffset)
{
while (runs >= MAX_COPY)
{
dest[destOffset++] = MAX_COPY - 1;
MaxCopy(dest, destOffset, src, srcOffset);
srcOffset += MAX_COPY;
destOffset += MAX_COPY;
runs -= MAX_COPY;
}
if (runs > 0)
{
dest[destOffset++] = (byte)(runs - 1);
SmallCopy(dest, destOffset, src, srcOffset, runs);
destOffset += runs;
}
return destOffset;
}
// flz1_match
public static long MatchLevel1(long len, long distance, byte[] output, long op)
{
--distance;
if (len > MAX_LEN - 2)
{
while (len > MAX_LEN - 2)
{
output[op++] = (byte)((7 << 5) + (distance >> 8));
output[op++] = (byte)(MAX_LEN - 2 - 7 - 2);
output[op++] = (byte)(distance & 255);
len -= MAX_LEN - 2;
}
}
if (len < 7)
{
output[op++] = (byte)((len << 5) + (distance >> 8));
output[op++] = (byte)(distance & 255);
}
else
{
output[op++] = (byte)((7 << 5) + (distance >> 8));
output[op++] = (byte)(len - 7);
output[op++] = (byte)((distance & 255));
}
return op;
}
// flz2_match
public static long MatchLevel2(long len, long distance, byte[] output, long op)
{
--distance;
if (distance < MAX_L2_DISTANCE)
{
if (len < 7)
{
output[op++] = (byte)((len << 5) + (distance >> 8));
output[op++] = (byte)((distance & 255));
}
else
{
output[op++] = (byte)((7 << 5) + (distance >> 8));
for (len -= 7; len >= 255; len -= 255)
{
output[op++] = 255;
}
output[op++] = (byte)(len);
output[op++] = (byte)((distance & 255));
}
}
else
{
/* far away, but not yet in the another galaxy... */
if (len < 7)
{
distance -= MAX_L2_DISTANCE;
output[op++] = (byte)((len << 5) + 31);
output[op++] = (byte)(255);
output[op++] = (byte)(distance >> 8);
output[op++] = (byte)(distance & 255);
}
else
{
distance -= MAX_L2_DISTANCE;
output[op++] = (7 << 5) + 31;
for (len -= 7; len >= 255; len -= 255)
{
output[op++] = 255;
}
output[op++] = (byte)(len);
output[op++] = (byte)(255);
output[op++] = (byte)(distance >> 8);
output[op++] = (byte)(distance & 255);
}
}
return op;
}
// flz_cmp
public static long MemCompare(byte[] p, long pOffset, byte[] q, long qOffset, long r)
{
long start = pOffset;
if (4 <= r && ReadUInt32(p, pOffset) == ReadUInt32(q, qOffset))
{
pOffset += 4;
qOffset += 4;
}
while (qOffset < r)
{
if (p[pOffset++] != q[qOffset++])
break;
}
return pOffset - start;
}
// fastlz_memmove
public static void MemMove(byte[] dest, long destOffset, byte[] src, long srcOffset, long count)
{
if (dest.Length < destOffset + count)
{
throw new IndexOutOfRangeException($"{dest.Length} < {destOffset} + {count}");
}
if (src.Length < srcOffset + count)
{
throw new IndexOutOfRangeException($"{src.Length} < {srcOffset} + {count}");
}
for (long i = 0; i < count; ++i)
{
dest[destOffset + i] = src[srcOffset + i];
}
}
public static long EstimateCompressedSize(long size)
{
long estimatedSize = (long)LMath.Ceiling(size * (LFloat)1.06f);
return LMath.Max(estimatedSize, 66);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c3fe416c3eb54a2b81d7e9b0c2908533
timeCreated: 1715335324

View File

@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
<PackageId>DotRecast.Core</PackageId>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Authors>ikpil</Authors>
<Description>DotRecast - a port of Recast Detour, Industry-standard navigation mesh toolset for .NET, C#, Unity3D, games, servers</Description>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://github.com/ikpil/DotRecast</PackageProjectUrl>
<RepositoryUrl>https://github.com/ikpil/DotRecast</RepositoryUrl>
<PackageTags>game gamedev ai csharp server unity navigation game-development unity3d pathfinding pathfinder recast detour navmesh crowd-simulation recastnavigation</PackageTags>
<PackageReleaseNotes>https://github.com/ikpil/DotRecast/blob/main/CHANGELOG.md</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<None Include="../../README.md" Pack="true" PackagePath="\"/>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2018ee4d906448deae351dcae11103ad
timeCreated: 1715335324

View File

@@ -0,0 +1,30 @@
/*
Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org
DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
namespace DotRecast.Core
{
public interface IRcCompressor
{
byte[] Decompress(byte[] data);
byte[] Decompress(byte[] buf, int offset, int len, int outputlen);
byte[] Compress(byte[] buf);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 412a6ebfb8224952a06bb88a9c2ff5ce
timeCreated: 1715335324

View File

@@ -0,0 +1,11 @@
using JNGame.Math;
namespace DotRecast.Core
{
public interface IRcRand
{
LFloat Next();
LFloat NextDouble();
int NextInt32();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3a6664b959384c758be06986a19a0a13
timeCreated: 1715335324

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 986fa4f4d98744c384582d053f6f7566
timeCreated: 1715335324

View File

@@ -0,0 +1,221 @@
using System;
using System.Runtime.CompilerServices;
using JNGame.Math;
namespace DotRecast.Core.Numerics
{
public struct RcMatrix4x4f
{
private static readonly RcMatrix4x4f _identity = new RcMatrix4x4f
(
(LFloat)1f, (LFloat)0f, (LFloat)0f, (LFloat)0f,
(LFloat)0f, (LFloat)1f, (LFloat)0f, (LFloat)0f,
(LFloat)0f, (LFloat)0f, (LFloat)1f, (LFloat)0f,
(LFloat)0f, (LFloat)0f, (LFloat)0f, (LFloat)1f
);
public LFloat M11; // 0
public LFloat M12; // 1
public LFloat M13; // 2
public LFloat M14; // 3
public LFloat M21; // 4
public LFloat M22; // 5
public LFloat M23; // 6
public LFloat M24; // 7
public LFloat M31; // 8
public LFloat M32; // 9
public LFloat M33; // 10
public LFloat M34; // 11
public LFloat M41; // 12
public LFloat M42; // 13
public LFloat M43; // 14
public LFloat M44; // 15
public RcMatrix4x4f(
LFloat m11, LFloat m12, LFloat m13, LFloat m14,
LFloat m21, LFloat m22, LFloat m23, LFloat m24,
LFloat m31, LFloat m32, LFloat m33, LFloat m34,
LFloat m41, LFloat m42, LFloat m43, LFloat m44)
{
M11 = m11;
M12 = m12;
M13 = m13;
M14 = m14;
M21 = m21;
M22 = m22;
M23 = m23;
M24 = m24;
M31 = m31;
M32 = m32;
M33 = m33;
M34 = m34;
M41 = m41;
M42 = m42;
M43 = m43;
M44 = m44;
}
public RcMatrix4x4f(LFloat[] m)
{
M11 = m[0];
M12 = m[1];
M13 = m[2];
M14 = m[3];
M21 = m[4];
M22 = m[5];
M23 = m[6];
M24 = m[7];
M31 = m[8];
M32 = m[9];
M33 = m[10];
M34 = m[11];
M41 = m[12];
M42 = m[13];
M43 = m[14];
M44 = m[15];
}
public void CopyTo(LFloat[] m)
{
m[0] = M11;
m[1] = M12;
m[2] = M13;
m[3] = M14;
m[4] = M21;
m[5] = M22;
m[6] = M23;
m[7] = M24;
m[8] = M31;
m[9] = M32;
m[10] = M33;
m[11] = M34;
m[12] = M41;
m[13] = M42;
m[14] = M43;
m[15] = M44;
}
public static RcMatrix4x4f Identity => _identity;
public readonly bool IsIdentity =>
M11.Equals(1f) && M22.Equals(1f) && M33.Equals(1f) && M44.Equals(1f) &&
M12 == 0f && M13 == 0f && M14 == 0f &&
M21 == 0f && M23 == 0f && M24 == 0f &&
M31 == 0f && M32 == 0f && M34 == 0f &&
M41 == 0f && M42 == 0f && M43 == 0f;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcMatrix4x4f Mul(ref RcMatrix4x4f left, ref RcMatrix4x4f right)
{
LFloat m11 = left.M11 * right.M11 + left.M21 * right.M12 + left.M31 * right.M13 + left.M41 * right.M14;
LFloat m12 = left.M12 * right.M11 + left.M22 * right.M12 + left.M32 * right.M13 + left.M42 * right.M14;
LFloat m13 = left.M13 * right.M11 + left.M23 * right.M12 + left.M33 * right.M13 + left.M43 * right.M14;
LFloat m14 = left.M14 * right.M11 + left.M24 * right.M12 + left.M34 * right.M13 + left.M44 * right.M14;
LFloat m21 = left.M11 * right.M21 + left.M21 * right.M22 + left.M31 * right.M23 + left.M41 * right.M24;
LFloat m22 = left.M12 * right.M21 + left.M22 * right.M22 + left.M32 * right.M23 + left.M42 * right.M24;
LFloat m23 = left.M13 * right.M21 + left.M23 * right.M22 + left.M33 * right.M23 + left.M43 * right.M24;
LFloat m24 = left.M14 * right.M21 + left.M24 * right.M22 + left.M34 * right.M23 + left.M44 * right.M24;
LFloat m31 = left.M11 * right.M31 + left.M21 * right.M32 + left.M31 * right.M33 + left.M41 * right.M34;
LFloat m32 = left.M12 * right.M31 + left.M22 * right.M32 + left.M32 * right.M33 + left.M42 * right.M34;
LFloat m33 = left.M13 * right.M31 + left.M23 * right.M32 + left.M33 * right.M33 + left.M43 * right.M34;
LFloat m34 = left.M14 * right.M31 + left.M24 * right.M32 + left.M34 * right.M33 + left.M44 * right.M34;
LFloat m41 = left.M11 * right.M41 + left.M21 * right.M42 + left.M31 * right.M43 + left.M41 * right.M44;
LFloat m42 = left.M12 * right.M41 + left.M22 * right.M42 + left.M32 * right.M43 + left.M42 * right.M44;
LFloat m43 = left.M13 * right.M41 + left.M23 * right.M42 + left.M33 * right.M43 + left.M43 * right.M44;
LFloat m44 = left.M14 * right.M41 + left.M24 * right.M42 + left.M34 * right.M43 + left.M44 * right.M44;
RcMatrix4x4f dest = new RcMatrix4x4f();
dest.M11 = m11;
dest.M12 = m12;
dest.M13 = m13;
dest.M14 = m14;
dest.M21 = m21;
dest.M22 = m22;
dest.M23 = m23;
dest.M24 = m24;
dest.M31 = m31;
dest.M32 = m32;
dest.M33 = m33;
dest.M34 = m34;
dest.M41 = m41;
dest.M42 = m42;
dest.M43 = m43;
dest.M44 = m44;
return dest;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcMatrix4x4f Mul(LFloat[] left, LFloat[] right)
{
LFloat m00 = left[0] * right[0] + left[4] * right[1] + left[8] * right[2] + left[12] * right[3];
LFloat m01 = left[1] * right[0] + left[5] * right[1] + left[9] * right[2] + left[13] * right[3];
LFloat m02 = left[2] * right[0] + left[6] * right[1] + left[10] * right[2] + left[14] * right[3];
LFloat m03 = left[3] * right[0] + left[7] * right[1] + left[11] * right[2] + left[15] * right[3];
LFloat m10 = left[0] * right[4] + left[4] * right[5] + left[8] * right[6] + left[12] * right[7];
LFloat m11 = left[1] * right[4] + left[5] * right[5] + left[9] * right[6] + left[13] * right[7];
LFloat m12 = left[2] * right[4] + left[6] * right[5] + left[10] * right[6] + left[14] * right[7];
LFloat m13 = left[3] * right[4] + left[7] * right[5] + left[11] * right[6] + left[15] * right[7];
LFloat m20 = left[0] * right[8] + left[4] * right[9] + left[8] * right[10] + left[12] * right[11];
LFloat m21 = left[1] * right[8] + left[5] * right[9] + left[9] * right[10] + left[13] * right[11];
LFloat m22 = left[2] * right[8] + left[6] * right[9] + left[10] * right[10] + left[14] * right[11];
LFloat m23 = left[3] * right[8] + left[7] * right[9] + left[11] * right[10] + left[15] * right[11];
LFloat m30 = left[0] * right[12] + left[4] * right[13] + left[8] * right[14] + left[12] * right[15];
LFloat m31 = left[1] * right[12] + left[5] * right[13] + left[9] * right[14] + left[13] * right[15];
LFloat m32 = left[2] * right[12] + left[6] * right[13] + left[10] * right[14] + left[14] * right[15];
LFloat m33 = left[3] * right[12] + left[7] * right[13] + left[11] * right[14] + left[15] * right[15];
return new RcMatrix4x4f(
m00, m01, m02, m03,
m10, m11, m12, m13,
m20, m21, m22, m23,
m30, m31, m32, m33
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcMatrix4x4f CreateFromRotate(LFloat a, LFloat x, LFloat y, LFloat z)
{
var matrix = new RcMatrix4x4f();
a = (LFloat)(a * LMath.PI / 180.0); // convert to radians
LFloat s = LMath.Sin(a);
LFloat c = LMath.Cos(a);
LFloat t = (LFloat)1.0f - c;
LFloat tx = t * x;
LFloat ty = t * y;
LFloat tz = t * z;
LFloat sz = s * z;
LFloat sy = s * y;
LFloat sx = s * x;
matrix.M11 = tx * x + c;
matrix.M12 = tx * y + sz;
matrix.M13 = tx * z - sy;
matrix.M14 = 0;
matrix.M21 = tx * y - sz;
matrix.M22 = ty * y + c;
matrix.M23 = ty * z + sx;
matrix.M24 = 0;
matrix.M31 = tx * z + sy;
matrix.M32 = ty * z - sx;
matrix.M33 = tz * z + c;
matrix.M34 = 0;
matrix.M41 = 0;
matrix.M42 = 0;
matrix.M43 = 0;
matrix.M44 = 1;
return matrix;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a4302cdd2a74453aa54269209cabda3c
timeCreated: 1715335324

View File

@@ -0,0 +1,61 @@
using System;
using System.Runtime.CompilerServices;
using JNGame.Math;
namespace DotRecast.Core.Numerics
{
public struct RcVec2f
{
public LFloat X;
public LFloat Y;
public static readonly RcVec2f Zero = new RcVec2f { X = 0, Y = 0 };
public RcVec2f(LFloat x, LFloat y)
{
X = x;
Y = y;
}
public override bool Equals(object obj)
{
if (!(obj is RcVec2f))
return false;
return Equals((RcVec2f)obj);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(RcVec2f other)
{
return X.Equals(other.X) &&
Y.Equals(other.Y);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode()
{
int hash = X.GetHashCode();
hash = RcHashCodes.CombineHashCodes(hash, Y.GetHashCode());
return hash;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(RcVec2f left, RcVec2f right)
{
return left.Equals(right);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(RcVec2f left, RcVec2f right)
{
return !left.Equals(right);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string ToString()
{
return $"{X}, {Y}";
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0b52438d444142ecb0b42b1eaf383716
timeCreated: 1715335324

View File

@@ -0,0 +1,257 @@
/*
recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
using System;
using System.Runtime.CompilerServices;
using JNGame.Math;
namespace DotRecast.Core.Numerics
{
public struct RcVec3f
{
public LFloat X;
public LFloat Y;
public LFloat Z;
public static readonly RcVec3f Zero = new RcVec3f((LFloat)0.0f, (LFloat)0.0f, (LFloat)0.0f);
public static readonly RcVec3f One = new RcVec3f((LFloat)1.0f);
public static readonly RcVec3f UnitX = new RcVec3f((LFloat)1.0f, (LFloat)0.0f, (LFloat)0.0f);
public static readonly RcVec3f UnitY = new RcVec3f((LFloat)0.0f, (LFloat)1.0f, (LFloat)0.0f);
public static readonly RcVec3f UnitZ = new RcVec3f((LFloat)0.0f, (LFloat)0.0f, (LFloat)1.0f);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public RcVec3f(LFloat x, LFloat y, LFloat z)
{
X = x;
Y = y;
Z = z;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public RcVec3f(LFloat f)
{
X = f;
Y = f;
Z = f;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly LFloat Length()
{
LFloat lengthSquared = LengthSquared();
return LMath.Sqrt(lengthSquared);
}
/// Derives the square of the scalar length of the vector. (len * len)
/// @param[in] v The vector. [(x, y, z)]
/// @return The square of the scalar length of the vector.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly LFloat LengthSquared()
{
return Dot(this, this);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Subtract(RcVec3f left, RcVec3f right)
{
return left - right;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Add(RcVec3f left, RcVec3f right)
{
return left + right;
}
public override bool Equals(object obj)
{
if (!(obj is RcVec3f))
return false;
return Equals((RcVec3f)obj);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(RcVec3f other)
{
return X.Equals(other.X) &&
Y.Equals(other.Y) &&
Z.Equals(other.Z);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode()
{
return HashCode.Combine(X, Y, Z);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Min(RcVec3f value1, RcVec3f value2)
{
return new RcVec3f(
(value1.X < value2.X) ? value1.X : value2.X,
(value1.Y < value2.Y) ? value1.Y : value2.Y,
(value1.Z < value2.Z) ? value1.Z : value2.Z
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Max(RcVec3f value1, RcVec3f value2)
{
return new RcVec3f(
(value1.X > value2.X) ? value1.X : value2.X,
(value1.Y > value2.Y) ? value1.Y : value2.Y,
(value1.Z > value2.Z) ? value1.Z : value2.Z
);
}
public override string ToString()
{
return $"{X}, {Y}, {Z}";
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(RcVec3f left, RcVec3f right)
{
return left.Equals(right);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(RcVec3f left, RcVec3f right)
{
return !left.Equals(right);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f operator -(RcVec3f left, RcVec3f right)
{
return new RcVec3f(
left.X - right.X,
left.Y - right.Y,
left.Z - right.Z
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f operator +(RcVec3f left, RcVec3f right)
{
return new RcVec3f(
left.X + right.X,
left.Y + right.Y,
left.Z + right.Z
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f operator *(RcVec3f left, RcVec3f right)
{
return new RcVec3f(
left.X * right.X,
left.Y * right.Y,
left.Z * right.Z
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f operator *(RcVec3f left, LFloat right)
{
return left * new RcVec3f(right);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f operator *(LFloat left, RcVec3f right)
{
return right * left;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Lerp(RcVec3f value1, RcVec3f value2, LFloat amount)
{
return (value1 * ((LFloat)1f - amount)) + (value2 * amount);
// return new RcVec3f(
// value1.X + (value2.X - value1.X) * amount,
// value1.Y + (value2.Y - value1.Y) * amount,
// value1.Z + (value2.Z - value1.Z) * amount
// );
}
/// Returns the distance between two points.
/// @param[in] v1 A point. [(x, y, z)]
/// @param[in] v2 A point. [(x, y, z)]
/// @return The distance between the two points.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Distance(RcVec3f value1, RcVec3f value2)
{
LFloat distanceSquared = DistanceSquared(value1, value2);
return LMath.Sqrt(distanceSquared);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat DistanceSquared(RcVec3f value1, RcVec3f value2)
{
var difference = value1 - value2;
return Dot(difference, difference);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Dot(RcVec3f vector1, RcVec3f vector2)
{
return (vector1.X * vector2.X) +
(vector1.Y * vector2.Y) +
(vector1.Z * vector2.Z);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void CopyTo(LFloat[] array)
{
CopyTo(array, 0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void CopyTo(LFloat[] array, int n)
{
array[n + 0] = X;
array[n + 1] = Y;
array[n + 2] = Z;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Cross(RcVec3f v1, RcVec3f v2)
{
return new RcVec3f(
(v1.Y * v2.Z) - (v1.Z * v2.Y),
(v1.Z * v2.X) - (v1.X * v2.Z),
(v1.X * v2.Y) - (v1.Y * v2.X)
);
}
/// Normalizes the vector.
/// @param[in,out] v The vector to normalize. [(x, y, z)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Normalize(RcVec3f v)
{
var normal = new LVector3(v.X, v.Y, v.Z);
normal.Normalize();
return new RcVec3f(normal.x, normal.y, normal.z);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ec2c395421c04c31b4c1e1517e8c3c98
timeCreated: 1715335324

View File

@@ -0,0 +1,291 @@
using System;
using System.Runtime.CompilerServices;
using JNGame.Math;
namespace DotRecast.Core.Numerics
{
public static class RcVecUtils
{
public static LFloat Epsilon = LFloat.EPSILON;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Create(LFloat[] values)
{
return Create(values, 0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Create(Span<LFloat> values, int n)
{
return new RcVec3f(values[n + 0], values[n + 1], values[n + 2]);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Get(this RcVec2f v, int i)
{
switch (i)
{
case 0: return v.X;
case 1: return v.Y;
default: throw new IndexOutOfRangeException("vector2f index out of range");
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Get(this RcVec3f v, int i)
{
switch (i)
{
case 0: return v.X;
case 1: return v.Y;
case 2: return v.Z;
default: throw new IndexOutOfRangeException("vector3f index out of range");
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Scale(this RcVec3f v, LFloat scale)
{
return v * scale;
}
/// Derives the dot product of two vectors on the xz-plane. (@p u . @p v)
/// @param[in] u A vector [(x, y, z)]
/// @param[in] v A vector [(x, y, z)]
/// @return The dot product on the xz-plane.
///
/// The vectors are projected onto the xz-plane, so the y-values are
/// ignored.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Dot2D(this RcVec3f @this, RcVec3f v)
{
return @this.X * v.X +
@this.Z * v.Z;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Dot2D(this RcVec3f @this, Span<LFloat> v, int vi)
{
return @this.X * v[vi] +
@this.Z * v[vi + 2];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Add(RcVec3f a, LFloat[] verts, int i)
{
return new RcVec3f(
a.X + verts[i],
a.Y + verts[i + 1],
a.Z + verts[i + 2]
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Subtract(LFloat[] verts, int i, int j)
{
return new RcVec3f(
verts[i] - verts[j],
verts[i + 1] - verts[j + 1],
verts[i + 2] - verts[j + 2]
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Subtract(RcVec3f i, LFloat[] verts, int j)
{
return new RcVec3f(
i.X - verts[j],
i.Y - verts[j + 1],
i.Z - verts[j + 2]
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Cross(LFloat[] dest, LFloat[] v1, LFloat[] v2)
{
dest[0] = v1[1] * v2[2] - v1[2] * v2[1];
dest[1] = v1[2] * v2[0] - v1[0] * v2[2];
dest[2] = v1[0] * v2[1] - v1[1] * v2[0];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Copy(LFloat[] @out, int n, LFloat[] @in, int m)
{
@out[n + 0] = @in[m + 0];
@out[n + 1] = @in[m + 1];
@out[n + 2] = @in[m + 2];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Dot(LFloat[] v1, LFloat[] v2)
{
return v1[0] * v2[0] +
v1[1] * v2[1] +
v1[2] * v2[2];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Dot(LFloat[] v1, RcVec3f vector2)
{
return v1[0] * vector2.X +
v1[1] * vector2.Y +
v1[2] * vector2.Z;
}
/// Returns the distance between two points.
/// @param[in] v1 A point. [(x, y, z)]
/// @param[in] v2 A point. [(x, y, z)]
/// @return The distance between the two points.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat DistanceSquared(RcVec3f v1, LFloat[] v2, int i)
{
LFloat dx = v2[i] - v1.X;
LFloat dy = v2[i + 1] - v1.Y;
LFloat dz = v2[i + 2] - v1.Z;
return dx * dx + dy * dy + dz * dz;
}
/// Normalizes the vector if the length is greater than zero.
/// If the magnitude is zero, the vector is unchanged.
/// @param[in,out] v The vector to normalize. [(x, y, z)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f SafeNormalize(RcVec3f v)
{
LFloat sqMag = RcMath.Sqr(v.X) + RcMath.Sqr(v.Y) + RcMath.Sqr(v.Z);
if (sqMag > Epsilon)
{
LFloat inverseMag = (LFloat)1.0f / LMath.Sqrt(sqMag);
return new RcVec3f(
v.X *= inverseMag,
v.Y *= inverseMag,
v.Z *= inverseMag
);
}
return v;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Min(RcVec3f v, LFloat[] @in, int i)
{
return new RcVec3f(
(v.X < @in[i + 0]) ? v.X : @in[i + 0],
(v.Y < @in[i + 1]) ? v.Y : @in[i + 1],
(v.Z < @in[i + 2]) ? v.Z : @in[i + 2]
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Max(RcVec3f v, LFloat[] @in, int i)
{
return new RcVec3f(
(v.X > @in[i + 0]) ? v.X : @in[i + 0],
(v.Y > @in[i + 1]) ? v.Y : @in[i + 1],
(v.Z > @in[i + 2]) ? v.Z : @in[i + 2]
);
}
/// Derives the distance between the specified points on the xz-plane.
/// @param[in] v1 A point. [(x, y, z)]
/// @param[in] v2 A point. [(x, y, z)]
/// @return The distance between the point on the xz-plane.
///
/// The vectors are projected onto the xz-plane, so the y-values are
/// ignored.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Dist2D(RcVec3f v1, RcVec3f v2)
{
LFloat dx = v2.X - v1.X;
LFloat dz = v2.Z - v1.Z;
return (LFloat)LMath.Sqrt(dx * dx + dz * dz);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Dist2DSqr(RcVec3f v1, RcVec3f v2)
{
LFloat dx = v2.X - v1.X;
LFloat dz = v2.Z - v1.Z;
return dx * dx + dz * dz;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Dist2DSqr(RcVec3f p, LFloat[] verts, int i)
{
LFloat dx = verts[i] - p.X;
LFloat dz = verts[i + 2] - p.Z;
return dx * dx + dz * dz;
}
/// Derives the xz-plane 2D perp product of the two vectors. (uz*vx - ux*vz)
/// @param[in] u The LHV vector [(x, y, z)]
/// @param[in] v The RHV vector [(x, y, z)]
/// @return The dot product on the xz-plane.
///
/// The vectors are projected onto the xz-plane, so the y-values are
/// ignored.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Perp2D(RcVec3f u, RcVec3f v)
{
return u.Z * v.X - u.X * v.Z;
}
/// Checks that the specified vector's components are all finite.
/// @param[in] v A point. [(x, y, z)]
/// @return True if all of the point's components are finite, i.e. not NaN
/// or any of the infinities.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsFinite(this RcVec3f v)
{
return LFloat.IsFinite(v.X) && LFloat.IsFinite(v.Y) && LFloat.IsFinite(v.Z);
}
/// Checks that the specified vector's 2D components are finite.
/// @param[in] v A point. [(x, y, z)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsFinite2D(this RcVec3f v)
{
return LFloat.IsFinite(v.X) && LFloat.IsFinite(v.Z);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat PerpXZ(RcVec3f a, RcVec3f b)
{
return (a.X * b.Z) - (a.Z * b.X);
}
/// Performs a linear interpolation between two vectors. (@p v1 toward @p
/// v2)
/// @param[out] dest The result vector. [(x, y, x)]
/// @param[in] v1 The starting vector.
/// @param[in] v2 The destination vector.
/// @param[in] t The interpolation factor. [Limits: 0 <= value <= 1.0]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Lerp(Span<LFloat> verts, int v1, int v2, LFloat t)
{
return new RcVec3f(
verts[v1 + 0] + (verts[v2 + 0] - verts[v1 + 0]) * t,
verts[v1 + 1] + (verts[v2 + 1] - verts[v1 + 1]) * t,
verts[v1 + 2] + (verts[v2 + 2] - verts[v1 + 2]) * t
);
}
/// Performs a scaled vector addition. (@p v1 + (@p v2 * @p s))
/// @param[out] dest The result vector. [(x, y, z)]
/// @param[in] v1 The base vector. [(x, y, z)]
/// @param[in] v2 The vector to scale and add to @p v1. [(x, y, z)]
/// @param[in] s The amount to scale @p v2 by before adding to @p v1.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Mad(RcVec3f v1, RcVec3f v2, LFloat s)
{
return new RcVec3f()
{
X = v1.X + (v2.X * s),
Y = v1.Y + (v2.Y * s),
Z = v1.Z + (v2.Z * s),
};
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 772dbeed95c448b8835352c77e9063ac
timeCreated: 1715335324

View File

@@ -0,0 +1,58 @@
using System;
using System.Runtime.CompilerServices;
using JNGame.Math;
namespace DotRecast.Core
{
public static class RcArrays
{
// Type Safe Copy
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Copy<T>(T[] sourceArray, long sourceIndex, T[] destinationArray, long destinationIndex, long length)
{
Array.Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length);
}
// Type Safe Copy
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Copy<T>(T[] sourceArray, T[] destinationArray, long length)
{
Array.Copy(sourceArray, destinationArray, length);
}
public static T[] CopyOf<T>(T[] source, int startIdx, int length)
{
var deatArr = new T[length];
for (int i = 0; i < length; ++i)
{
deatArr[i] = source[startIdx + i];
}
return deatArr;
}
public static T[] CopyOf<T>(T[] source, long length)
{
var deatArr = new T[length];
var count = LMath.Max(0, LMath.Min(source.Length, length));
for (int i = 0; i < count; ++i)
{
deatArr[i] = source[i];
}
return deatArr;
}
public static T[][] Of<T>(int len1, int len2)
{
var temp = new T[len1][];
for (int i = 0; i < len1; ++i)
{
temp[i] = new T[len2];
}
return temp;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 15094f0e651644f2877ec4928500f930
timeCreated: 1715335324

View File

@@ -0,0 +1,20 @@

namespace DotRecast.Core
{
public class RcAtomicBoolean
{
private volatile int _location;
public bool Set(bool v)
{
//线程库类 虽然不会影响帧同步 但是显示的使用线程库 这里给它改正常
// return 0 != Interlocked.Exchange(ref _location, v ? 1 : 0);
return 0 != (_location = (v ? 1 : 0));
}
public bool Get()
{
return 0 != _location;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e352ceebd375483799b1bc4d18c6d71f
timeCreated: 1715335324

View File

@@ -0,0 +1,35 @@
using JNGame.Math;
namespace DotRecast.Core
{
public class RcAtomicFloat
{
private LFloat _location;
public RcAtomicFloat(LFloat location)
{
_location = location;
}
public LFloat Get()
{
return _location;
}
public LFloat Exchange(LFloat exchange)
{
_location.rawValue = exchange.rawValue;
return _location;
}
public LFloat CompareExchange(LFloat value, LFloat comparand)
{
if (_location == comparand)
{
_location.rawValue = value.rawValue;
return comparand;
}
return comparand;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1881b83a0db7481f9efc313caa5d2af1
timeCreated: 1715335324

View File

@@ -0,0 +1,71 @@

//备注 因为是帧同步所以不用当心多线程
//线程库类 虽然不会影响帧同步 但是显示的使用线程库 这里给它改正常
//Interlocked.Increment
using JNGame.Util.NoThread;
namespace DotRecast.Core
{
public class RcAtomicInteger
{
// private volatile int _location;
private int _location;
public RcAtomicInteger() : this(0)
{
}
public RcAtomicInteger(int location)
{
_location = location;
}
public int IncrementAndGet()
{
return Interlocked.Increment(ref _location);
}
public int GetAndIncrement()
{
var next = Interlocked.Increment(ref _location);
return next - 1;
}
public int DecrementAndGet()
{
return Interlocked.Decrement(ref _location);
}
public int Read()
{
return _location;
}
public int GetSoft()
{
return _location;
}
public int Exchange(int exchange)
{
return Interlocked.Exchange(ref _location, exchange);
}
public int Decrease(int value)
{
return Interlocked.Add(ref _location, -value);
}
public int CompareExchange(int value, int comparand)
{
return Interlocked.CompareExchange(ref _location, value, comparand);
}
public int Add(int value)
{
return Interlocked.Add(ref _location, value);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 04430b7ad302468286a4d870d761dfc3
timeCreated: 1715335324

View File

@@ -0,0 +1,59 @@
using System;
using JNGame.Util.NoThread;
namespace DotRecast.Core
{
public class RcAtomicLong : IComparable<RcAtomicLong>
{
private long _location;
public RcAtomicLong() : this(0)
{
}
public RcAtomicLong(long location)
{
_location = location;
}
public int CompareTo(RcAtomicLong other)
{
return Read().CompareTo(other.Read());
}
public long IncrementAndGet()
{
return Interlocked.Increment(ref _location);
}
public long DecrementAndGet()
{
return Interlocked.Decrement(ref _location);
}
public long Read()
{
return Interlocked.Read(ref _location);
}
public long Exchange(long exchange)
{
return Interlocked.Exchange(ref _location, exchange);
}
public long Decrease(long value)
{
return Interlocked.Add(ref _location, -value);
}
public long CompareExchange(long value, long comparand)
{
return Interlocked.CompareExchange(ref _location, value, comparand);
}
public long AddAndGet(long value)
{
return Interlocked.Add(ref _location, value);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 46b1a9b82c114f5a8a59778b78d2dc98
timeCreated: 1715335324

View File

@@ -0,0 +1,143 @@
using System;
using System.Buffers.Binary;
using JNGame.Math;
namespace DotRecast.Core
{
public class RcByteBuffer
{
private RcByteOrder _order;
private byte[] _bytes;
private int _position;
public RcByteBuffer(byte[] bytes)
{
_order = BitConverter.IsLittleEndian
? RcByteOrder.LITTLE_ENDIAN
: RcByteOrder.BIG_ENDIAN;
_bytes = bytes;
_position = 0;
}
public RcByteOrder Order()
{
return _order;
}
public void Order(RcByteOrder order)
{
_order = order;
}
public int Limit()
{
return _bytes.Length - _position;
}
public int Remaining()
{
int rem = Limit();
return rem > 0 ? rem : 0;
}
public void Position(int pos)
{
_position = pos;
}
public int Position()
{
return _position;
}
public Span<byte> ReadBytes(int length)
{
var nextPos = _position + length;
(nextPos, _position) = (_position, nextPos);
return _bytes.AsSpan(nextPos, length);
}
public byte Get()
{
var span = ReadBytes(1);
return span[0];
}
public short GetShort()
{
var span = ReadBytes(2);
if (_order == RcByteOrder.BIG_ENDIAN)
{
return BinaryPrimitives.ReadInt16BigEndian(span);
}
else
{
return BinaryPrimitives.ReadInt16LittleEndian(span);
}
}
public int GetInt()
{
var span = ReadBytes(4);
if (_order == RcByteOrder.BIG_ENDIAN)
{
return BinaryPrimitives.ReadInt32BigEndian(span);
}
else
{
return BinaryPrimitives.ReadInt32LittleEndian(span);
}
}
public LFloat GetFloat()
{
var span = ReadBytes(4);
if (_order == RcByteOrder.BIG_ENDIAN && BitConverter.IsLittleEndian)
{
span.Reverse();
}
else if (_order == RcByteOrder.LITTLE_ENDIAN && !BitConverter.IsLittleEndian)
{
span.Reverse();
}
return (LFloat)BitConverter.ToSingle(span);
}
public long GetLong()
{
var span = ReadBytes(8);
if (_order == RcByteOrder.BIG_ENDIAN)
{
return BinaryPrimitives.ReadInt64BigEndian(span);
}
else
{
return BinaryPrimitives.ReadInt64LittleEndian(span);
}
}
public void PutFloat(LFloat v)
{
// if (_order == ByteOrder.BIG_ENDIAN)
// {
// BinaryPrimitives.WriteInt32BigEndian(_bytes[_position]);
// }
// else
// {
// BinaryPrimitives.ReadInt64LittleEndian(span);
// }
// ?
}
public void PutInt(int v)
{
// ?
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 55a26dde34aa4502b9162479487e882f
timeCreated: 1715335324

View File

@@ -0,0 +1,9 @@
namespace DotRecast.Core
{
public enum RcByteOrder
{
/// <summary>Default on most Windows systems</summary>
LITTLE_ENDIAN,
BIG_ENDIAN,
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f221be943ef148d0a81f6ec930f8579b
timeCreated: 1715335324

View File

@@ -0,0 +1,96 @@
/*
recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org
DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
namespace DotRecast.Core
{
public static class RcByteUtils
{
public static int GetInt(byte[] data, int position, RcByteOrder order)
{
return order == RcByteOrder.BIG_ENDIAN ? GetIntBE(data, position) : GetIntLE(data, position);
}
public static int GetIntBE(byte[] data, int position)
{
return ((data[position] & 0xff) << 24)
| ((data[position + 1] & 0xff) << 16)
| ((data[position + 2] & 0xff) << 8)
| (data[position + 3] & 0xff);
}
public static int GetIntLE(byte[] data, int position)
{
return ((data[position + 3] & 0xff) << 24)
| ((data[position + 2] & 0xff) << 16)
| ((data[position + 1] & 0xff) << 8)
| (data[position] & 0xff);
}
public static int GetShort(byte[] data, int position, RcByteOrder order)
{
return order == RcByteOrder.BIG_ENDIAN ? GetShortBE(data, position) : GetShortLE(data, position);
}
public static int GetShortBE(byte[] data, int position)
{
return ((data[position] & 0xff) << 8) | (data[position + 1] & 0xff);
}
public static int GetShortLE(byte[] data, int position)
{
return ((data[position + 1] & 0xff) << 8) | (data[position] & 0xff);
}
public static int PutInt(int value, byte[] data, int position, RcByteOrder order)
{
if (order == RcByteOrder.BIG_ENDIAN)
{
data[position] = (byte)((uint)value >> 24);
data[position + 1] = (byte)((uint)value >> 16);
data[position + 2] = (byte)((uint)value >> 8);
data[position + 3] = (byte)(value & 0xFF);
}
else
{
data[position] = (byte)(value & 0xFF);
data[position + 1] = (byte)((uint)value >> 8);
data[position + 2] = (byte)((uint)value >> 16);
data[position + 3] = (byte)((uint)value >> 24);
}
return position + 4;
}
public static int PutShort(int value, byte[] data, int position, RcByteOrder order)
{
if (order == RcByteOrder.BIG_ENDIAN)
{
data[position] = (byte)((uint)value >> 8);
data[position + 1] = (byte)(value & 0xFF);
}
else
{
data[position] = (byte)(value & 0xFF);
data[position + 1] = (byte)((uint)value >> 8);
}
return position + 2;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 57ba46cf7ef947e88bbed17b7e4cfe46
timeCreated: 1715335324

View File

@@ -0,0 +1,79 @@
/*
recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org
DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
using System.Collections.Generic;
namespace DotRecast.Core
{
/// Provides an interface for optional logging and performance tracking of the Recast
/// build process.
///
/// This class does not provide logging or timer functionality on its
/// own. Both must be provided by a concrete implementation
/// by overriding the protected member functions. Also, this class does not
/// provide an interface for extracting log messages. (Only adding them.)
/// So concrete implementations must provide one.
///
/// If no logging or timers are required, just pass an instance of this
/// class through the Recast build process.
///
/// @ingroup recast
public class RcContext
{
// private readonly ThreadLocal<Dictionary<string, RcAtomicLong>> _timerStart;
// private readonly ConcurrentDictionary<string, RcAtomicLong> _timerAccum;
public RcContext()
{
// _timerStart = new ThreadLocal<Dictionary<string, RcAtomicLong>>(() => new Dictionary<string, RcAtomicLong>());
// _timerAccum = new ConcurrentDictionary<string, RcAtomicLong>();
}
public RcScopedTimer ScopedTimer(RcTimerLabel label)
{
return new RcScopedTimer(this, label);
}
public void StartTimer(RcTimerLabel label)
{
// _timerStart.Value[label.Name] = new RcAtomicLong(RcFrequency.Ticks);
}
public void StopTimer(RcTimerLabel label)
{
// _timerAccum
// .GetOrAdd(label.Name, _ => new RcAtomicLong(0))
// .AddAndGet(RcFrequency.Ticks - _timerStart.Value?[label.Name].Read() ?? 0);
}
public void Warn(string message)
{
// Console.WriteLine(message);
}
public List<RcTelemetryTick> ToList()
{
// return _timerAccum
// .Select(x => new RcTelemetryTick(x.Key, x.Value.Read()))
// .ToList();
return null;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4c29a750f91746acb93cf1a57852ffcb
timeCreated: 1715335324

View File

@@ -0,0 +1,104 @@
/*
recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org
DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
using System.Collections.Generic;
using DotRecast.Core.Numerics;
using JNGame.Math;
namespace DotRecast.Core
{
public static class RcConvexUtils
{
// Calculates convex hull on xz-plane of points on 'pts',
// stores the indices of the resulting hull in 'out' and
// returns number of points on hull.
public static List<int> Convexhull(List<RcVec3f> pts)
{
int npts = pts.Count;
List<int> @out = new List<int>();
// Find lower-leftmost point.
int hull = 0;
for (int i = 1; i < npts; ++i)
{
if (Cmppt(pts[i], pts[hull]))
{
hull = i;
}
}
// Gift wrap hull.
int endpt = 0;
do
{
@out.Add(hull);
endpt = 0;
for (int j = 1; j < npts; ++j)
{
RcVec3f a = pts[hull];
RcVec3f b = pts[endpt];
RcVec3f c = pts[j];
if (hull == endpt || Left(a, b, c))
{
endpt = j;
}
}
hull = endpt;
} while (endpt != @out[0]);
return @out;
}
// Returns true if 'a' is more lower-left than 'b'.
private static bool Cmppt(RcVec3f a, RcVec3f b)
{
if (a.X < b.X)
{
return true;
}
if (a.X > b.X)
{
return false;
}
if (a.Z < b.Z)
{
return true;
}
if (a.Z > b.Z)
{
return false;
}
return false;
}
// Returns true if 'c' is left of line 'a'-'b'.
private static bool Left(RcVec3f a, RcVec3f b, RcVec3f c)
{
LFloat u1 = b.X - a.X;
LFloat v1 = b.Z - a.Z;
LFloat u2 = c.X - a.X;
LFloat v2 = c.Z - a.Z;
return u1 * v2 - v1 * u2 < 0;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b017645b9f6a4b13a5f4ce9d7bfdbee6
timeCreated: 1715335324

View File

@@ -0,0 +1,57 @@
using System.IO;
using System.Linq;
namespace DotRecast.Core
{
public static class RcDirectory
{
public static string SearchPath(string searchPath, int depth, out bool isDir)
{
isDir = false;
for (int i = 0; i < depth; ++i)
{
var relativePath = string.Join("", Enumerable.Range(0, i).Select(x => "../"));
var searchingPath = Path.Combine(relativePath, searchPath);
var fullSearchingPath = Path.GetFullPath(searchingPath);
if (File.Exists(fullSearchingPath))
{
return fullSearchingPath;
}
if (Directory.Exists(fullSearchingPath))
{
isDir = true;
return fullSearchingPath;
}
}
return string.Empty;
}
// only directory
public static string SearchDirectory(string dirname, int depth = 10)
{
var searchingPath = SearchPath(dirname, depth, out var isDir);
if (isDir)
{
return searchingPath;
}
var path = Path.GetDirectoryName(searchingPath) ?? string.Empty;
return path;
}
public static string SearchFile(string filename, int depth = 10)
{
var searchingPath = SearchPath(filename, depth, out var isDir);
if (!isDir)
{
return searchingPath;
}
return string.Empty;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2ca1481e33684803a4c06a1da5d427fa
timeCreated: 1715335324

View File

@@ -0,0 +1,9 @@
namespace DotRecast.Core
{
public class RcEdge
{
public int[] vert = new int[2];
public int[] polyEdge = new int[2];
public int[] poly = new int[2];
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 18cc11d1ded0437a80fc1e4165b803ed
timeCreated: 1715335324

View File

@@ -0,0 +1,12 @@
using System;
using System.Diagnostics;
using JNGame.Math;
namespace DotRecast.Core
{
public static class RcFrequency
{
public static readonly LFloat Frequency = (LFloat)TimeSpan.TicksPerSecond / Stopwatch.Frequency;
public static long Ticks => unchecked((long)(Stopwatch.GetTimestamp() * Frequency));
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ccb02c961d7a4ec28cd3994523e26d3c
timeCreated: 1715335324

View File

@@ -0,0 +1,26 @@
using System.Runtime.CompilerServices;
namespace DotRecast.Core
{
public static class RcHashCodes
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int CombineHashCodes(int h1, int h2)
{
return (((h1 << 5) + h1) ^ h2);
}
// From Thomas Wang, https://gist.github.com/badboy/6267743
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint WangHash(uint a)
{
a = (~a) + (a << 18); // a = (a << 18) - a - 1;
a = a ^ (a >> 31);
a = a * 21; // a = (a + (a << 2)) + (a << 4);
a = a ^ (a >> 11);
a = a + (a << 6);
a = a ^ (a >> 22);
return (uint)a;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6854614122244005aed0f22d69548e5f
timeCreated: 1715335324

View File

@@ -0,0 +1,135 @@
/*
Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
recast4j copyright (c) 2021 Piotr Piastucki piotr@jtilia.org
DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
using System;
using DotRecast.Core.Numerics;
using JNGame.Math;
namespace DotRecast.Core
{
public static class RcIntersections
{
public static bool IntersectSegmentTriangle(RcVec3f sp, RcVec3f sq, RcVec3f a, RcVec3f b, RcVec3f c, out LFloat t)
{
t = 0;
LFloat v, w;
RcVec3f ab = RcVec3f.Subtract(b, a);
RcVec3f ac = RcVec3f.Subtract(c, a);
RcVec3f qp = RcVec3f.Subtract(sp, sq);
// Compute triangle normal. Can be precalculated or cached if
// intersecting multiple segments against the same triangle
RcVec3f norm = RcVec3f.Cross(ab, ac);
// Compute denominator d. If d <= 0, segment is parallel to or points
// away from triangle, so exit early
LFloat d = RcVec3f.Dot(qp, norm);
if (d <= 0.0f)
{
return false;
}
// Compute intersection t value of pq with plane of triangle. A ray
// intersects iff 0 <= t. Segment intersects iff 0 <= t <= 1. Delay
// dividing by d until intersection has been found to pierce triangle
RcVec3f ap = RcVec3f.Subtract(sp, a);
t = RcVec3f.Dot(ap, norm);
if (t < 0.0f)
{
return false;
}
if (t > d)
{
return false; // For segment; exclude this code line for a ray test
}
// Compute barycentric coordinate components and test if within bounds
RcVec3f e = RcVec3f.Cross(qp, ap);
v = RcVec3f.Dot(ac, e);
if (v < 0.0f || v > d)
{
return false;
}
w = -RcVec3f.Dot(ab, e);
if (w < 0.0f || v + w > d)
{
return false;
}
// Segment/ray intersects triangle. Perform delayed division
t /= d;
return true;
}
public static bool IsectSegAABB(RcVec3f sp, RcVec3f sq, RcVec3f amin, RcVec3f amax, out LFloat tmin, out LFloat tmax)
{
LFloat EPS = LFloat.EPSILON;
RcVec3f d = new RcVec3f();
d.X = sq.X - sp.X;
d.Y = sq.Y - sp.Y;
d.Z = sq.Z - sp.Z;
tmin = (LFloat)0.0f;
tmax = LFloat.MaxValue;
for (int i = 0; i < 3; i++)
{
if (LMath.Abs(d.Get(i)) < EPS)
{
if (sp.Get(i) < amin.Get(i) || sp.Get(i) > amax.Get(i))
{
return false;
}
}
else
{
LFloat ood = (LFloat)1.0f / d.Get(i);
LFloat t1 = (amin.Get(i) - sp.Get(i)) * ood;
LFloat t2 = (amax.Get(i) - sp.Get(i)) * ood;
if (t1 > t2)
{
(t1, t2) = (t2, t1);
}
if (t1 > tmin)
{
tmin = t1;
}
if (t2 < tmax)
{
tmax = t2;
}
if (tmin > tmax)
{
return false;
}
}
}
return true;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3bf8fb6577034f66b97fbd3699614550
timeCreated: 1715335324

View File

@@ -0,0 +1,34 @@
/*
Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org
DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
using System.Runtime.CompilerServices;
using JNGame.Math;
namespace DotRecast.Core
{
public static class RcMath
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static LFloat Sqr(LFloat f)
{
return f * f;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 298b7e8a14e346b6bc9589c9844a7d45
timeCreated: 1715335324

View File

@@ -0,0 +1,133 @@
/*
recast4j Copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org
DotRecast Copyright (c) 2023 Choi Ikpil ikpil@naver.com
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
using System;
using System.Globalization;
using System.IO;
using DotRecast.Core.Numerics;
using JNGame.Math;
namespace DotRecast.Core
{
public static class RcObjImporter
{
public static RcObjImporterContext LoadContext(byte[] chunk)
{
RcObjImporterContext context = new RcObjImporterContext();
try
{
using StreamReader reader = new StreamReader(new MemoryStream(chunk));
string line;
while ((line = reader.ReadLine()) != null)
{
line = line.Trim();
ReadLine(line, context);
}
}
catch (Exception e)
{
throw new Exception(e.Message, e);
}
return context;
}
public static void ReadLine(string line, RcObjImporterContext context)
{
if (line.StartsWith("v"))
{
ReadVertex(line, context);
}
else if (line.StartsWith("f"))
{
ReadFace(line, context);
}
}
private static void ReadVertex(string line, RcObjImporterContext context)
{
if (line.StartsWith("v "))
{
var vert = ReadVector3f(line);
context.vertexPositions.Add(vert.X);
context.vertexPositions.Add(vert.Y);
context.vertexPositions.Add(vert.Z);
}
}
private static RcVec3f ReadVector3f(string line)
{
string[] v = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (v.Length < 4)
{
throw new Exception("Invalid vector, expected 3 coordinates, found " + (v.Length - 1));
}
// fix - https://github.com/ikpil/DotRecast/issues/7
return new RcVec3f(
LFloat.Parse(v[1], CultureInfo.InvariantCulture),
LFloat.Parse(v[2], CultureInfo.InvariantCulture),
LFloat.Parse(v[3], CultureInfo.InvariantCulture)
);
}
private static void ReadFace(string line, RcObjImporterContext context)
{
string[] v = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (v.Length < 4)
{
throw new Exception("Invalid number of face vertices: 3 coordinates expected, found " + v.Length);
}
for (int j = 0; j < v.Length - 3; j++)
{
context.meshFaces.Add(ReadFaceVertex(v[1], context));
for (int i = 0; i < 2; i++)
{
context.meshFaces.Add(ReadFaceVertex(v[2 + j + i], context));
}
}
}
private static int ReadFaceVertex(string face, RcObjImporterContext context)
{
string[] v = face.Split("/");
return GetIndex(int.Parse(v[0]), context.vertexPositions.Count);
}
private static int GetIndex(int posi, int size)
{
if (posi > 0)
{
posi--;
}
else if (posi < 0)
{
posi = size + posi;
}
else
{
throw new Exception("0 vertex index");
}
return posi;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4d88ceffb1fb4221862fcdd7bb403153
timeCreated: 1715335324

View File

@@ -0,0 +1,11 @@
using System.Collections.Generic;
using JNGame.Math;
namespace DotRecast.Core
{
public class RcObjImporterContext
{
public List<LFloat> vertexPositions = new List<LFloat>();
public List<int> meshFaces = new List<int>();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 293436c829af46ad9f6fd7c7e4beb449
timeCreated: 1715335324

View File

@@ -0,0 +1,34 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DotRecast.Core
{
public static class RcProcess
{
public static void OpenUrl(string url)
{
try
{
// OS에 따라 다른 명령 실행
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var psi = new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true };
Process.Start(psi);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", url);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Process.Start("xdg-open", url);
}
}
catch (Exception ex)
{
Console.WriteLine($"Error opening web browser: {ex.Message}");
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 13122b6072164e2d841cdd5157acdb24
timeCreated: 1715335324

View File

@@ -0,0 +1,33 @@
using JNGame.Math;
namespace DotRecast.Core
{
public class RcRand : IRcRand
{
private JNGame.Math.Random _random = new();
public RcRand()
{
}
public RcRand(long seed)
{
}
public LFloat Next()
{
return _random.Range((LFloat)0f,(LFloat)1f);
}
public LFloat NextDouble()
{
return _random.Range((LFloat)0f,(LFloat)1f);
}
public int NextInt32()
{
return (int)_random.Next();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 87746d362a99461691759dd3b2219a0a
timeCreated: 1715335324

View File

@@ -0,0 +1,22 @@
using System.IO;
namespace DotRecast.Core
{
public static class RcResources
{
public static byte[] Load(string filename)
{
var filepath = filename;
if (!File.Exists(filepath))
{
filepath = RcDirectory.SearchFile($"resources/{filename}");
}
using var fs = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
return buffer;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: afe3a5344ed34416977ebd0de6980f7b
timeCreated: 1715335324

View File

@@ -0,0 +1,23 @@
using System;
namespace DotRecast.Core
{
public readonly struct RcScopedTimer : IDisposable
{
private readonly RcContext _context;
private readonly RcTimerLabel _label;
internal RcScopedTimer(RcContext context, RcTimerLabel label)
{
_context = context;
_label = label;
_context.StartTimer(_label);
}
public void Dispose()
{
_context.StopTimer(_label);
}
}
}

Some files were not shown because too many files have changed in this diff Show More