void AddVertexData(Vertex vertex, float4 color)
        {
            DebugSystem.Count("Vertices drawn");

            vertices.Add(vertex);
            colors.Add(new VertColor {
                color = color
            });
        }
示例#2
0
        public void FloodFillCell()
        {
            NativeQueue <WorleyNoise.PointData> dataToCheck = new NativeQueue <WorleyNoise.PointData>(Allocator.Temp);

            WorleyNoise.PointData initialPointData = GetPointData(startCell.position);
            dataToCheck.Enqueue(initialPointData);

            float startCellGrouping = GetOrGenerateCellGrouping(startCell.index);

            initialPointData.cellGrouping = startCellGrouping;

            pointMatrix.AddItem(initialPointData, initialPointData.pointWorldPosition);

            while (dataToCheck.Count > 0)
            {
                DebugSystem.Count("Points flood filled");
                WorleyNoise.PointData data = dataToCheck.Dequeue();

                bool currentIsOutsideCell = GetOrGenerateCellGrouping(data.currentCellIndex) != startCellGrouping;

                for (int x = -1; x <= 1; x++)
                {
                    for (int z = -1; z <= 1; z++)
                    {
                        float3 adjacentPosition            = new float3(x, 0, z) + data.pointWorldPosition;
                        WorleyNoise.PointData adjacentData = GetPointData(adjacentPosition);

                        float grouping = GetOrGenerateCellGrouping(adjacentData.currentCellIndex);

                        bool adjacentIsOutsideCell = grouping != startCellGrouping;
                        if (pointMatrix.ItemIsSet(adjacentPosition) || (currentIsOutsideCell && adjacentIsOutsideCell))
                        {
                            continue;
                        }

                        adjacentData.cellGrouping = grouping;

                        dataToCheck.Enqueue(adjacentData);
                        pointMatrix.AddItem(adjacentData, adjacentData.pointWorldPosition);
                    }
                }
            }

            dataToCheck.Dispose();
        }