Пример #1
0
    public void UpdateVelocity()
    {
        int pos = FluidSolver.Pos(i, j, grid.N);

        grid.velocitiesX[pos] = velX;
        grid.velocitiesY[pos] = velY;
    }
Пример #2
0
 public void RefreshCells()
 {
     for (int i = 0; i < N; i++)
     {
         for (int j = 0; j < N; j++)
         {
             int pos = FluidSolver.Pos(i, j, N);
             cells[pos].color = colors[pos];
             cells[pos].velX  = velocitiesX[pos];
             cells[pos].velY  = velocitiesY[pos];
         }
     }
 }
Пример #3
0
    public void PopulateGridFunction()
    {
        cells       = new Cell[N * N];
        velocitiesX = new float[N * N];
        velocitiesY = new float[N * N];
        colors      = new float[N * N];
        temp        = new float[N * N];
        Vector3 cellSpacing = cellPrefab.sprite.bounds.size;

        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                var cell = GameObject.Instantiate(cellPrefab, this.transform.position + new Vector3(cellSpacing.x * i, -cellSpacing.y * j), Quaternion.identity, this.transform);
                cell.i    = i;
                cell.j    = j;
                cell.grid = this;
                cells[FluidSolver.Pos(i, j, N)] = cell;
            }
        }
    }
Пример #4
0
    public void UpdateColor()
    {
        int pos = FluidSolver.Pos(i, j, grid.N);

        grid.colors[pos] = color;
    }