Beispiel #1
0
        public static void RemoveRange <T>(this NativeListArray <T> .NativeList list, int index, int count) where T : unmanaged
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            AtomicSafetyHandle.CheckWriteAndThrow(list.m_Safety);
#endif
            if (count == 0)
            {
                return;
            }
            if (index < 0 || index + count > list.Length)
            {
                LogRangeError();
                return;
            }
            if (index == 0 && count == list.Length)
            {
                list.Clear();
                return;
            }

            if (index + count < list.Length)
            {
                var listPtr = (T *)list.GetUnsafePtr();
                int size    = sizeof(T);
                UnsafeUtility.MemMove(listPtr + index, listPtr + (index + count), (list.Length - (index + count)) * size);
            }
            list.Resize(list.Length - count, NativeArrayOptions.ClearMemory);
        }
        // TODO: find a way to share found intersections between loops, to avoid accuracy issues
        public unsafe void Execute()
        {
            if (edges.Length < 3)
            {
                return;
            }

            var inputEdgesLength = edges.Length;
            var inputEdges       = stackalloc Edge[inputEdgesLength];   // (Edge*)UnsafeUtility.Malloc(edges.Length * sizeof(Edge), 4, Allocator.TempJob);

            UnsafeUtility.MemCpyReplicate(inputEdges, edges.GetUnsafePtr(), sizeof(Edge) * edges.Length, 1);
            edges.Clear();

            var tempVertices = stackalloc ushort[] { 0, 0, 0, 0 };

            ref var otherPlanesNative = ref brushTreeSpacePlanes[otherBrushNodeIndex].Value.treeSpacePlanes;  // allTreeSpacePlanePtr + otherPlanesSegment.x;
            ref var selfPlanesNative  = ref brushTreeSpacePlanes[selfBrushNodeIndex].Value.treeSpacePlanes;   //allTreeSpacePlanePtr + selfPlanesSegment.x;