![]() |
vkmEngine 1.0.15
A C++ game engine · vkmengine.com
|
The edits a brush makes to a terrain, one dab at a time: raise, smooth and flatten its heights, paint a layer's share, and grow or thin a plant layer. More...
Classes | |
| struct | Dab |
| One application of a brush: where, how wide, how much. More... | |
| struct | Region |
| Grid vertices [i0, i1] by [j0, j1], inclusive: what a dab touched. More... | |
Functions | |
| float | falloff (const Dab &dab, float distance) |
How much of a dab's effect reaches distance from its centre. | |
| Region | reach (const TerrainAsset &terrain, const Dab &dab) |
The grid vertices within dab, clamped to terrain's grid. | |
| bool | hit (const TerrainAsset &terrain, const glm::vec3 &origin, const glm::vec3 &direction, float range, float &t) |
Where a ray first meets terrain's surface, over its grid. | |
| Region | raise (TerrainAsset &terrain, const Dab &dab, float metres) |
Raise the heights under dab, metres at its centre; negative lowers. | |
| Region | smooth (TerrainAsset &terrain, const Dab &dab) |
Pull each height under dab toward its neighbours' mean. | |
| Region | flatten (TerrainAsset &terrain, const Dab &dab, float height) |
Pull each height under dab toward height. | |
| Region | paint (TerrainAsset &terrain, const Dab &dab, uint32_t layer) |
Move each vertex's layer shares under dab toward all of layer. | |
| Region | grow (TerrainAsset &terrain, const Dab &dab, uint32_t foliage, float target) |
Move the density of plant layer foliage under dab toward target. | |
The edits a brush makes to a terrain, one dab at a time: raise, smooth and flatten its heights, paint a layer's share, and grow or thin a plant layer.
Each changes the asset in place and returns the grid vertices it touched; the caller commits the asset (ResourceManager::commit), which redraws the touched chunks and rebuilds the terrain's collider and plants. A dab's effect fades from its centre to its rim, so strokes made of many dabs blend.
| float Vkm::Engine::TerrainBrush::falloff | ( | const Dab & | dab, |
| float | distance ) |
How much of a dab's effect reaches distance from its centre.
| dab | The dab. |
| distance | Metres from its centre. |
| Region Vkm::Engine::TerrainBrush::reach | ( | const TerrainAsset & | terrain, |
| const Dab & | dab ) |
The grid vertices within dab, clamped to terrain's grid.
| terrain | The terrain. |
| dab | The dab. |
| bool Vkm::Engine::TerrainBrush::hit | ( | const TerrainAsset & | terrain, |
| const glm::vec3 & | origin, | ||
| const glm::vec3 & | direction, | ||
| float | range, | ||
| float & | t ) |
Where a ray first meets terrain's surface, over its grid.
Marched a half grid step at a time, then narrowed to the crossing, so a ray grazing a ridge thinner than that may pass it.
| terrain | The terrain. | |
| origin | Local metres. | |
| direction | Unit, local. | |
| range | Metres along it to look. | |
| [out] | t | Metres along it to the surface; untouched on false. |
range. | Region Vkm::Engine::TerrainBrush::raise | ( | TerrainAsset & | terrain, |
| const Dab & | dab, | ||
| float | metres ) |
Raise the heights under dab, metres at its centre; negative lowers.
| terrain | The terrain. |
| dab | Where. |
| metres | How far its centre moves. |
| Region Vkm::Engine::TerrainBrush::smooth | ( | TerrainAsset & | terrain, |
| const Dab & | dab ) |
Pull each height under dab toward its neighbours' mean.
| terrain | The terrain. |
| dab | Where; its strength is the share of the way each height moves. |
| Region Vkm::Engine::TerrainBrush::flatten | ( | TerrainAsset & | terrain, |
| const Dab & | dab, | ||
| float | height ) |
Pull each height under dab toward height.
| terrain | The terrain. |
| dab | Where; its strength is the share of the way each height moves. |
| height | Local metres: the level a path or a plot is cut to. |
| Region Vkm::Engine::TerrainBrush::paint | ( | TerrainAsset & | terrain, |
| const Dab & | dab, | ||
| uint32_t | layer ) |
Move each vertex's layer shares under dab toward all of layer.
The shares still add up to 255 after.
| terrain | The terrain. |
| dab | Where; its strength is the share of the way each vertex moves. |
| layer | Below MaterialAsset::MAX_LAYERS. |
| Region Vkm::Engine::TerrainBrush::grow | ( | TerrainAsset & | terrain, |
| const Dab & | dab, | ||
| uint32_t | foliage, | ||
| float | target ) |
Move the density of plant layer foliage under dab toward target.
Gives the layer a density map first if it has none.
| terrain | The terrain. |
| dab | Where; its strength is the share of the way each vertex moves. |
| foliage | Below terrain.foliage.size(). |
| target | 0 thins it out, 1 grows it full. |