예제 #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);
        }
    }