#pragma once #include "evo/client/camera.hpp" #include "evo/client/environment_view.hpp" #include "evo/render/frame.hpp" #include #include #include #include namespace evo::render { // Per cell: terrain square, up to four habitat rectangles (fill, checker or hollow // outline) and up to four voxel-outline rectangles; plus status and legend. inline constexpr std::size_t environment_legend_steps = 8; inline constexpr std::size_t max_environment_rectangles = client::max_environment_cells * 9 + 1 + environment_legend_steps; struct EnvironmentDisplay { enum class Mode : std::uint8_t { field, moisture } mode{Mode::field}; world::Field field{world::Field::water}; // Used by Mode::field only. }; // Presentation encodings, deliberately distinct from every ramp colour. namespace palette { inline constexpr Color present_zero{0, 0, 0, 255}; inline constexpr Color missing_a{150, 40, 150, 255}, missing_b{40, 12, 40, 255}; inline constexpr Color not_requested{210, 210, 210, 255}; inline constexpr Color undefined{150, 50, 30, 255}; // Moisture with zero water capacity. inline constexpr Color voxel_outline{8, 10, 14, 255}; inline constexpr Color stale_outline{240, 170, 40, 255}; inline constexpr Color status_none{200, 40, 40, 255}; inline constexpr Color status_current{64, 180, 140, 255}; inline constexpr Color status_stale{240, 170, 40, 255}; } // namespace palette // Field layers map log2(quantity / habitat volume um^3) over [-30, 12] onto the ramp, // clamping outside it. Moisture maps saturation [0, 1] linearly. Presentation only. inline constexpr double field_log2_min = -30, field_log2_max = 12; [[nodiscard]] Color ramp(double t) noexcept; [[nodiscard]] Color dim(Color color) noexcept; // Stale presentation tint. enum class EnvironmentRenderError : std::uint8_t { invalid_display }; // Replaces `out` with logical-window rectangles clipped to the camera viewport, in // cell order, ending with the status chip and legend. Output never exceeds // max_environment_rectangles; reuse `out` to avoid per-frame allocation. A null // presentation (or Freshness::none) draws only the "no environment" status. [[nodiscard]] std::expected build_environment(std::vector& out, const client::EnvironmentPresentation* presentation, client::Freshness freshness, const client::Camera& camera, EnvironmentDisplay display); } // namespace evo::render