Skip to content

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 ​

  • struct Settings — Layout and per-patch geometry parameters.

Constructors & destructor ​

StreamedTerrain ​

cpp
StreamedTerrain(
    RayraiWindow &viewer,
    std::string prefix,
    WorldCellBounds world,
    TerrainPatch::HeightFunction height,
    Material material,
    Settings settings)

Parameters

ParameterDescription
viewerViewer that owns the patch visuals; must outlive this object.
prefixName prefix; visuals are named prefix/depth/x/y.
worldWorld rectangle covered by the terrain.
heightHeight function valid over all of world.
materialMaterial assigned to every patch mesh.
settingsLayout parameters.

Exceptions

ExceptionDescription
std::invalid_argumentfor invalid settings; std::length_error if even the coarse layout exceeds the patch budget.
cpp
StreamedTerrain(const StreamedTerrain &) = delete

~StreamedTerrain ​

cpp
~StreamedTerrain()

Public member functions ​

operator= ​

cpp
StreamedTerrain &operator=(const StreamedTerrain &) = delete

update ​

cpp
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

ParameterDescription
observersHorizontal observer positions.
focalPixelsProjection focal length in pixels.
pixelErrorAllowed screen-space height error in pixels.
lodEnabledFalse keeps every patch at full resolution.

Returns Number of patches of the pending layout still awaiting preparation.

clear ​

cpp
void clear()

Remove all patch visuals and forget the layout.

residentPatchCount ​

cpp
size_t residentPatchCount() const

Returns Patch count of the currently visible layout.

preparedPatchCount ​

cpp
size_t preparedPatchCount() const

Returns Visible patches plus newly prepared patches of the pending layout.

selectedTriangleCount ​

cpp
size_t selectedTriangleCount() const

Returns Triangles (including skirts) of the selected LOD of every visible patch.

regions ​

cpp
std::vector<TerrainPatchRegion> regions() const

Returns Regions of the currently visible layout.

RaiSim — physics for robotics and AI.