header_utils
Loading...
Searching...
No Matches

Container for, and operations on, a 2D grid. More...

Classes

struct  ghassanpl::geometry::squares::grid< TILE_DATA, RESIZABLE >
 A container for squares in a 2D square grid. More...
template<typename TILE_DATA, bool RESIZABLE, typename FUNC>
void ghassanpl::geometry::squares::apply_cellular_automata (grid< TILE_DATA, RESIZABLE > &current_iteration, irec2 const &rect, FUNC &&func)
 Applies a cellular automata generation function on (a region of) the grid.
template<typename TILE_DATA, bool RESIZABLE, typename FUNC>
void ghassanpl::geometry::squares::apply_cellular_automata (grid< TILE_DATA, RESIZABLE > &current_iteration, FUNC &&func)
 Applies a cellular automata generation function on (a region of) the grid.
template<typename TILE_DATA, bool RESIZABLE, typename FUNC>
void ghassanpl::geometry::squares::apply_cellular_automata (grid< TILE_DATA, RESIZABLE > const &current_iteration, grid< TILE_DATA, RESIZABLE > &new_iteration, irec2 const &rect, FUNC &&func)
 TODO: This.
template<typename TILE_DATA, bool RESIZABLE, change_tile_callback< TILE_DATA > REPLACE_FUNC, query_tile_callback< TILE_DATA > SHOULD_FLOOD_FUNC>
void ghassanpl::geometry::squares::flood_at (grid< TILE_DATA, RESIZABLE > &grid, glm::ivec2 start, REPLACE_FUNC &&replace, SHOULD_FLOOD_FUNC &&should_flood)
 Performs a flood-fill algorithm on grid.
template<typename TILE_DATA, bool RESIZABLE, change_tile_callback< TILE_DATA > REPLACE_FUNC>
void ghassanpl::geometry::squares::flood_at (grid< TILE_DATA, RESIZABLE > &grid, glm::ivec2 start, REPLACE_FUNC &&replace)
 Performs a flood-fill algorithm on grid.
template<typename TILE_DATA, bool RESIZABLE, query_tile_callback< TILE_DATA > SHOULD_FLOOD_FUNC>
void ghassanpl::geometry::squares::flood_at (grid< TILE_DATA, RESIZABLE > &grid, glm::ivec2 start, TILE_DATA const &replace_with, SHOULD_FLOOD_FUNC &&should_flood)
 Performs a flood-fill algorithm on grid.
template<typename TILE_DATA, bool RESIZABLE>
void ghassanpl::geometry::squares::flood_at (grid< TILE_DATA, RESIZABLE > &grid, glm::ivec2 start, TILE_DATA const &replace_with)
 Performs a flood-fill algorithm on grid.

Detailed Description

Container for, and operations on, a 2D grid.

Function Documentation

◆ apply_cellular_automata() [1/2]

template<typename TILE_DATA, bool RESIZABLE, typename FUNC>
void ghassanpl::geometry::squares::apply_cellular_automata ( grid< TILE_DATA, RESIZABLE > & current_iteration,
FUNC && func )

Applies a cellular automata generation function on (a region of) the grid.

Note that since cellular automata operations are done on an immutable grid, this function creates a copy of the entire grid as the next generation, modifies it, and then swaps it with the current generation grid. Any iterators to the current (old) grid will therefore be invalidated and its data destroyed.

Definition at line 55 of file square_grid_algorithms.h.

◆ apply_cellular_automata() [2/2]

template<typename TILE_DATA, bool RESIZABLE, typename FUNC>
void ghassanpl::geometry::squares::apply_cellular_automata ( grid< TILE_DATA, RESIZABLE > & current_iteration,
irec2 const & rect,
FUNC && func )

Applies a cellular automata generation function on (a region of) the grid.

Note that since cellular automata operations are done on an immutable grid, this function creates a copy of the entire grid as the next generation, modifies it, and then swaps it with the current generation grid. Any iterators to the current (old) grid will therefore be invalidated and its data destroyed.

Definition at line 20 of file square_grid_algorithms.h.

◆ flood_at() [1/4]

template<typename TILE_DATA, bool RESIZABLE, change_tile_callback< TILE_DATA > REPLACE_FUNC>
void ghassanpl::geometry::squares::flood_at ( grid< TILE_DATA, RESIZABLE > & grid,
glm::ivec2 start,
REPLACE_FUNC && replace )

Performs a flood-fill algorithm on grid.

Whether a tile should be flooded will depend on if it compares equal to a copy of the tile at start

Parameters
startwhere to start flooding
replacewill be called on each tile that needs to be flooded, to change it

Definition at line 145 of file square_grid_algorithms.h.

◆ flood_at() [2/4]

template<typename TILE_DATA, bool RESIZABLE, change_tile_callback< TILE_DATA > REPLACE_FUNC, query_tile_callback< TILE_DATA > SHOULD_FLOOD_FUNC>
void ghassanpl::geometry::squares::flood_at ( grid< TILE_DATA, RESIZABLE > & grid,
glm::ivec2 start,
REPLACE_FUNC && replace,
SHOULD_FLOOD_FUNC && should_flood )

Performs a flood-fill algorithm on grid.

Parameters
startwhere to start flooding; should_flood(start) should be true before replace(start), and false afterwards
replacewill be called on each tile that needs to be flooded, to change it; after replace(pos), should_flood(pos) should always be false
should_floodqueries whether the given tile should be flooded

Definition at line 69 of file square_grid_algorithms.h.

◆ flood_at() [3/4]

template<typename TILE_DATA, bool RESIZABLE>
void ghassanpl::geometry::squares::flood_at ( grid< TILE_DATA, RESIZABLE > & grid,
glm::ivec2 start,
TILE_DATA const & replace_with )

Performs a flood-fill algorithm on grid.

Whether a tile should be flooded will depend on if it compares equal to a copy of the tile at start

Parameters
startwhere to start flooding
replace_withthe tile data to set on each square that should be flooded

Definition at line 168 of file square_grid_algorithms.h.

◆ flood_at() [4/4]

template<typename TILE_DATA, bool RESIZABLE, query_tile_callback< TILE_DATA > SHOULD_FLOOD_FUNC>
void ghassanpl::geometry::squares::flood_at ( grid< TILE_DATA, RESIZABLE > & grid,
glm::ivec2 start,
TILE_DATA const & replace_with,
SHOULD_FLOOD_FUNC && should_flood )

Performs a flood-fill algorithm on grid.

Parameters
startwhere to start flooding; should_flood(start) should be true before *grid.at(start) = replace_with, and false afterwards
replace_withthe tile data to set on each square that should be flooded
should_floodqueries whether the given tile should be flooded

Definition at line 157 of file square_grid_algorithms.h.