/// <summary> /// 将页表置为非活跃状态 /// </summary> private void InvalidatePage(Vector2Int id) { TableNode node = null; if (!m_ActivePages.TryGetValue(id, out node)) { return; } node.Payload.ResetTileIndex(); m_ActivePages.Remove(id); }
/// <summary> /// 加载页表 /// </summary> private void LoadPage(int x, int y, TableNode node) { if (node == null) { return; } // 正在加载中,不需要重复请求 if (node.Payload.LoadRequest != null) { return; } // 新建加载请求 node.Payload.LoadRequest = m_Loader.Request(x, y, node.MipLevel); }
public void CreatePagePointer(int x, int y, TableNode node) { if (node == null) { return; } if (node.Payload.tileStatus == TileStatus.Loading || node.Payload.tileStatus == TileStatus.LoadingComplete) { return; } node.Payload.tileStatus = TileStatus.Loading; int key = getKey(node.Rect.x, node.Rect.y, node.MipLevel); m_Pages[key] = node; tileGenerator.GeneratePageTask(key); }
void Start() { if (m_TableSize < 1 || (m_TableSize & m_TableSize - 1) != 0) { m_TableSize = 64; } quadRootKey = getKey(0, 0, MaxMipLevel); m_LookupTexture = new Texture2D(TableSize, TableSize, TextureFormat.RGBA32, false); m_LookupTexture.wrapMode = TextureWrapMode.Clamp; m_LookupTexture.filterMode = FilterMode.Point; Shader.SetGlobalTexture("_LOOKUPTEX", m_LookupTexture); Shader.SetGlobalFloat("_MAXMIP", MaxMipLevel); Shader.SetGlobalFloat("_PAGETABLESIZE", TableSize); Shader.SetGlobalInt("_DEBUG", m_DebugMode); tileGenerator = (TileGeneration)GetComponent(typeof(TileGeneration)); physicalTiles = (PhysicalTexture)GetComponent(typeof(PhysicalTexture)); feedBack = (Feedback)GetComponent(typeof(Feedback)); AddressMapping = new Dictionary <int, PhysicalTileInfo>(); ChildList = new Dictionary <int, int[]>(); feedBack.OnFeedbackReadComplete += ProcessFeedbackCoroutine; InCoroutine = false; //tileGenerator.OnTileGenerationComplete += OnGenerationComplete; tileGenerator.OnTileGenerationComplete += OnGenerationCompletePointer; //FOR POINTER quadRoot = new TableNode(MaxMipLevel, 0, 0, TableSize, TableSize); m_Pages = new Dictionary <int, TableNode>(); //multiple quad trees quadRoots = new TableNode[m_TerrainDivision * m_TerrainDivision]; /*for(int i = 0; i < m_TerrainDivision; i++) * { * for (int j = 0; j < m_TerrainDivision; j++) { * //quadRoots[i] = new TableNode(MaxMipLevel, i ) * } * }*/ }