Example #1
0
        public bool ExecuteTask()
        {
            lock (mInstLock)
            {
                if (mIsHalted)
                {
                    return(true);
                }

                if (WaitingInstances.Count > 0)
                {
                    for (int i = 0; WaitingInstances.Count > 0; ++i)
                    {
                        var data = WaitingInstances.First();
                        ActiveInstances.Add(data);
                        WaitingInstances.Remove(data);
                    }
                    if (Renderer.InstanceDataBuffer != null)
                    {
                        Renderer.InstanceDataBuffer.Dispose();
                    }
                    int size = Marshal.SizeOf(typeof(Models.MDX.MdxInstanceData));
                    Renderer.InstanceDataBuffer = new VertexBuffer(Game.GameManager.GraphicsThread.GraphicsManager.Device, ActiveInstances.Count * size, Usage.WriteOnly, VertexFormat.Diffuse, Pool.Managed);
                    DataStream strm = Renderer.InstanceDataBuffer.Lock(0, 0, LockFlags.None);
                    Models.MDX.MdxInstanceData[] InstData = ActiveInstances.ToArray();
                    strm.WriteRange(InstData);
                    Renderer.InstanceDataBuffer.Unlock();
                    Renderer.numInstances = ActiveInstances.Count;
                }
            }
            return(WaitingInstances.Count == 0);
        }
Example #2
0
        public GameObject Pop()
        {
            if (ReservedInstances.Count == 0)
            {
                Generate();
            }

            var instance = ReservedInstances.Dequeue();

            ActiveInstances.Add(instance);

            if (EventPop != null)
            {
                EventPop(this, instance);
            }

            return(instance);
        }
 public GRendererResourceManager()
 {
     billboardMeshes = new Dictionary <BillboardAsset, Mesh>();
     ActiveInstances.Add(this);
 }