public virtual void SortSystemUpdateList()
        {
            CheckCreated();

            if (!UseLegacySortOrder)
            {
                throw new InvalidOperationException("UseLegacySortOrder must be true to use the SortSystemUpdateList() legacy API");
            }

            if (!m_systemSortDirty)
            {
                return;
            }

            m_systemSortDirty = false;

            RemovePending();

            foreach (var sys in m_systemsToUpdate)
            {
                if (TypeManager.IsSystemAGroup(sys.GetType()))
                {
                    RecurseUpdate((ComponentSystemGroup)sys);
                }
            }

            var elems = new ComponentSystemSorter.SystemElement[m_systemsToUpdate.Count];

            for (int i = 0; i < m_systemsToUpdate.Count; ++i)
            {
                elems[i] = new ComponentSystemSorter.SystemElement
                {
                    Type           = m_systemsToUpdate[i].GetType(),
                    Index          = new UpdateIndex(i, true),
                    OrderingBucket = 1,
                    updateBefore   = new List <Type>(),
                    nAfter         = 0,
                };
            }

            ComponentSystemSorter.FindConstraints(GetType(), elems);

            ComponentSystemSorter.Sort(elems);

            var oldSystems = m_systemsToUpdate;

            m_systemsToUpdate = new List <ComponentSystemBase>(oldSystems.Count);
            m_MasterUpdateList.Clear();
            for (int i = 0; i < elems.Length; ++i)
            {
                var index = elems[i].Index;
                m_systemsToUpdate.Add(oldSystems[index.Index]);
                m_MasterUpdateList.Add(new UpdateIndex(i, true));
            }
        }
Exemple #2
0
    public unsafe void UnsafeList_TrimExcess()
    {
        var sizeOf  = UnsafeUtility.SizeOf <int>();
        var alignOf = UnsafeUtility.AlignOf <int>();

        using (var list = new UnsafeList(sizeOf, alignOf, 32, Allocator.Persistent, NativeArrayOptions.ClearMemory))
        {
            var capacity = list.Capacity;

            list.Add(1);
            list.TrimExcess <int>();
            Assert.AreEqual(1, list.Length);
            Assert.AreEqual(1, list.Capacity);

            list.RemoveAtSwapBack <int>(0);
            Assert.AreEqual(list.Length, 0);
            list.TrimExcess <int>();
            Assert.AreEqual(list.Capacity, 0);

            list.Add(1);
            Assert.AreEqual(list.Length, 1);
            Assert.AreNotEqual(list.Capacity, 0);

            list.Clear();
        }
    }
Exemple #3
0
        public void UpdateChunkCollections()
        {
            ActiveArchetypeChunks.Clear();
            ActiveFullArchetypeChunks.Clear();
            ActivePartialArchetypeChunk.Clear();
            InactiveFullArchetypeChunks.Clear();
            InactivePartialArchetypeChunk.Clear();

            for (int i = 0; i < ActiveChunks.ChunkCount; i++)
            {
                var archetypeChunk = ActiveChunks.GetArchetypeChunk(i);
                if (archetypeChunk.Full)
                {
                    ActiveFullArchetypeChunks.Add(archetypeChunk);
                }
                else
                {
                    ActivePartialArchetypeChunk.Add(archetypeChunk);
                }
                ActiveArchetypeChunks.Add(archetypeChunk);
            }

            for (int i = 0; i < InactiveChunks.ChunkCount; i++)
            {
                var archetypeChunk = InactiveChunks.GetArchetypeChunk(i);
                if (archetypeChunk.Full)
                {
                    InactiveFullArchetypeChunks.Add(archetypeChunk);
                }
                else
                {
                    InactivePartialArchetypeChunk.Add(archetypeChunk);
                }
            }
        }
 public void Clear()
 {
     if (sections.IsCreated)
     {
         sections.Clear();
     }
 }
