Ejemplo n.º 1
0
        private void updateSuperBatch()
        {
            int oldCount = 0;

            if (superBatch != null)
            {
                oldCount = superBatch.EntityCount;
            }

            var entities = new List <Entity>();

            foreach (var ent in TW.Data.Objects.Where(o => o is Entity).Select(o => (Entity)o))
            {
                if (ent.Mesh == null)
                {
                    continue;
                }
                if (!ent.Visible)
                {
                    continue;
                }
                if (!ent.get <BatchInfo>().ShouldBatch(time))
                {
                    continue;
                }

                entities.Add(ent);
            }

            if (entities.Count - oldCount <= 20)
            {
                return;
            }

            destroySuperBatch();
            superBatch = new Batch();
            foreach (var ent in entities)
            {
                superBatch.AddEntity(ent);
            }
            superBatch.Build();
        }