using System; using System.Collections.Generic; using Unity.Collections; using Unity.Collections.LowLevel.Unsafe; using VRM.FastSpringBones.Blittables; namespace VRM.FastSpringBones.NativeWrappers { /// /// BlittablePointsGroupのライフサイクルを管理するWrapper /// public sealed unsafe class NativePoints : IDisposable { private readonly NativePointer _nativePointer; private NativeArray _buffer; public BlittablePoints* GetUnsafePtr() => _nativePointer.GetUnsafePtr(); public NativePoints(IList> points) { _buffer = new NativeArray(points.Count, Allocator.Persistent); for (var i = 0; i < _buffer.Length; ++i) { _buffer[i] = points[i].Value; } _nativePointer = new NativePointer(new BlittablePoints((BlittablePoint*) _buffer.GetUnsafePtr(), _buffer.Length)); } public void Dispose() { if (_buffer.IsCreated) { _buffer.Dispose(); } _nativePointer.Dispose(); } } }