コード例 #1
0
    public void CreateFinalMesh()
    {
        if (meshData == null)
        {
            return;
        }
        mesh = meshData.CreateMesh(MeshData.TYPE_NORMAL);
        Mesh XplusPatchMesh = meshData.CreateMesh(MeshData.TYPE_X_NORMAL_PLUS);

        GetComponent <MeshFilter>().mesh = mesh;


        if (parent != null)
        {
            if (parent.isSplitting)
            {
                parent.childrenReady++;
                if (parent.childrenReady == 8)
                {
                    Destroy(parent.GetComponent <MeshFilter>().mesh);
                    parent.mesh          = null;
                    parent.childrenReady = 0;
                    parent.isSplitting   = false;
                    //DCManager.chunkDictionary.Remove(parent.transform.position);
                    DCManager.removeChunkFromList(this);
                    DCManager.greenLight = true;
                }
            }
        }
        else
        {
            if (manager.isSplitting)
            {
                manager.childrenReady++;
                if (manager.childrenReady == 8)
                {
                    Destroy(parent.GetComponent <MeshFilter>().mesh);
                    manager.GetComponent <MeshFilter>().mesh = null;
                    manager.childrenReady = 0;
                    manager.isSplitting   = false;
                    DCManager.greenLight  = true;
                }
            }
        }

        if (isRestoringParent)
        {
            int k = children.Count;
            for (int i = 0; i < k; i++)
            {
                Destroy(children[i].gameObject);
                //DCManager.chunkDictionary.Remove(children[i].transform.position);
                //DCManager.chunkList.Remove(children[i]);
                DCManager.removeChunkFromList(children[i]);
            }

            children.Clear();
            isRestoringParent = false;
        }
    }
コード例 #2
0
    public void OnMeshDataReceived(MeshData meshData)
    {
        // Debug.Log("mesh data received");
        if (meshData == null)
        {
            return;
        }
        mesh = meshData.CreateMesh(MeshData.TYPE_NORMAL);
        GetComponent <MeshFilter>().mesh = mesh;


        if (parent != null)
        {
            if (parent.isSplitting)
            {
                parent.childrenReady++;
                if (parent.childrenReady == 8)
                {
                    Destroy(parent.GetComponent <MeshFilter>().mesh);
                    parent.mesh          = null;
                    parent.childrenReady = 0;
                    parent.isSplitting   = false;
                    DCManager.chunkDictionary.Remove(parent.transform.position);
                    DCManager.greenLight = true;
                }
            }
        }
        else
        {
            if (manager.isSplitting)
            {
                manager.childrenReady++;
                if (manager.childrenReady == 8)
                {
                    Destroy(parent.GetComponent <MeshFilter>().mesh);
                    manager.GetComponent <MeshFilter>().mesh = null;
                    manager.childrenReady = 0;
                    manager.isSplitting   = false;
                    DCManager.greenLight  = true;
                }
            }
        }

        if (isRestoringParent)
        {
            int k = children.Count;
            for (int i = 0; i < k; i++)
            {
                Destroy(children[i].gameObject);
                DCManager.chunkDictionary.Remove(children[i].transform.position);
            }

            children.Clear();
            isRestoringParent = false;
        }

        Mesh XplusPatchMesh = meshData.CreateMesh(MeshData.TYPE_X_NORMAL_PLUS);


        DCManager.chunkDictionary.Add(transform.position, this);
    }