Exemple #5
0
 public void Reset()
 {
     vertices.Clear();
     visibleOuterLines.Clear();
     surfaceVisibleOuterLines.Clear();
     surfaceVisibleOuterLineRanges.Clear();
     hash = 0;
 }
        public void UnsafeListAdd()
        {
            for (int i = 0; i < COUNTMAX; i++)
            {
                UnsafeList.Add(uList, i);
            }

            UnsafeList.Clear(uList);
        }
 public void Clear()
 {
     CreateChunks.Clear();
     AddComponentToChunks.Clear();
     RemoveComponentFromChunks.Clear();
     AddComponentBatches.Clear();
     RemoveComponentBatches.Clear();
     ChunkScratch.Reset();
     BatchScratch.Reset();
 }
        void ResetSharedComponentData()
        {
            m_HashLookup.Clear();
            m_SharedComponentData.Clear();
            m_SharedComponentInfo.Clear();

            m_SharedComponentData.Add(null);
            m_SharedComponentInfo.Add(new SharedComponentInfo {
                RefCount = 1, ComponentType = -1, Version = 1, HashCode = 0
            });
            m_FreeListIndex = -1;
        }
Exemple #9
0
 public void Clear()
 {
     if (idToIndex.IsCreated)
     {
         idToIndex.Clear();
     }
     if (indexToID.IsCreated)
     {
         indexToID.Clear();
     }
     if (sectionManager.IsCreated)
     {
         sectionManager.Clear();
     }
     if (freeIDs.IsCreated)
     {
         freeIDs.Clear();
     }
 }
Exemple #10
0
 private unsafe void Clear()
 {
     RenderTarget.Clear();
     for (int i = 0; i < _linePrimitives.Count; i++)
     {
         PrimitiveHelper.Free(_linePrimitives.GetPointer(i));
     }
     _linePrimitives.Clear();
     for (int i = 0; i < _trianglePrimitives.Count; i++)
     {
         PrimitiveHelper.Free(_trianglePrimitives.GetPointer(i));
     }
     _trianglePrimitives.Clear();
     for (int i = 0; i < _rasterizedFragments.Count; i++)
     {
         _rasterizedFragments[i].Free();
     }
     _rasterizedFragments.Clear();
     _renderedColors.Clear();
 }
Exemple #11
0
        private void RemovePending()
        {
            if (m_systemsToRemove.Count > 0)
            {
                foreach (var sys in m_systemsToRemove)
                {
                    m_systemsToUpdate.Remove(sys);
                }

                m_systemsToRemove.Clear();
            }

            for (int i = 0; i < m_UnmanagedSystemsToRemove.Length; ++i)
            {
                var sysHandle = m_UnmanagedSystemsToRemove[i];
                m_UnmanagedSystemsToUpdate.RemoveAt(m_UnmanagedSystemsToUpdate.IndexOf(sysHandle));
            }

            m_UnmanagedSystemsToRemove.Clear();
        }
Exemple #12
0
    public unsafe void UnsafeList_Resize_Zero()
    {
        var sizeOf  = UnsafeUtility.SizeOf <int>();
        var alignOf = UnsafeUtility.AlignOf <int>();

        UnsafeList list     = new UnsafeList(sizeOf, alignOf, 5, Allocator.Persistent, NativeArrayOptions.ClearMemory);
        var        capacity = list.Capacity;

        list.Add(1);
        list.Resize <int>(0);
        Assert.AreEqual(0, list.Length);
        Assert.AreEqual(capacity, list.Capacity); // list capacity should not change on resize

        list.Add(2);
        list.Clear();
        Assert.AreEqual(0, list.Length);
        Assert.AreEqual(capacity, list.Capacity); // list capacity should not change on resize

        list.Dispose();
    }
