Beispiel #1
0
    public IEnumerator computeIsosurfaceAsyn()
    {
        int chunksRebuilt = 0;

        if (chunkDataList == null)
        {
            yield break;
        }
        Mesh ret;

        for (int i = 0; i < chunkDataList.Count; i++)
        {
            if (chunkDataList[i] != null && chunkDataList[i].Length > 0)
            {
                swBlock45.setInputChunkData(chunkDataList[i]);
//				MonoBehaviour.print("blocks in chunk : " + B45ChunkData.numDots_d(chunkDataList[i]));
                ret = swBlock45.RebuildMeshSM();
                usedMaterialIndicesList.Add(swBlock45.getMaterialMap());
                outputMesh.Add(ret);

//				retbm = swBlock45.RebuildMeshByMaterial();
//				outputMeshByMaterial.Add(retbm);
                chunksRebuilt++;
                if ((chunksRebuilt % Block45Constants.NumChunksPerFrame) == 0)
                {
                    chunksRebuilt = 0;
                    yield return(0);
                }
            }
        }
        chunkDataList.Clear();
    }
    public void Exec()
    {
        reqToProceed = null;
        lock (_reqList)
            reqToProceed = PickReqToProceed();
        if (reqToProceed == null)
        {
            return;
        }

        swBlock45.setInputChunkData(_chunkDataToProceed);
        swBlock45.Rebuild();

        SurfExtractReqB45 req = reqToProceed as SurfExtractReqB45;
        //usedMaterialIndicesList.Add(swBlock45.getMaterialMap());

        int chunkTotalVerts = swBlock45.verts.Count;

        if (chunkTotalVerts > 0)
        {
            int chunkVertsCntThreshold = reqToProceed.MeshSplitThreshold;
            if (chunkTotalVerts <= chunkVertsCntThreshold)
            {
                req.verts       = swBlock45.verts.ToArray();
                req.uvs         = swBlock45.uvs.ToArray();
                req.matCnt      = swBlock45.matCnt;
                req.materialMap = swBlock45.materialMap;
                foreach (List <int> indice in swBlock45.subMeshIndices)
                {
                    req.subMeshIndices.Add(indice.ToArray());
                }
            }
            else
            {
                Debug.LogError("[SurfB45_CPU]:Out Of chunkVertsCntThreshold.");
            }
        }

        lock (_reqFinishedList)
            _reqFinishedList.Add(reqToProceed);
        _chunkDataToProceed = null;
    }