Esempio n. 1
0
    public void WriteToByteArray(int x, int y, int z, byte b0, byte b1)
    {
        if (_nData != null && _nData.IsInReq)
        {
            if (_chkData == null)
            {
                _chkData = s_ChunkDataPool.Get();
                Array.Clear(_chkData, 0, _chkData.Length);
            }

            int idx = Block45Kernel.OneIndexNoPrefix(x, y, z);
            _chkData[idx]     = b0;
            _chkData[idx + 1] = b1;
            if (_nData.LOD == 0)
            {
                SceneChunkDependence.Instance.ValidListRemove(_nData.ChunkPosLod, EDependChunkType.ChunkBlkMask);
            }
            _nData.AddToBuildList(this);
        }
        else if (_chkData != null)
        {
            int idx = Block45Kernel.OneIndexNoPrefix(x, y, z);
            _chkData[idx]     = b0;
            _chkData[idx + 1] = b1;
        }
    }
Esempio n. 2
0
 public void init()
 {
     swBlock45               = new Block45Kernel();
     outputMesh              = new List <Mesh>();
     outputMeshByMaterial    = new List <List <Mesh> >();
     chunkDataList           = new List <byte[]>();
     usedMaterialIndicesList = new List <int[]>();
 }
Esempio n. 3
0
 public static void BlockVectors2ChunkData(List <BlockVector> list, byte[] chunkData)
 {
     Array.Clear(chunkData, 0, chunkData.Length);
     for (int i = 0; i < list.Count; i++)
     {
         BlockVector bv  = list[i];
         int         idx = Block45Kernel.OneIndexNoPrefix(bv.x, bv.y, bv.z);
         chunkData[idx]     = bv.byte0;
         chunkData[idx + 1] = bv.byte1;
     }
 }
Esempio n. 4
0
 public byte[] BlockVecs2ByteArray()
 {
     byte[] chunkData = s_ChunkDataPool.Get();
     Array.Clear(chunkData, 0, chunkData.Length);
     for (int i = 0; i < _vecData.Count; i++)
     {
         BlockVec bv  = _vecData[i];
         int      idx = Block45Kernel.OneIndexNoPrefix(bv.x, bv.y, bv.z);
         chunkData[idx]     = bv._byte0;
         chunkData[idx + 1] = bv._byte1;
     }
     return(chunkData);
 }
    public void Init()
    {
        //MCOutputData.InitConstData();
        swBlock45           = new Block45Kernel();
        _chunkDataBuffer    = new byte[Block45Constants.VOXEL_ARRAY_LENGTH_VT];
        _chunkDataToProceed = null;
        _reqList            = new Dictionary <int, IVxSurfExtractReq>();
        _reqFinishedList    = new List <IVxSurfExtractReq>();
        Pause = false;

                #if B45_THREADING
        _threadB45 = new Thread(new ThreadStart(ThreadExec));
        _threadB45.Start();
                #endif
    }
    public int  FillMesh(Mesh mesh)
    {
        if (mesh == null)
        {
            return((verts != null && verts.Length > 0) ? 1 : 0);
        }

        mesh.name         = "b45_mesh";
        mesh.vertices     = verts;
        mesh.uv           = uvs;
        mesh.subMeshCount = matCnt;
        for (int i = 0; i < matCnt; i++)
        {
            mesh.SetTriangles(subMeshIndices[i], i);
        }

        mesh.RecalculateNormals();
        //MonoBehaviour.print("rebuild mesh took " + (Environment.TickCount - before) + " ms.");
        Block45Kernel.TangentSolver(mesh);
        return(0);
    }
Esempio n. 7
0
    public List <BlockVec> ByteArray2BlockVecs()
    {
        List <BlockVec> blvec = new List <BlockVec>();

        if (_chkData != null)
        {
            for (int z = 0; z < Block45Constants.VOXEL_ARRAY_AXIS_SIZE; z++)
            {
                for (int y = 0; y < Block45Constants.VOXEL_ARRAY_AXIS_SIZE; y++)
                {
                    for (int x = 0; x < Block45Constants.VOXEL_ARRAY_AXIS_SIZE; x++)
                    {
                        int idx = Block45Kernel.OneIndexNoPrefix(x, y, z);
                        if (_chkData[idx] != 0)
                        {
                            blvec.Add(new BlockVec(x, y, z, _chkData[idx], _chkData[idx + 1]));
                        }
                    }
                }
            }
        }
        return(blvec);
    }
Esempio n. 8
0
    public static List <BlockVector> ChunkData2BlockVectors(byte[] chunkData)
    {
        //if(chunkData.Length == 0){
        //	int sdg = 0;
        //}
        List <BlockVector> blvec = new List <BlockVector>();

        for (int z = 0; z < Block45Constants.VOXEL_ARRAY_AXIS_SIZE; z++)
        {
            for (int y = 0; y < Block45Constants.VOXEL_ARRAY_AXIS_SIZE; y++)
            {
                for (int x = 0; x < Block45Constants.VOXEL_ARRAY_AXIS_SIZE; x++)
                {
                    int idx = Block45Kernel.OneIndexNoPrefix(x, y, z);
                    if (chunkData[idx] != 0)
                    {
                        blvec.Add(new BlockVector(x, y, z, chunkData[idx], chunkData[idx + 1]));
                    }
                }
            }
        }
        return(blvec);
    }