Пример #1
0
 public ChunkCache(Game game)
     : base(game)
 {
     m_logger = MainEngine.GetEngineInstance().GetLogger("ChunkCache");
     Debug.Assert(game != null);
     var graphicsDevice = game.GraphicsDevice;
     Debug.Assert(ViewRange < CacheRange);
     Debug.Assert(graphicsDevice != null);
     Blocks = new Block[CacheSizeInBlocks * CacheSizeInBlocks * CacheSizeInBlocks];
     m_lightingEngine = new CellularLighting<Block>(Blocks, BlockIndexByWorldPosition, Chunk.SizeInBlocks, GetChunkByWorldPosition);
     m_vertexBuilder = new VertexBuilder<Block>(Blocks, BlockIndexByWorldPosition, graphicsDevice);
     m_chunkStorage = new SparseArray3D<Chunk>(CacheRange * 2 + 1, CacheRange * 2 + 1);
     m_cacheCenterPosition = new Vector4();
     m_eventSinkImpl = new EventSinkImpl ();
     m_eventSinkImpl.AddHandler<Vector3Args>(EventConstants.PlayerPositionUpdated, OnUpdateCachePosition);
     m_startUpState = StartUpState.NotStarted;
     m_processingQueue = new Queue<Chunk>();
     m_EditQueue = new ConcurrentQueue<WorldEdit>();
     #if DEBUG
     StateStatistics = new Dictionary<ChunkState, int> // init. the debug stastics.
                                {
                                    {ChunkState.AwaitingGenerate, 0},
                                    {ChunkState.Generating, 0},
                                    {ChunkState.AwaitingLighting, 0},
                                    {ChunkState.Lighting, 0},
                                    {ChunkState.AwaitingBuild, 0},
                                    {ChunkState.Building, 0},
                                    {ChunkState.Ready, 0},
                                    {ChunkState.AwaitingRemoval, 0},
                                };
     #endif
 }
Пример #2
0
        public void UniqueValuesCube()
        {
            var cube = UniqueCube;

            SparseArray3D <int> arr = new SparseArray3D <int>(cube);

            AssertEqual(cube, arr);
        }
Пример #3
0
        public void IdenticalValuesCube()
        {
            var cube = IdenticalCube(123);

            SparseArray3D <int> arr = new SparseArray3D <int>(cube);

            AssertEqual(cube, arr);

            var snap = arr.TreeSnapshot();

            Assert.AreEqual(NodeType.Leaf, snap.Type);
        }
Пример #4
0
 private void SetAll(int[, ,] values, SparseArray3D <int> arr)
 {
     for (uint x = 0; x < values.GetLength(0); x++)
     {
         for (uint y = 0; y < values.GetLength(1); y++)
         {
             for (uint z = 0; z < values.GetLength(2); z++)
             {
                 arr[x, y, z] = values[x, y, z];
             }
         }
     }
 }
Пример #5
0
        private void AssertEqual(int[, ,] cube, SparseArray3D <int> arr)
        {
            for (uint x = 0; x < cube.GetLength(0); x++)
            {
                for (uint y = 0; y < cube.GetLength(1); y++)
                {
                    for (uint z = 0; z < cube.GetLength(2); z++)
                    {
                        string pos = String.Format("[{0}, {1}, {2}]", x, y, z);

                        Assert.AreEqual(cube[x, y, z], arr[x, y, z], pos);
                    }
                }
            }
        }
Пример #6
0
        public void ChangingValuesCube()
        {
            SparseArray3D <int> arr = new SparseArray3D <int>(CubeLength, CubeLength, CubeLength);

            var uniqueCube = UniqueCube;

            SetAll(uniqueCube, arr);
            AssertEqual(uniqueCube, arr);

            var identCube = IdenticalCube(123);

            SetAll(identCube, arr);
            AssertEqual(identCube, arr);

            var snap = arr.TreeSnapshot();

            Assert.AreEqual(NodeType.Leaf, snap.Type);
        }
Пример #7
0
 public RenderShim(Column column, Patch patch)
 {
     _column = column;
     Patch   = patch;
     _items  = PoolManager.GetObjectPool <SparseArray3D <LightBlockItem> >().Pop();
 }