private void InitMaterialProperties() { ExposedMaterialProperties properties = MaterialProperties; properties.SetRenderRadius(GlobalSettings.Instance.RenderRadius); properties.SetAmbientColor(GlobalSettings.Instance.DefaultAmbientColor); }
public ChunkManager(WorldSettings settings, Camera mainCamera, Transform player, string chunkSavingDirectory, Material solidMaterial, Material liquidMaterial) { m_ChunkPositionComparer = new ChunkPositionComparer(); m_Chunks = new ConcurrentDictionary <Vector2Int, Chunk>(m_ChunkPositionComparer); m_ChunksToLoad = new ConcurrentQueue <Vector2Int>(); m_ChunksToUnload = new ConcurrentQueue <Vector2Int>(); m_ChunkLoader = new ChunkLoader(settings.Seed, chunkSavingDirectory, settings.Type); m_BuildAndUnloadChunksThread = new Thread(BuildAndUnloadChunksThreadMethod) { IsBackground = true }; m_ChunksToRender = new HashSet <Vector2Int>(m_ChunkPositionComparer); m_UpdateChunksThread = new Thread(UpdateChunksThreadMethod) { IsBackground = true }; m_BlocksToTickQueue = new Queue <Vector3Int>(); m_TickBlockInterval = 0.5f; m_TickBlockDeltaTime = 0; m_BlocksToLightQueue = new Stack <Vector3Int>(); m_TickChunkRandom = new Random(settings.Seed); m_TickChunkInterval = 2; m_TickChunkDeltaTime = 0; m_PlayerPositionX = 0; m_PlayerPositionY = 0; m_PlayerPositionZ = 0; m_PlayerForwardX = 0; m_PlayerForwardZ = 0; m_ChunksUpdatingRequired = false; m_RenderChunkRadius = GlobalSettings.Instance.RenderChunkRadius; m_SqrRenderRadius = m_RenderChunkRadius * m_RenderChunkRadius * ChunkWidth * ChunkWidth; m_HorizontalFOVInDEG = GlobalSettings.Instance.HorizontalFOVInDEG; m_MaxChunkCountInMemory = GlobalSettings.Instance.MaxChunkCountInMemory; m_SharedSolidMaterial = solidMaterial; m_SharedLiquidMaterial = liquidMaterial; m_MainCamera = mainCamera; m_MainCamera.farClipPlane = GlobalSettings.Instance.RenderRadius; m_PlayerTransform = player; MaterialProperties = new ExposedMaterialProperties(new MaterialPropertyBlock(), new MaterialPropertyBlock()); InitMaterialProperties(); m_IsStartUp = true; m_Disposed = false; #if UNITY_EDITOR m_BuildAndUnloadChunksThread.Name = "Build And Unload Chunks Thread"; m_UpdateChunksThread.Name = "Update Chunks Thread"; #endif }