Jazz2/Editor/Common/ToolMath.h file

Namespaces

namespace Jazz2
Root namespace of Jazz² Resurrection.
namespace Jazz2::Editor
namespace Jazz2::Editor::ToolMath
Small helpers shared by the tools of the level editor and the smart tiles.

Functions

auto PositiveModulo(std::int32_t value, std::int32_t divisor) -> std::int32_t
Remainder of a division that's never negative, for positions wrapped around a layer that repeats.
auto FloorDivide(std::int32_t value, std::int32_t divisor) -> std::int32_t
Division rounded down, not towards zero, for chunks of a grid that goes into negative positions.
template<class TFunc>
void WalkLine(Vector2i from, Vector2i to, TFunc&& func)
Calls a function for every cell on a line between two cells, both included, so a fast drag doesn't leave gaps.
auto CatmullRom(Vector2f p0, Vector2f p1, Vector2f p2, Vector2f p3, float t) -> Vector2f
Returns a point of the Catmull-Rom curve between p1 and p2, t from 0 to 1.
auto ToCellKey(Vector2i cell) -> std::uint64_t
Returns a key of a cell for a hash map.
auto FromCellKey(std::uint64_t key) -> Vector2i
Returns the cell of a key made by ToCellKey().
auto HashCell(Vector2i cell) -> std::uint32_t
Returns a hash of a cell, which picks among tiles about as good so large areas aren't all the same tile.
auto IsSolidTile(const TileRef& tile) -> bool
Returns whether a tile is solid as the smart tools see it, not empty and not invisible.

Variables

std::int32_t NeighborOffsets constexpr
Offsets of the 8 neighbors of a cell, in the order of the bits of SmartTileModel::Neighbor.