protected override void Process(HashSet <Entity> changedChunks, NativeMultiHashMap <Entity, Entity> changedVolumesPerChunk)
        {
            var allVolumes = changedVolumesPerChunk.GetValueArray(Allocator.TempJob);

            foreach (var chunk in changedChunks)
            {
                var volumes = EntityManager.GetBuffer <ChunkVolumes>(chunk);
                var index   = 0;

                while (index < volumes.Length)
                {
                    var found = NativeArrayExtensions.IndexOf(allVolumes, volumes[index].VolumeEntity);
                    if (found >= 0)
                    {
                        volumes.RemoveAt(index);
                    }
                    else
                    {
                        index++;
                    }
                }
            }

            allVolumes.Dispose();
        }
Ejemplo n.º 2
0
        public void Execute()
        {
            var keys = IntersectionsToRoadsMap.GetKeyArray(Allocator.Temp);

            for (int i = 1, startIndex = 0; i <= keys.Length; i++)
            {
                if (i != keys.Length && keys[i] == keys[i - 1])
                {
                    continue;
                }
                RoadConnectionRanges.Add(new RoadConnectionArrayRange
                {
                    IntersectionEntity = keys[i - 1],
                    StartIndex         = startIndex,
                    Length             = i - startIndex
                });
                startIndex = i;
            }
            keys.Dispose();

            var values = IntersectionsToRoadsMap.GetValueArray(Allocator.Temp);

            RoadConnections.AddRange(values);
            values.Dispose();
        }
Ejemplo n.º 3
0
        public void Execute()
        {
            if (SplitIndicesMap.Count() == 0)
            {
                return;
            }

            var roadIndices          = SplitIndicesMap.GetKeyArray(Allocator.Temp);
            var intersectionMetaData = SplitIndicesMap.GetValueArray(Allocator.Temp);

            // Sort intersection metadata by spline interpolation factor
            for (var i = 1; i < roadIndices.Length; i++)
            {
                var j         = i - 1;
                var prevIndex = roadIndices[j];
                while (i < roadIndices.Length && roadIndices[i] == prevIndex)
                {
                    i++;
                }
                var subArray = intersectionMetaData.GetSubArray(j, i - j);
                subArray.Sort(new IntersectionPointComparer());
            }

            IntersectionMetaData.AddRange(intersectionMetaData);
            intersectionMetaData.Dispose();

            RemoveDuplicateIntersectionRecords(roadIndices);
            roadIndices.Dispose();

            // Identify all unique intersection points and save them to a list
            for (var i = 0; i < IntersectionMetaData.Length; i++)
            {
                var foundDuplicate          = false;
                var metaData                = IntersectionMetaData[i];
                var intersectionEntityIndex = 0;

                // Search all known unique intersection points for a duplicate
                for (var j = 0; j < UniqueIntersectionPoints.Length; j++)
                {
                    if (!Utilities.GeometryUtility.ApproximatelyEqual(UniqueIntersectionPoints[j], metaData.Point))
                    {
                        continue;
                    }
                    foundDuplicate          = true;
                    intersectionEntityIndex = j;
                    break;
                }

                if (!foundDuplicate)
                {
                    UniqueIntersectionPoints.Add(metaData.Point);
                    intersectionEntityIndex = UniqueIntersectionPoints.Length - 1;
                }

                metaData.IntersectionEntityIndex = intersectionEntityIndex;
                IntersectionMetaData[i]          = metaData;
            }
        }
Ejemplo n.º 4
0
        public List <Node> GetChildren(Node node)
        {
            var result = new List <Node>();
            var values = _nodeToParent.GetValueArray(Allocator.Temp);

            foreach (var edge in values)
            {
                if (edge.Parent.Equals(node))
                {
                    result.Add(edge.Child);
                }
            }
            values.Dispose();
            return(result);
        }
    public void NativeMultiHashMap_GetValues()
    {
        var hashMap = new NativeMultiHashMap <int, int> (1, Allocator.Temp);

        for (int i = 0; i < 30; ++i)
        {
            hashMap.Add(i, 30 + i);
            hashMap.Add(i, 60 + i);
        }
        var values = hashMap.GetValueArray(Allocator.Temp);

        hashMap.Dispose();

        Assert.AreEqual(60, values.Length);
        values.Sort();
        for (int i = 0; i < 60; ++i)
        {
            Assert.AreEqual(30 + i, values[i]);
        }
        values.Dispose();
    }
Ejemplo n.º 6
0
        public void Execute()
        {
            if (MaterialToSubMeshMap.Count() == 0)
            {
                return;
            }

            // Copy the values array of MaterialToSubMeshMap to the SubMeshRecords NativeList
            {
                var subMeshRecords = MaterialToSubMeshMap.GetValueArray(Allocator.Temp);
                SubMeshRecords.AddRange(subMeshRecords);
                SubMeshMap.ResizeUninitialized(SubMeshRecords.Length);
                subMeshRecords.Dispose();
            }

            var keys = MaterialToSubMeshMap.GetKeyArray(Allocator.Temp);

            for (var i = 0; i < SubMeshRecords.Length; i++)
            {
                var subMesh = SubMeshRecords[i];
                SubMeshMap[i] = new MappedSubMeshIndices
                {
                    TriangleIndexOffset = m_TriangleIndexOffset,
                    VertexStartIndex    = m_VertexCount,
                    TriangleStartIndex  = m_TriangleCount
                };
                m_VertexCount         += subMesh.VertexCount;
                m_TriangleCount       += subMesh.TriangleCount;
                m_TriangleIndexOffset += subMesh.VertexCount;

                var material = keys[i];
                if (i == SubMeshRecords.Length - 1 || material != keys[i + 1])
                {
                    AddSubMesh(material);
                }
            }

            Vertices.ResizeUninitialized(m_VertexCount);
            Triangles.ResizeUninitialized(m_TriangleCount);
        }
Ejemplo n.º 7
0
        // PRIVATES METHODS

        private void CreateCommandsQueries()
        {
            if (commands.Length > 0)
            {
                var priorities = commands.GetKeyArray(Allocator.Temp);
                var values     = commands.GetValueArray(Allocator.Temp);

                priorities.Sort();

                for (int i = 0; i < priorities.Length; ++i)
                {
                    var priority = priorities[i];
                    var value    = values[i];

                    CacheCommandType(value, priority);
                }

                priorities.Dispose();
                values.Dispose();
            }

            commands.Clear();
        }
Ejemplo n.º 8
0
 public void Execute()
 {
     MultiHashmap.GetValueArray(Array);
 }