Files
aevolution/include/evo/render/environment.hpp
T
dingoandClaude Opus 5.5 feca07f791 Implement M9.4 revision-tagged microscopic environment rendering
Add SDL-free owned EnvironmentPresentation copied from M6.3 views (no
store pointers or validation tokens), a single-slot EnvironmentLayer that
rejects foreign/regressed updates and reports none/current/stale against
observed authority watermarks, and a bounded camera projection with
explicit missing, not-requested, present-zero, undefined-moisture and
stale encodings (at most 2313 clipped rectangles, reused buffer).

The engineering app renders a local in-memory fixture authority with
configurable refresh cadence and layer selection. ADR-0080 records the
decision; validation evidence and limits are in VALIDATION.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 17:45:53 -04:00

47 lines
2.4 KiB
C++

#pragma once
#include "evo/client/camera.hpp"
#include "evo/client/environment_view.hpp"
#include "evo/render/frame.hpp"
#include <cstddef>
#include <cstdint>
#include <expected>
#include <vector>
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<void, EnvironmentRenderError>
build_environment(std::vector<Rectangle>& out, const client::EnvironmentPresentation* presentation,
client::Freshness freshness, const client::Camera& camera,
EnvironmentDisplay display);
} // namespace evo::render