mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-26 17:04:53 +01:00
Editor terrain: texture browser, undo, conversion from terrain files
- Terrain work mode shows a browser of the textures folder in place of the node bank; textures/materials can be dragged onto the palette entries (replacing the material), the material field and the water material field - Ctrl+Z/Ctrl+Y for heightmap terrain changes: a brush stroke or an operation is one step of the editor history - Ground conversion reads only the files of the terrain directives (.txtf with origin/rotate, or .btf without text), paints the chunks with the materials of the triangles, drops only the shapes of those files - Fix: ground grids converted out-of-range floats to int, so whole-scene queries returned the triangles of a single cell (shifted chunks) - Fix: terrain layers copied from textures already uploaded without their data stayed grey - Fix: ImGui ID conflict between terrain tool radios and section headers - Fix: layers of terrain .txtf files named with the scenery/ prefix and could not be saved - Editor selftest commands for the terrain
This commit is contained in:
@@ -120,13 +120,15 @@ class ground_mesh
|
||||
}
|
||||
|
||||
private:
|
||||
// NOTE: clamped before the conversion: a rectangle asked about can reach far beyond the mesh (to infinity even),
|
||||
// and a float out of the range of int doesn't turn into anything sensible
|
||||
int column(float const X) const
|
||||
{
|
||||
return std::clamp(static_cast<int>(std::floor((X - m_low.x) / m_cellsize)), 0, m_columns - 1);
|
||||
return static_cast<int>(std::clamp(std::floor((X - m_low.x) / m_cellsize), 0.f, static_cast<float>(m_columns - 1)));
|
||||
}
|
||||
int row(float const Z) const
|
||||
{
|
||||
return std::clamp(static_cast<int>(std::floor((Z - m_low.y) / m_cellsize)), 0, m_rows - 1);
|
||||
return static_cast<int>(std::clamp(std::floor((Z - m_low.y) / m_cellsize), 0.f, static_cast<float>(m_rows - 1)));
|
||||
}
|
||||
// cells the bounds of a triangle reach: first column, first row, last column, last row
|
||||
std::array<int, 4> cells(triangle const &Triangle) const
|
||||
|
||||
Reference in New Issue
Block a user