void FloodFill(int startIndex, BlockID block) { if (startIndex < 0) { return; // y below map, immediately ignore } FastIntStack stack = new FastIntStack(4); stack.Push(startIndex); while (stack.Size > 0) { int index = stack.Pop(); if (blocks[index] != Block.Air) { continue; } blocks[index] = block; int x = index % Width; int y = index / oneY; int z = (index / Width) % Length; if (x > 0) { stack.Push(index - 1); } if (x < Width - 1) { stack.Push(index + 1); } if (z > 0) { stack.Push(index - Width); } if (z < Length - 1) { stack.Push(index + Width); } if (y > 0) { stack.Push(index - oneY); } } }
void FloodFill( int startIndex, byte block ) { FastIntStack stack = new FastIntStack( 4 ); stack.Push( startIndex ); while( stack.Size > 0 ) { int index = stack.Pop(); if( blocks[index] == 0 ) { blocks[index] = block; int x = index % width; int y = index / oneY; int z = (index / width) % length; if( x > 0 ) stack.Push( index - 1 ); if( x < width - 1 ) stack.Push( index + 1 ); if( z > 0 ) stack.Push( index - width ); if( z < length - 1 ) stack.Push( index + width ); if( y > 0 ) stack.Push( index - oneY ); } } }
void FloodFill(int startIndex, byte block) { FastIntStack stack = new FastIntStack(4); stack.Push(startIndex); while (stack.Size > 0) { int index = stack.Pop(); if (blocks[index] != 0) { continue; } blocks[index] = block; int x = index % width; int y = index / oneY; int z = (index / width) % length; if (x > 0) { stack.Push(index - 1); } if (x < width - 1) { stack.Push(index + 1); } if (z > 0) { stack.Push(index - width); } if (z < length - 1) { stack.Push(index + width); } if (y > 0) { stack.Push(index - oneY); } } }