User Tools

Site Tools


4rpl:commands:floodfillterrain

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
4rpl:commands:floodfillterrain [2022/04/01 15:38] virgilw4rpl:commands:floodfillterrain [2024/03/16 12:31] – More details provided Vertu
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(posX, posZ) +  * The set is empty or contains (posX, posZ) 
-  *The set is filled only with squares at height between min_height inclusive and max_height exclusive. (i.e. if set to 3 and 6, it will grab cells with a height of 3, 4, or 5.   +  * The set is filled only with squares at height between min_height inclusive and max_height exclusive. (i.e. if set to 3 and 6, it will grab cells with a height of 3, 4, or 5.   
-  *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. 
 +
 +  * minHeight: Minimum height a cell must be. 
 +  * maxHeight: Maximum height a cell can be. (This is an exclusive bound, a minHeight of 10 maxHeight of 11 will only find cells of a height of 11). 
 +  * maxSize: Maximum number of cells that can be found.
  
-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.  +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 18: Line 22:
 FloodFillTerrain(GetUnitCell(self) 1 20 999999) ->listOfCells FloodFillTerrain(GetUnitCell(self) 1 20 999999) ->listOfCells
 </code> </code>
 +
 +==== 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 "above" matched criteria and is in the list, will cause it's left (also diagonal left from start cell), above, right (again, also diagonal right from start cell), but not below, since that has already been checked. 
 +
 +This process iterates for as many iterations as "maxsize" and the total number of cells returned and their locations are dependent on the topology of the terrain. 
 + 
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
  
4rpl/commands/floodfillterrain.txt · Last modified: 2024/03/16 12:31 by Vertu