Ejemplo n.º 1
0
    public static void SwitchToVxCpu(List <IVxSurfExtractReq> reqsInProcess, Dictionary <int, IVxSurfExtractReq> reqsToProcess)
    {
        Debug.LogError("[SurfExtractMan]: Start to switch to Cpu !");
        SurfExtractorCpuMC vxCpu = new SurfExtractorCpuMC();

        vxCpu.Init();
        _vxSurfExtractor = vxCpu;               // To avoid AddReq when vxCpu not Init
        lock (reqsToProcess) {
            for (int i = 0; i < reqsInProcess.Count; i++)
            {
                _vxSurfExtractor.AddSurfExtractReq(reqsInProcess [i]);
            }
            foreach (KeyValuePair <int, IVxSurfExtractReq> pair in reqsToProcess)
            {
                _vxSurfExtractor.AddSurfExtractReq(pair.Value);
            }
            Debug.LogError("[SurfExtractMan]: Finished to switch to Cpu:" + (reqsInProcess.Count + reqsToProcess.Count));
        }
    }
Ejemplo n.º 2
0
    public void ThreadBuildTransExec()
    {
        surfExtractorTrans.Init();

        List <IntVector4>       locTransPosList   = new List <IntVector4>();
        List <VFVoxelChunkData> locTransChunkList = new List <VFVoxelChunkData>();

        while (bTransVoxelEnabled)
        {
            if (curStatus == ETransBuildStatus.Status_ToBuild)
            {
                locTransPosList   = transRebuildList.Keys.ToList();
                locTransChunkList = transRebuildList.Values.ToList();
                for (int i = 0; i < locTransChunkList.Count; i++)
                {
                    VFVoxelChunkData cdata = locTransChunkList[i];
                    //if(cdata.LOD != 0)	continue;
                    if (cdata.LOD == LODOctreeMan._maxLod || null == (System.Object)cdata.ChunkGo)
                    {
                        continue;
                    }
                    int oldFaceMask = null == (System.Object)cdata.ChunkGo.TransvoxelGo ? 0 : cdata.ChunkGo.TransvoxelGo._faceMask;
                    int faceMask    = 0;
                    int curLod      = cdata.LOD;
                    int posMask     = (-1) << (curLod + 1);
                    for (int dirIdx = 0; dirIdx < Transvoxel.Lengyel.Tables.TransitionFaceDir.Length; dirIdx++)
                    {
                        IntVector3 unitOfs = Transvoxel.Lengyel.Tables.TransitionFaceDir[dirIdx];
                        IntVector4 nearLow = new IntVector4((cdata.ChunkPosLod.x + (unitOfs.x << curLod)) & posMask,
                                                            (cdata.ChunkPosLod.y + (unitOfs.y << curLod)) & posMask,
                                                            (cdata.ChunkPosLod.z + (unitOfs.z << curLod)) & posMask,
                                                            curLod + 1);
                        if (locTransPosList.Contains(nearLow))
                        {
                            faceMask |= 1 << dirIdx;
                        }
                    }
                    if (faceMask == oldFaceMask)
                    {
                        continue;
                    }
                    surfExtractorTrans.AddSurfExtractReq(new SurfExtractReqTrans(faceMask, cdata));
                }
                surfExtractorTrans.Exec();
                curStatus = ETransBuildStatus.Status_FinBuild;
            }

            System.Threading.Thread.Sleep(16);
        }
        curStatus = ETransBuildStatus.Status_Idle;
    }