Exemple #13
0
        /// <summary>
        /// Clears this layer.
        /// </summary>
        internal void ClearObjects()
        {
            // Clear objects on all view subsets
            foreach (var actViewSubset in _viewSubsets)
            {
                actViewSubset.ClearAllSubscriptions(this.ObjectsInternal);
            }

            foreach (var actObject in this.ObjectsInternal)
            {
                actObject.UnloadResources();
                actObject.ResetSceneAndLayer();
            }

            this.ObjectsInternal.Clear();

            // Clear specialized collections
            _sceneObjectsNotSpacial.Clear();
            this.SpacialObjects.Clear();
            _sceneObjectsNotStatic.Clear();
        }
Exemple #14
0
 internal void InvalidateDependents()
 {
     if (!NeedsUseAfterFreeTracking())
     {
         return;
     }
     for (var i = 0; i < ChildSafetyHandles.Length; ++i)
     {
         unsafe
         {
             AtomicSafetyHandle *handle = ChildSafetyHandles.Ptr + i;
             if (CheckExists(*handle))
             {
                 AtomicSafetyHandle.Release(*handle);
             }
         }
     }
     ChildSafetyHandles.Clear();
     if (Parent.IsValid)
     {
         Parent.TryRemoveChildAllocator(this, IndexInParent);
     }
     Parent        = default;
     IndexInParent = InvalidChildAllocatorIndex;
     for (var i = 0; i < ChildAllocators.Length; ++i)
     {
         unsafe
         {
             AllocatorHandle *handle = (AllocatorHandle *)ChildAllocators.Ptr + i;
             if (handle->IsValid)
             {
                 handle->Unregister();
             }
         }
     }
     ChildAllocators.Clear();
 }
Exemple #15
0
 private static void Clear()
 {
     _pixelCoords.Clear();
     _fragmentData.Clear();
 }
Exemple #16
0
        private UnsafeList <Byte> Read()
        {
            _reader = new TiffReader(_tiff);

            (Int32 animationType, AMAnimation[] animations, AMFrame[] frames) = GetMetadata(_tiff);

            try
            {
                ReadPages();

                _header.AnimationType = animationType;

                _header.AnimationCount    = animations.Length;
                _header.FrameCount        = frames.Length;
                _header.PaletteCount      = _palettes.Count;
                _header.ImageHeaderCount  = _images.Count;
                _header.ImageContentSize  = (Int32)_content.Length;
                _header.ImageSegmentCount = _segments.Count;
                _header.ImageLineCount    = _lines.Count;

                unsafe
                {
                    _result.SetPosition(sizeof(AMHeader));

                    _header.AnimationOffset = CurrentPosition;
                    _result.WriteStructs(animations);

                    _header.FrameOffset = CurrentPosition;
                    _result.WriteStructs(frames);

                    _header.PaletteOffset = CurrentPosition;
                    _result.WriteStructs(_palettes.GetBuffer());

                    _header.ImageHeaderOffset = CurrentPosition;
                    _result.WriteStructs(_images.GetBuffer());

                    _header.ImageContentOffset = CurrentPosition;
                    _content.SetPosition(0);
                    _content.CopyTo(_result);

                    _header.ImageSegmentOffset = CurrentPosition;
                    _result.WriteStructs(_segments.GetBuffer());

                    _header.ImageLineOffset = CurrentPosition;
                    _result.WriteStructs(_lines.GetBuffer());

                    _result.SetPosition(0);
                    _result.WriteStruct(_header);
                }

                if (!_result.TryGetBuffer(out var result))
                {
                    throw new NotSupportedException();
                }

                return(new UnsafeList <Byte>(result));
            }
            finally
            {
                _images.Clear();
                _paletteMaps.Clear();
                _palettes.Clear();
                _segments.Clear();
                _lines.Clear();

                _contentOffset = 0;
                _content.SetLength(0);
                _result.SetLength(0);
            }
        }
 private static void PrepareList(UnsafeList <float> list, int interpolationCount)
 {
     list.Clear();
     list.AddEmpty(interpolationCount);
 }
