HighMap library (C++)
Loading...
Searching...
No Matches
cell_path.hpp
Go to the documentation of this file.
1/* Copyright (c) 2026 Otto Link. Distributed under the terms of the GNU General
2 Public License. The full license is in the file LICENSE, distributed with
3 this software. */
4
11#pragma once
12#include <vector>
13
14#include <glm/glm.hpp>
15
16#include "highmap/functions.hpp"
17
18namespace hmap
19{
20
28{
29public:
30 CellPath() = default;
31
36 CellPath(const std::vector<glm::ivec2> &indices);
37
42 CellPath(std::vector<glm::ivec2> &&indices);
43
48 std::vector<glm::ivec2> &get_indices();
49
54 const std::vector<glm::ivec2> &get_indices() const;
55
56private:
57 std::vector<glm::ivec2> indices;
58};
59
71void add_line_bresenham(std::vector<glm::ivec2> &out,
72 glm::ivec2 a,
73 glm::ivec2 b);
74
98void add_noise(std::vector<glm::ivec2> &indices,
99 std::uint32_t seed,
100 float kw,
101 float amp,
102 const glm::ivec2 &shape,
103 NoiseType noise_type = NoiseType::PERLIN,
104 int octaves = 8,
105 float weight = 0.7f,
106 float persistence = 0.5f,
107 float lacunarity = 2.f);
108
117void enforce_path_adjacency(std::vector<glm::ivec2> &indices);
118
128bool is_path_adjacent(const std::vector<glm::ivec2> &indices);
129
130} // namespace hmap
Ordered path of grid cell indices.
Definition cell_path.hpp:28
CellPath()=default
std::vector< glm::ivec2 > & get_indices()
Get the cell indices.
Definition cell_path.cpp:21
Defines modular function objects for procedural generation, including noise algorithms (Perlin,...
Definition algebra.hpp:23
void add_noise(std::vector< glm::ivec2 > &indices, std::uint32_t seed, float kw, float amp, const glm::ivec2 &shape, NoiseType noise_type=NoiseType::PERLIN, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f)
Applies transverse noise displacement along an integer path.
Definition add_noise.cpp:56
bool is_path_adjacent(const std::vector< glm::ivec2 > &indices)
Checks if a grid path has no gaps (8-connectivity).
Definition add_noise.cpp:141
void add_line_bresenham(std::vector< glm::ivec2 > &out, glm::ivec2 a, glm::ivec2 b)
Rasterizes a segment between two integer points using Bresenham's algorithm.
Definition add_noise.cpp:19
NoiseType
Enumeration of various noise types used for procedural generation.
Definition functions.hpp:67
@ PERLIN
Perlin.
Definition functions.hpp:69
void enforce_path_adjacency(std::vector< glm::ivec2 > &indices)
Ensures that an integer path is grid-adjacent and gap-free.
Definition add_noise.cpp:119