raisin::StreamedFoliage
class · #include <rayrai/StreamedFoliage.hpp>
Owns per-cell/species batches while the viewer retains shared mesh/texture assets. Providers may read baked files or generate deterministic placements. Call on the viewer's GL thread; it creates no simulation worker threads. The viewer/context must outlive this owner. The owner exclusively manages its prefixed visual names; call clear() before editing/removing them outside.
Nested classes
structSpecies — One plant type. Each resident cell gets one InstancedVisuals batch per species.
Public types
Placements
using Placements = std::vector<std::vector<InstancedVisuals::InstanceSpec>>Per-species instance lists for one cell; outer size must equal the species count.
Provider
using Provider = std::function<Placements(WorldCellKey, WorldCellBounds)>Produces the placements of a cell from its key and world bounds.
Constructors & destructor
StreamedFoliage
StreamedFoliage(
RayraiWindow &viewer,
std::string prefix,
WorldCells cells,
std::vector<Species> species,
Provider provider)Parameters
| Parameter | Description |
|---|---|
viewer | Viewer that owns the batches; must outlive this object. |
prefix | Name prefix; batches are named prefix/x/y/speciesIndex. |
cells | Residency planner; must have no resident cells. |
species | Plant types (non-empty; each needs a mesh or a prototype). |
provider | Placement source. |
Exceptions
| Exception | Description |
|---|---|
std::invalid_argument | if any requirement above is violated. |
StreamedFoliage(const StreamedFoliage &) = delete~StreamedFoliage
~StreamedFoliage()Public member functions
operator=
StreamedFoliage &operator=(const StreamedFoliage &) = deleteupdate
WorldCellPlan update(std::span<const WorldInterest> interests)Unload released cells and load up to the planner's load budget.
A cell whose load fails is rolled back and the exception is rethrown.
Parameters
| Parameter | Description |
|---|---|
interests | Points that want foliage nearby. |
Returns The plan that was executed.
Exceptions
| Exception | Description |
|---|---|
std::length_error | if the resident budget cannot cover interests. |
std::runtime_error | on a provider species-count mismatch, a name collision or a failed batch creation. |
clear
void clear()Remove every batch from the viewer and unload all cells.
residentCellCount
size_t residentCellCount() constReturns Number of loaded cells.
residentCells
const std::vector<WorldCellKey> &residentCells() constReturns Sorted keys of successfully loaded cells, including empty placements.
residentInstanceCount
size_t residentInstanceCount() constReturns Total instances across all resident batches.
batches
std::vector<std::shared_ptr<InstancedVisuals>> batches() constReturns All resident batches (a cell has none for a species with empty placements).