This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
4rpl:commands:floodfillterrain [2021/01/08 16:01] – external edit 127.0.0.1 | 4rpl:commands:floodfillterrain [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 7: | Line 7: | ||
===== Description ===== | ===== Description ===== | ||
Returns a list of 2d vectors representing map coordinates that satisfy the following conditions: | Returns a list of 2d vectors representing map coordinates that satisfy the following conditions: | ||
- | *The set is connected. | + | * The set is connected. |
- | *The set is empty or contains(X, Y) | + | * The set is empty or contains (posX, posZ) |
- | *The set is filled only with squares at height between min_height and max_height | + | * The set is filled only with squares at height between min_height |
- | *There are no more than maxSize squares in the set. | + | * MaxSize is the upper bound limit for cell iteration. It is not directly related to the size of the list that is returned. The number of Cells returned is the number of cells that fit the criteria specified. |
+ | |||
+ | Warning: This currently has a bug (current for 1.4), and will accept heights 1 tile below min_height, so a min height of 3 will add tiles with a height of 2 as well, but not tiles with a height of 1. | ||
=== Examples === | === Examples === | ||
Line 16: | Line 18: | ||
FloodFillTerrain(GetUnitCell(self) 1 20 999999) -> | FloodFillTerrain(GetUnitCell(self) 1 20 999999) -> | ||
</ | </ | ||
+ | |||
+ | ==== How FloodFill Works ==== | ||
+ | |||
+ | FloodFill starts at the center and looks at the four adjacent cells - above, left, right, below. If the cell matches the criteria, it is added to a list. | ||
+ | |||
+ | Now FloodFill iterates over each of the cells in the list, but not checking cells that has been checked in a previous iteration. So, assuming the cell " | ||
+ | |||
+ | This process iterates for as many iterations as " | ||
+ | |||
< | < | ||