コード例 #1
0
ファイル: ChunkCache.cs プロジェクト: HaKDMoDz/4DBlockEngine
 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
ファイル: Sky.cs プロジェクト: HaKDMoDz/4DBlockEngine
 public override void Initialize(GraphicsDevice graphicsDevice, Camera camera, GetTimeOfDay getTimeOfDay, GetFogVector getFogVector)
 {
     base.Initialize(graphicsDevice, camera, getTimeOfDay, getFogVector);
     m_vertexBuilder = new VertexBuilder<CloudBlock>(m_clouds, CloudIndexByWorldPosition, m_graphicsDevice, Scale);
     //TODO: create general task pool (with priority) and put this in it.
     Task.Run(() =>
     {
         while (true)
         {
             StepClouds();
             foreach (var cloudVertexTarget in m_cloudVertexTargets)
             {
                 m_vertexBuilder.Build(cloudVertexTarget);
             }
             Thread.Sleep(100);
         }
     // ReSharper disable once FunctionNeverReturns
     });
 }