BecomeXDummyOf() public method

public BecomeXDummyOf ( Voxel, voxel, float offset ) : void
voxel Voxel,
offset float
return void
Ejemplo n.º 1
0
    private void FillFirstRowCache()
    {
        CacheFirstCorner(voxels[0]);
        int i;

        for (i = 0; i < resolution - 1; i++)
        {
            CacheNextEdgeAndCorner(i * 2, voxels[i], voxels[i + 1]);
        }
        if (xNeighbor != null)
        {
            dummyX.BecomeXDummyOf(xNeighbor.voxels[0], gridSize);
            CacheNextEdgeAndCorner(i * 2, voxels[i], dummyX);
        }
    }
Ejemplo n.º 2
0
    private void TriangulateGapCell(int i)
    {
        Voxel dummySwap = dummyT;

        dummySwap.BecomeXDummyOf(xNeighbor.voxels[i + 1], gridSize);
        dummyT = dummyX;
        dummyX = dummySwap;
        TriangulateCell(voxels[i], dummyT, voxels[i + resolution], dummyX);
    }
Ejemplo n.º 3
0
 public void Triangulate()
 {
     if (xNeighbor != null)
     {
         dummyX.BecomeXDummyOf(xNeighbor.voxels[0], grid.gridSize);
     }
     TriangulateCellRow();
     if (yNeighbor != null)
     {
         TriangulateGapRow();
     }
 }
Ejemplo n.º 4
0
    private void TriangulateGapCell(int i)
    {
        Voxel dummySwap = dummyT;

        dummySwap.BecomeXDummyOf(xNeighbor.voxels[i + 1], gridSize);
        dummyT = dummyX;
        dummyX = dummySwap;
        int cacheIndex = resolution - 1;

        CacheNextEdgeAndCorner(cacheIndex, voxels[i + resolution], dummyX);
        CacheNextMiddleEdge(dummyT, dummyX);
        TriangulateCell(cacheIndex, voxels[i], dummyT, voxels[i + resolution], dummyX);
    }
Ejemplo n.º 5
0
    private void Triangulate()
    {
        vertices.Clear(); //TODO: could be a place of optimization. using fixed size arrays instead of lists?
        triangles.Clear();
        mesh.Clear();

        if (xNeighbor != null)
        {
            dummyX.BecomeXDummyOf(xNeighbor.voxels[0], gridSize);
        }
        TriangulateCellRows();

        mesh.vertices  = vertices.ToArray();
        mesh.triangles = triangles.ToArray();
    }
Ejemplo n.º 6
0
    private void Triangulate()
    {
        vertices.Clear();
        triangles.Clear();
        mesh.Clear();

        if (xNeighbor != null)
        {
            dummyX.BecomeXDummyOf(xNeighbor.voxels[0], gridSize);
        }
        TriangulateCellRows();
        if (yNeighbor != null)
        {
            TriangulateGapRow();
        }

        mesh.vertices  = vertices.ToArray();
        mesh.triangles = triangles.ToArray();
    }
Ejemplo n.º 7
0
    private void SetCrossings(VoxelStencil stencil, int xStart, int xEnd, int yStart, int yEnd)
    {
        bool crossHorizontalGap = false;
        bool lastVerticalRow    = false;
        bool crossVerticalGap   = false;

        if (xStart > 0)
        {
            xStart -= 1;
        }
        if (xEnd == resolution - 1)
        {
            xEnd -= 1;
            crossHorizontalGap = xNeighbor != null;
        }
        if (yStart > 0)
        {
            yStart -= 1;
        }
        if (yEnd == resolution - 1)
        {
            yEnd            -= 1;
            lastVerticalRow  = true;
            crossVerticalGap = yNeighbor != null;
        }

        Voxel a, b;

        for (int y = yStart; y <= yEnd; y++)
        {
            int i = y * resolution + xStart;
            b = voxels[i];
            for (int x = xStart; x <= xEnd; x++, i++)
            {
                a = b;
                b = voxels[i + 1];
                stencil.SetHorizontalCrossing(a, b);
                stencil.SetVerticalCrossing(a, voxels[i + resolution]);
            }
            stencil.SetVerticalCrossing(b, voxels[i + resolution]);
            if (crossHorizontalGap)
            {
                dummyX.BecomeXDummyOf(xNeighbor.voxels[y * resolution], gridSize);
                stencil.SetHorizontalCrossing(b, dummyX);
            }
        }
        if (lastVerticalRow)
        {
            int i = voxels.Length - resolution + xStart;
            b = voxels[i];
            for (int x = xStart; x <= xEnd; x++, i++)
            {
                a = b;
                b = voxels[i + 1];
                stencil.SetHorizontalCrossing(a, b);
                if (crossVerticalGap)
                {
                    dummyY.BecomeYDummyOf(yNeighbor.voxels[x], gridSize);
                    stencil.SetVerticalCrossing(a, dummyY);
                }
            }
            if (crossVerticalGap)
            {
                dummyY.BecomeYDummyOf(yNeighbor.voxels[xEnd + 1], gridSize);
                stencil.SetVerticalCrossing(b, dummyY);
            }
            if (crossHorizontalGap)
            {
                dummyX.BecomeXDummyOf(xNeighbor.voxels[voxels.Length - resolution], gridSize);
                stencil.SetHorizontalCrossing(b, dummyX);
            }
        }
    }