raisin::StreamedTerrain
class · #include <rayrai/StreamedTerrain.hpp>
A complete visual terrain cover with small patches near observers and coarse patches toward the horizon. Update on the viewer's GL thread. Replacements are prepared within an upload budget; the previous cover stays visible until its complete replacement is ready. Physics is owned by the caller. The height provider must support the entire world bounds. The viewer/context must outlive this owner; prefixed visuals are owned here.
Nested classes
structSettings — Layout and per-patch geometry parameters.
Constructors & destructor
StreamedTerrain
StreamedTerrain(
RayraiWindow &viewer,
std::string prefix,
WorldCellBounds world,
TerrainPatch::HeightFunction height,
Material material,
Settings settings)Parameters
| Parameter | Description |
|---|---|
viewer | Viewer that owns the patch visuals; must outlive this object. |
prefix | Name prefix; visuals are named prefix/depth/x/y. |
world | World rectangle covered by the terrain. |
height | Height function valid over all of world. |
material | Material assigned to every patch mesh. |
settings | Layout parameters. |
Exceptions
| Exception | Description |
|---|---|
std::invalid_argument | for invalid settings; std::length_error if even the coarse layout exceeds the patch budget. |
StreamedTerrain(const StreamedTerrain &) = delete~StreamedTerrain
~StreamedTerrain()Public member functions
operator=
StreamedTerrain &operator=(const StreamedTerrain &) = deleteupdate
size_t update(
std::span<const glm::dvec2> observers,
double focalPixels,
double pixelError=1,
bool lodEnabled=true)Advance layout preparation and re-select patch LODs. Empty observers retain a single coarse world patch. Horizontal distance is conservative for the terrain projection error used here.
Parameters
| Parameter | Description |
|---|---|
observers | Horizontal observer positions. |
focalPixels | Projection focal length in pixels. |
pixelError | Allowed screen-space height error in pixels. |
lodEnabled | False keeps every patch at full resolution. |
Returns Number of patches of the pending layout still awaiting preparation.
clear
void clear()Remove all patch visuals and forget the layout.
residentPatchCount
size_t residentPatchCount() constReturns Patch count of the currently visible layout.
preparedPatchCount
size_t preparedPatchCount() constReturns Visible patches plus newly prepared patches of the pending layout.
selectedTriangleCount
size_t selectedTriangleCount() constReturns Triangles (including skirts) of the selected LOD of every visible patch.
regions
std::vector<TerrainPatchRegion> regions() constReturns Regions of the currently visible layout.