Exemple #18
0
        private void RecurseUpdate(ComponentSystemGroup group)
        {
            if (!m_systemSortDirty)
            {
                return;
            }

            RemovePending();

            var groupType        = GetType();
            var allElems         = new ComponentSystemSorter.SystemElement[m_systemsToUpdate.Count + m_UnmanagedSystemsToUpdate.Length];
            var systemsPerBucket = new int[3];

            for (int i = 0; i < m_systemsToUpdate.Count; ++i)
            {
                var system         = m_systemsToUpdate[i];
                var sysType        = system.GetType();
                int orderingBucket = ComputeSystemOrdering(sysType, groupType);
                allElems[i] = new ComponentSystemSorter.SystemElement
                {
                    Type           = sysType,
                    Index          = new UpdateIndex(i, true),
                    OrderingBucket = orderingBucket,
                    updateBefore   = new List <Type>(),
                    nAfter         = 0,
                };
                systemsPerBucket[orderingBucket]++;
            }
            for (int i = 0; i < m_UnmanagedSystemsToUpdate.Length; ++i)
            {
                var sysType        = World.GetTypeOfUnmanagedSystem(m_UnmanagedSystemsToUpdate[i]);
                int orderingBucket = ComputeSystemOrdering(sysType, groupType);
                allElems[m_systemsToUpdate.Count + i] = new ComponentSystemSorter.SystemElement
                {
                    Type           = sysType,
                    Index          = new UpdateIndex(i, false),
                    OrderingBucket = orderingBucket,
                    updateBefore   = new List <Type>(),
                    nAfter         = 0,
                };
                systemsPerBucket[orderingBucket]++;
            }

            // Find & validate constraints between systems in the group
            ComponentSystemSorter.FindConstraints(groupType, allElems);

            // Build three lists of systems
            var elemBuckets = new []
            {
                new ComponentSystemSorter.SystemElement[systemsPerBucket[0]],
                new ComponentSystemSorter.SystemElement[systemsPerBucket[1]],
                new ComponentSystemSorter.SystemElement[systemsPerBucket[2]],
            };
            var nextBucketIndex = new int[3];

            for (int i = 0; i < allElems.Length; ++i)
            {
                int bucket = allElems[i].OrderingBucket;
                int index  = nextBucketIndex[bucket]++;
                elemBuckets[bucket][index] = allElems[i];
            }
            // Perform the sort for each bucket.
            for (int i = 0; i < 3; ++i)
            {
                if (elemBuckets[i].Length > 0)
                {
                    ComponentSystemSorter.Sort(elemBuckets[i]);
                }
            }

            // Because people can freely look at the list of managed systems, we need to put that part of list in order.
            var oldSystems = m_systemsToUpdate;

            m_systemsToUpdate = new List <ComponentSystemBase>(oldSystems.Count);
            for (int i = 0; i < 3; ++i)
            {
                foreach (var e in elemBuckets[i])
                {
                    var index = e.Index;
                    if (index.IsManaged)
                    {
                        m_systemsToUpdate.Add(oldSystems[index.Index]);
                    }
                }
            }

            // Commit results to master update list
            m_MasterUpdateList.Clear();
            m_MasterUpdateList.SetCapacity(allElems.Length);

            // Append buckets in order, but replace managed indices with incrementing indices
            // into the newly sorted m_systemsToUpdate list
            int managedIndex = 0;

            for (int i = 0; i < 3; ++i)
            {
                foreach (var e in elemBuckets[i])
                {
                    if (e.Index.IsManaged)
                    {
                        m_MasterUpdateList.Add(new UpdateIndex(managedIndex++, true));
                    }
                    else
                    {
                        m_MasterUpdateList.Add(e.Index);
                    }
                }
            }

            m_systemSortDirty = false;

            foreach (var sys in m_systemsToUpdate)
            {
                if (TypeManager.IsSystemAGroup(sys.GetType()))
                {
                    RecurseUpdate((ComponentSystemGroup)sys);
                }
            }
        }
Exemple #19
0
 public void Clear()
 {
     UnsafeList.Clear(m_inner);
 }