Ejemplo n.º 1
0
        //public SharedBlockIndexData GetSharedIndexData(int terrEdgeSize)
        //{
        //    SharedBlockIndexData result;
        //    if (!sharedIBCache.TryGetValue(terrEdgeSize, out result ))
        //    {
        //        result = new SharedBlockIndexData(renderSystem, terrEdgeSize);
        //        sharedIBCache.Add(terrEdgeSize, result);
        //    }
        //    return result;
        //}
        /// <summary>
        ///  Create a terrain mesh at the given tile-based coordinate and with a given size.
        /// </summary>
        /// <param name="rs"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="size">The size can be either 33 or 17</param>
        /// <returns></returns>
        public ResourceHandle <TerrainMesh> CreateInstance(RenderSystem rs, int x, int y, int size)
        {
            if (!loaded)
            {
                lock (syncHelper)
                {
                    if (!loaded)
                    {
                        loaded       = true;
                        renderSystem = rs;

                        index33 = new SharedIndexData(rs, 33);
                        index17 = new SharedIndexData(rs, 17);
                        //SharedBlockIndexData sharedIdxBuffer1025 = new SharedBlockIndexData(rs, 513);
                        //SharedBlockIndexData sharedIdxBuffer257 = new SharedBlockIndexData(rs, 129);
                        //SharedBlockIndexData sharedIdxBuffer65 = new SharedBlockIndexData(rs, 33);
                        //sharedIBCache.Add(513, sharedIdxBuffer1025);
                        //sharedIBCache.Add(129, sharedIdxBuffer257);
                        //sharedIBCache.Add(33, sharedIdxBuffer65);
                    }
                }
            }
            Resource retrived = base.Exists(TerrainMesh.GetHashString(x, y, size));

            if (retrived == null)
            {
                TerrainMesh mdl = new TerrainMesh(rs, x, y, size);
                retrived = mdl;
                base.NotifyResourceNew(mdl);
            }
            //else
            //{
            //    retrived.Use();
            //}
            return(new ResourceHandle <TerrainMesh>((TerrainMesh)retrived));
        }
Ejemplo n.º 2
0
        //public SharedBlockIndexData GetSharedIndexData(int terrEdgeSize) 
        //{
        //    SharedBlockIndexData result;
        //    if (!sharedIBCache.TryGetValue(terrEdgeSize, out result ))
        //    {
        //        result = new SharedBlockIndexData(renderSystem, terrEdgeSize);
        //        sharedIBCache.Add(terrEdgeSize, result);
        //    }
        //    return result;
        //}
        /// <summary>
        ///  Create a terrain mesh at the given tile-based coordinate and with a given size.
        /// </summary>
        /// <param name="rs"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="size">The size can be either 33 or 17</param>
        /// <returns></returns>
        public ResourceHandle<TerrainMesh> CreateInstance(RenderSystem rs, int x, int y, int size)
        {
            if (!loaded)
            {
                lock (syncHelper)
                {
                    if (!loaded)
                    {
                        loaded = true;
                        renderSystem = rs;

                        index33 = new SharedIndexData(rs, 33);
                        index17 = new SharedIndexData(rs, 17);
                        //SharedBlockIndexData sharedIdxBuffer1025 = new SharedBlockIndexData(rs, 513);
                        //SharedBlockIndexData sharedIdxBuffer257 = new SharedBlockIndexData(rs, 129);
                        //SharedBlockIndexData sharedIdxBuffer65 = new SharedBlockIndexData(rs, 33);
                        //sharedIBCache.Add(513, sharedIdxBuffer1025);
                        //sharedIBCache.Add(129, sharedIdxBuffer257);
                        //sharedIBCache.Add(33, sharedIdxBuffer65);
                    }
                }
            }
            Resource retrived = base.Exists(TerrainMesh.GetHashString(x, y, size));
            if (retrived == null)
            {
                TerrainMesh mdl = new TerrainMesh(rs, x, y, size);
                retrived = mdl;
                base.NotifyResourceNew(mdl);
            }
            //else
            //{
            //    retrived.Use();
            //}
            return new ResourceHandle<TerrainMesh>((TerrainMesh)retrived);
        }