Esempio n. 1
0
        internal Entity FindOrCreateRenderGroup(BuildGroup key)
        {
            Entity e = Entity.Null;

            if (m_buildGroups.TryGetValue(key, out e))
            {
                return(e);
            }

            // gather all passes
            // This whole thing is temporary; this perf is not great but only happens at startup
            var q = GetEntityQuery(ComponentType.ReadOnly <RenderPass>());

            using (var allPasses = q.ToEntityArray(Allocator.TempJob)) {
                e = EntityManager.CreateEntity();
                EntityManager.AddComponent <RenderGroup>(e);
                EntityManager.AddComponentData <BuildGroup>(e, key);
                var groupTargetPasses = EntityManager.AddBuffer <RenderToPassesEntry>(e);
                m_buildGroups.TryAdd(key, e);
                for (int i = 0; i < allPasses.Length; i++)
                {
                    var ePass = allPasses[i];
                    var pass  = EntityManager.GetComponentData <RenderPass>(ePass);
                    if (((uint)pass.passType & (uint)key.passTypes) == 0)
                    {
                        continue;
                    }
                    groupTargetPasses.Add(new RenderToPassesEntry {
                        e = ePass
                    });
                }
            }

            return(e);
        }
Esempio n. 2
0
        private Entity FindOrCreateRenderGroup(BuildGroup key)
        {
            Entity e = Entity.Null;

            if (m_buildGroups.TryGetValue(key, out e))
            {
                return(e);
            }
            else
            {
                e = EntityManager.CreateEntity();
                EntityManager.AddComponent <RenderGroup>(e);
                EntityManager.AddComponentData <BuildGroup>(e, key);
                var groupTargetPasses = EntityManager.AddBuffer <RenderToPassesEntry>(e);
                m_buildGroups.TryAdd(key, e);
                for (int i = 0; i < m_allPasses.Length; i++)
                {
                    var ePass = m_allPasses[i];
                    var pass  = EntityManager.GetComponentData <RenderPass>(ePass);
                    if (((uint)pass.passType & (uint)key.passTypes) == 0)
                    {
                        continue;
                    }
                    groupTargetPasses.Add(new RenderToPassesEntry {
                        e = ePass
                    });
                }
                return(e);
            }
        }
Esempio n. 3
0
        public void AddItemToRenderGroup(Entity item, BuildGroup key)
        {
            var group = FindOrCreateRenderGroup(key);

            OptionalSetSharedComponent(item, new RenderToPasses {
                e = group
            });
        }