GetFloodFillIndices - GetRectangleIndices

jlevet
Member
From: Marseille, France
Registered: 2014-03-31
Posts: 33
Website

Topic

Hi Lea,

I'm using the PaintingUtility.Paint/PaintCircle/PaintSquare methods to paint on my tilesystems, and their respectives GetxxxIndices methods, but it seems that PaintingUtility miss the GetFloodFillIndices() and the GetRectangleIndices().

Is that on purpose? I need theses indices (as a return value of the Painting methods, or as an additionnal method like the other ones) to iterate and work on the indexes.

Thank you for your answer.


Game Developper working on Zombie Night Terror.

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 1

Hey

Yes this is intentional since these two procedures are more efficiently achieved using the algorithm directly.

To paint a rectangle you simply need to enumerate the space between tile indices:

for (int row = firstRow; row < endRow; ++row) {
    for (int column = firstColumn; column < endColumn; ++column) {
        // Do what you want at this column.
    }
}

To perform flood-fill use one of the standard algorithms:
http://en.wikipedia.org/wiki/Flood_fill

I hope that this helps!

jlevet
Member
From: Marseille, France
Registered: 2014-03-31
Posts: 33
Website

Response 2

Thank you for the quick reply. I'll implement both to retrieve the indexes!


Game Developper working on Zombie Night Terror.

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 3

Perhaps it would be useful if an overload was added for PaintingUtility.FloodFill which accepted an array to output painted indices to? something like this:

TileIndex[] paintedIndices;
PaintingUtility.FloodFill(system, index, args, out paintedIndices);

Since the flood filling process is influenced by the tiles that it itself paints or erases. Without painting to a buffer you wont know which tiles this guy paints up-front, so perhaps the method should just return the results when requested.

jlevet
Member
From: Marseille, France
Registered: 2014-03-31
Posts: 33
Website

Response 4

That would be awesome :)
Adding an additionnal ref array parameter won't cost you anything. We can imagine the same for Rectangle


Game Developper working on Zombie Night Terror.

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 5

This change will be made ready for the next release of Rotorz Tile System.

There still isn't any advantage to adding this for the rectangle function since you can easily loop through the indices without any memory overhead.


Edit: FloodFill(TileSystem, TileIndex, PaintingArgs, IList<TileIndex>) has been added and will be available in the next BETA release.

Usage example:

var filledIndices = new List<TileIndex>();
PaintingUtility.FloodFill(system, index, args, filledIndices);
Debug.Log(string.Format("Filled {0} tiles.", filledIndices.Count));

Last edited by Lea Hayes (2014-12-04 23:20:47)