Beispiel #1
0
    void AddTriangleIfInCell(BowyerWatson <WorleyNoise.CellData> .Triangle triangle)
    {
        bool triangleInCell = false;

        int floatIndex       = 0;
        var adjacentCellPair = new WorleyNoise.CellDataX2();

        for (int i = 0; i < 3; i++)
        {
            if (triangle[i].pos.Equals(cellPosition))
            {
                triangleInCell = true;
            }
            else
            {
                if (floatIndex > 1)
                {
                    continue;
                }

                adjacentCellPair[floatIndex] = triangle[i].pointObject;
                floatIndex++;
            }
        }

        if (triangleInCell)
        {
            cellVertices.Add(triangle.circumcircle.center);
            adjacentCells.Add(SortCellPairClockwise(adjacentCellPair));
            vertexRotations.Add(vectorUtil.RotationFromUp(triangle.circumcircle.center, cellPosition));
        }
    }
Beispiel #2
0
    WorleyNoise.CellDataX2 FlipCellDataX2(WorleyNoise.CellDataX2 original)
    {
        var result = new WorleyNoise.CellDataX2();

        result.c0 = original.c1;
        result.c1 = original.c0;
        return(result);
    }
Beispiel #3
0
    WorleyNoise.CellDataX2 SortCellPairClockwise(WorleyNoise.CellDataX2 original)
    {
        bool wrongWay = vectorUtil.RotationFromUp(original.c0.position, cellPosition) >
                        vectorUtil.RotationFromUp(original.c1.position, cellPosition);

        if (wrongWay)
        {
            return(FlipCellDataX2(original));
        }
        else
        {
            return(original);
        }
    }