void Update() { //every 10 frame update once if (m_Camera == null || m_Root == null || !m_Camera.enabled || !m_Dirty) { return; } m_Dirty = false; Plane[] planes = GeometryUtility.CalculateFrustumPlanes(m_Camera);//视景平面 得到摄像机视锥 mVisiblePatches.Reset(); //transform 为玩家中心点 m_Root.GetVisibleMesh(planes, transform.position, lodPolicy, mVisiblePatches); m_PatchesFlipBuffer.Clear(); for (int i = 0; i < mVisiblePatches.Length; ++i) { uint pId = mVisiblePatches.Data[i]; if (m_ActivePatches.ContainsKey(pId)) { m_PatchesFlipBuffer.Add(pId, m_ActivePatches[pId]); m_ActivePatches.Remove(pId); } else { //new patches Mesh m = GetMesh(pId); if (m != null) { MTPatch patch = MTPatch.Pop(m_Header.RuntimeMats); patch.gameObject.transform.SetParent(m_Go.transform); patch.Reset(pId, m); m_PatchesFlipBuffer.Add(pId, patch); } } } Dictionary <uint, MTPatch> .Enumerator iPatch = m_ActivePatches.GetEnumerator(); while (iPatch.MoveNext()) { MTPatch.Push(iPatch.Current.Value); } m_ActivePatches.Clear(); Dictionary <uint, MTPatch> temp = m_PatchesFlipBuffer; m_PatchesFlipBuffer = m_ActivePatches; m_ActivePatches = temp; }
public static void Push(MTPatch p) { p.gameObject.SetActive(false); _qPool.Enqueue(p); }
private void OnDestroy() { MTPatch.Clear(); }
public static void Push(MTPatch p) { p.mGo.SetActive(false); _qPool.Enqueue(p); }