Exemple #1
0
    void Update()
    {
        //Vector3Int pos = new Vector3Int(Mathf.FloorToInt((Player.transform.position.x + (maxsize)) / maxsize), Mathf.FloorToInt((Player.transform.position.y + (maxsize )) / maxsize), Mathf.FloorToInt((Player.transform.position.z + (maxsize )) / maxsize));
        Vector3Int pos = new Vector3Int(Mathf.FloorToInt((Player.transform.position.x) / maxsize), Mathf.FloorToInt((Player.transform.position.y) / maxsize), Mathf.FloorToInt((Player.transform.position.z) / maxsize));

        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                for (int k = -1; k <= 1; k++)
                {
                    Vector3Int ss = new Vector3Int(((pos.x + i) % 3 + 3) % 3, ((pos.y + j) % 3 + 3) % 3, ((pos.z + k) % 3 + 3) % 3);
                    if (ChunkGrid[ss.x, ss.y, ss.z].Position != new Vector3((pos.x + i), (pos.y + j), (pos.z + k)))
                    {
                        Pool.Release(ChunkGrid[ss.x, ss.y, ss.z]);
                        ChunkGrid[ss.x, ss.y, ss.z] = Pool.GetInstance(new Vector3((pos.x + i), (pos.y + j), (pos.z + k)), maxsize, "MAIN_UPD");
                    }
                }
            }
        }
        foreach (Chunk t in ChunkGrid)
        {
            t.Dfs(Player.transform.position);
        }
    }
Exemple #2
0
 void Start()
 {
     master         = Master;
     Pool           = new ChunkPool(MaxInstanceCount);
     ChunkGrid      = new Chunk[3, 3, 3];
     maxsize        = Mathf.Pow(16, Visibility);
     MinSize        = Mathf.Pow(16, Resolution);
     DrawList       = new List <Chunk>();
     PrecomputeList = new List <PrecomputeAttrib>();
     for (int i = -1; i <= 1; i++)
     {
         for (int j = -1; j <= 1; j++)
         {
             for (int k = -1; k <= 1; k++)
             {
                 ChunkGrid[(i + 3) % 3, (j + 3) % 3, (k + 3) % 3] = Pool.GetInstance(new Vector3(i, j, k), maxsize, "INIT");
                 ChunkGrid[(i + 3) % 3, (j + 3) % 3, (k + 3) % 3].Dfs(Player.transform.position);
             }
         }
     }
 }