Implement M9.5 biology-derived organism rendering and inspector

Add OrganismPresentation cells derived via biology::derive_phenotype with
no controller, owner or level fields (pinned by test), so identical
biology renders identically for players and NPCs. OrganismLayer reuses
the ADR-0080 ordering/freshness semantics; death is a remnant state and
removal is absence. Rendering takes an explicit rectangle budget, falls
back to body-only detail and marks truncation instead of dropping data.
An opt-in rectangle-only hover inspector shows phenotype gauges; ImGui is
not adopted. ADR-0081 records the decision; evidence in VALIDATION.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-01 18:21:53 -04:00
co-authored by Claude Opus 5.5
parent feca07f791
commit 9bb147de82
21 changed files with 1169 additions and 33 deletions
+50
View File
@@ -0,0 +1,50 @@
#pragma once
#include "evo/client/camera.hpp"
#include "evo/client/organism_view.hpp"
#include "evo/render/frame.hpp"
#include <cstddef>
#include <cstdint>
#include <expected>
#include <vector>
namespace evo::render {
// Full detail: motility ring (4), body (1), membrane (4), ingestion mark (1). Bodies
// smaller than organism_detail_side draw as a dark halo plus body (2).
inline constexpr std::size_t organism_detail_rectangles = 10;
// Freshness chip plus an explicit truncation marker.
inline constexpr std::size_t organism_status_rectangles = 2;
// Uniform minimum on-screen body side (logical units) so micrometre organisms stay
// visible when zoomed out. Below it, drawn sizes are not comparable; inspect values.
inline constexpr double organism_visibility_floor = 5;
inline constexpr double organism_detail_side = 6;
namespace organism_palette {
inline constexpr Color ring{200, 230, 240, 255};
inline constexpr Color mouth{20, 16, 24, 255};
inline constexpr Color halo{8, 8, 12, 255}; // Contrast backing for collapsed bodies.
inline constexpr Color remnant{110, 95, 80, 255};
inline constexpr Color truncated{255, 0, 200, 255};
} // namespace organism_palette
struct ScreenBox {
double left{}, top{}, right{}, bottom{};
};
// Unclipped body box in logical window units, after the visibility floor. Shared by
// rendering and picking so both agree on what is under the pointer.
[[nodiscard]] ScreenBox organism_bounds(const client::OrganismCell& cell,
const client::Camera& camera) noexcept;
// Body colour from conversion, realized growth, damage and alive/dead state only.
[[nodiscard]] Color organism_fill(const client::OrganismCell& cell) noexcept;
enum class OrganismDetail : std::uint8_t { full, body_only };
struct OrganismRenderReport {
std::size_t visible{}, drawn{};
OrganismDetail detail{OrganismDetail::full};
};
enum class OrganismRenderError : std::uint8_t { invalid_budget };
// Appends at most `budget` rectangles (>= organism_status_rectangles) in id order.
// Detail is chosen once per call: full when every visible organism fits at full
// detail, otherwise one body rectangle each (no halo); organisms beyond the budget are not
// drawn and the magenta truncation marker appears. Nothing is dropped silently.
[[nodiscard]] std::expected<OrganismRenderReport, OrganismRenderError>
append_organisms(std::vector<Rectangle>& out, std::size_t budget,
const client::OrganismPresentation* presentation, client::Freshness freshness,
const client::Camera& camera);
} // namespace evo::render