|
@@ -69,8 +69,10 @@ public static class FloodFillHelper
|
|
// once the chunk is filled all places where it spills over to neighboring chunks are saved in the stack
|
|
// once the chunk is filled all places where it spills over to neighboring chunks are saved in the stack
|
|
Stack<(VecI chunkPos, VecI posOnChunk)> positionsToFloodFill = new();
|
|
Stack<(VecI chunkPos, VecI posOnChunk)> positionsToFloodFill = new();
|
|
positionsToFloodFill.Push((initChunkPos, initPosOnChunk));
|
|
positionsToFloodFill.Push((initChunkPos, initPosOnChunk));
|
|
|
|
+ int iter = -1;
|
|
while (positionsToFloodFill.Count > 0)
|
|
while (positionsToFloodFill.Count > 0)
|
|
{
|
|
{
|
|
|
|
+ iter++;
|
|
var (chunkPos, posOnChunk) = positionsToFloodFill.Pop();
|
|
var (chunkPos, posOnChunk) = positionsToFloodFill.Pop();
|
|
|
|
|
|
if (!drawingChunks.ContainsKey(chunkPos))
|
|
if (!drawingChunks.ContainsKey(chunkPos))
|
|
@@ -116,7 +118,8 @@ public static class FloodFillHelper
|
|
uLongColor,
|
|
uLongColor,
|
|
drawingColor,
|
|
drawingColor,
|
|
posOnChunk,
|
|
posOnChunk,
|
|
- colorRange);
|
|
|
|
|
|
+ colorRange,
|
|
|
|
+ iter != 0);
|
|
|
|
|
|
if (maybeArray is null)
|
|
if (maybeArray is null)
|
|
continue;
|
|
continue;
|
|
@@ -145,10 +148,13 @@ public static class FloodFillHelper
|
|
ulong colorBits,
|
|
ulong colorBits,
|
|
Color color,
|
|
Color color,
|
|
VecI pos,
|
|
VecI pos,
|
|
- ColorBounds bounds)
|
|
|
|
|
|
+ ColorBounds bounds,
|
|
|
|
+ bool checkFirstPixel)
|
|
{
|
|
{
|
|
if (referenceChunk.Surface.GetSRGBPixel(pos) == color || drawingChunk.Surface.GetSRGBPixel(pos) == color)
|
|
if (referenceChunk.Surface.GetSRGBPixel(pos) == color || drawingChunk.Surface.GetSRGBPixel(pos) == color)
|
|
return null;
|
|
return null;
|
|
|
|
+ if (checkFirstPixel && !bounds.IsWithinBounds(referenceChunk.Surface.GetSRGBPixel(pos)))
|
|
|
|
+ return null;
|
|
|
|
|
|
byte[] pixelStates = new byte[chunkSize * chunkSize];
|
|
byte[] pixelStates = new byte[chunkSize * chunkSize];
|
|
DrawSelection(pixelStates, selection, globalSelectionBounds, chunkPos, chunkSize);
|
|
DrawSelection(pixelStates, selection, globalSelectionBounds, chunkPos, chunkSize);
|