Cells face where they move; a click outside closes the evolution window
Foundation / checks (checks) (push) Successful in 45m19s
Foundation / checks (deploy) (push) Successful in 3m45s
Foundation / checks (ecs) (push) Successful in 2m16s
Foundation / checks (network) (push) Successful in 19m17s
Foundation / checks (postgres) (push) Successful in 43m23s
Foundation / checks (tsan) (push) Successful in 11m39s
Foundation / checks (client) (push) Successful in 17m3s
Foundation / postgres-tools (push) Successful in 29s
Foundation / server-image (push) Successful in 3m8s
Foundation / image (push) Successful in 3m25s
Foundation / checks (checks) (push) Successful in 45m19s
Foundation / checks (deploy) (push) Successful in 3m45s
Foundation / checks (ecs) (push) Successful in 2m16s
Foundation / checks (network) (push) Successful in 19m17s
Foundation / checks (postgres) (push) Successful in 43m23s
Foundation / checks (tsan) (push) Successful in 11m39s
Foundation / checks (client) (push) Successful in 17m3s
Foundation / postgres-tools (push) Successful in 29s
Foundation / server-image (push) Successful in 3m8s
Foundation / image (push) Successful in 3m25s
The microscope view orients each cell along its last movement of at least 20 um, with the flagella trailing, easing into turns. The heading is projected with the current camera, so panning never turns a cell; a cell that has not moved keeps its seeded orientation. A left click outside the evolution window closes it (the offer stays; E or the callout reopens it), except on the frame it opens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
#include "evo/client/camera.hpp"
|
||||
#include "evo/render/frame.hpp"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace evo::client_app {
|
||||
@@ -60,4 +64,57 @@ inline void patch_box(std::vector<render::Rectangle>& out, client::ScreenPoint l
|
||||
}
|
||||
}
|
||||
}
|
||||
// 2026-10-16: a cell faces the way it last moved, flagella trailing. The heading comes
|
||||
// from the last world displacement of at least `step_mm`, projected with the current
|
||||
// camera (so panning never turns a cell), and eases toward it so a turn is visible.
|
||||
class CellHeadings {
|
||||
public:
|
||||
static constexpr double step_mm = 0.02;
|
||||
static constexpr float ease = 0.18F;
|
||||
// Per frame, per drawn cell: its screen heading, or none before it has moved.
|
||||
std::optional<float> update(std::uint64_t id, client::WorldPoint at,
|
||||
const client::Camera& camera) {
|
||||
auto& t = tracks_[id];
|
||||
t.frame = frame_;
|
||||
if (!t.anchored) {
|
||||
t.anchor = at;
|
||||
t.anchored = true;
|
||||
} else if (std::hypot(at.x_mm - t.anchor.x_mm, at.y_mm - t.anchor.y_mm) >= step_mm) {
|
||||
const auto from = camera.world_to_screen(t.anchor);
|
||||
const auto to = camera.world_to_screen(at);
|
||||
if (from && to && (to->x != from->x || to->y != from->y)) {
|
||||
t.target = static_cast<float>(std::atan2(to->y - from->y, to->x - from->x));
|
||||
if (!t.facing)
|
||||
t.heading = t.target;
|
||||
t.facing = true;
|
||||
}
|
||||
t.anchor = at;
|
||||
}
|
||||
if (!t.facing)
|
||||
return std::nullopt;
|
||||
constexpr float pi = 3.14159265F;
|
||||
float turn = t.target - t.heading;
|
||||
while (turn > pi)
|
||||
turn -= 2 * pi;
|
||||
while (turn < -pi)
|
||||
turn += 2 * pi;
|
||||
t.heading += turn * ease;
|
||||
return t.heading;
|
||||
}
|
||||
// After the frame's cells: forget cells no longer drawn.
|
||||
void end_frame() {
|
||||
std::erase_if(tracks_, [&](const auto& entry) { return entry.second.frame != frame_; });
|
||||
++frame_;
|
||||
}
|
||||
|
||||
private:
|
||||
struct Track {
|
||||
client::WorldPoint anchor{};
|
||||
float heading{}, target{};
|
||||
bool anchored{}, facing{};
|
||||
std::uint64_t frame{};
|
||||
};
|
||||
std::unordered_map<std::uint64_t, Track> tracks_;
|
||||
std::uint64_t frame_{};
|
||||
};
|
||||
} // namespace evo::client_app
|
||||
|
||||
@@ -467,7 +467,8 @@ int main(int argc, char** argv) try {
|
||||
bool auth_connect = false; // Connect when the requested grant arrives.
|
||||
auto grant_requested = std::chrono::steady_clock::time_point{};
|
||||
int drawn_organisms = -1;
|
||||
evo::client_app::CellularScene scene; // Rebuilt each frame in cellular play.
|
||||
evo::client_app::CellularScene scene; // Rebuilt each frame in cellular play.
|
||||
evo::client_app::CellHeadings headings; // Where each drawn cell last moved.
|
||||
bool scene_active = false;
|
||||
evo::client_app::PanelActions actions;
|
||||
(*app)->set_overlay([&] {
|
||||
@@ -783,8 +784,20 @@ int main(int argc, char** argv) try {
|
||||
c.stale =
|
||||
org_layer && org_layer->freshness() != evo::client::Freshness::current;
|
||||
c.seed = cell.id;
|
||||
// The organism projection's world position (organism_bounds).
|
||||
constexpr auto pitch = static_cast<double>(evo::world::cell_pitch_mm);
|
||||
const evo::client::WorldPoint at{
|
||||
static_cast<double>(cell.voxel.x) * pitch +
|
||||
static_cast<double>(cell.x.value) / 1000,
|
||||
static_cast<double>(cell.voxel.y) * pitch +
|
||||
static_cast<double>(cell.y.value) / 1000};
|
||||
if (const auto heading = headings.update(cell.id, at, *camera)) {
|
||||
c.facing = true;
|
||||
c.heading = *heading;
|
||||
}
|
||||
scene.cells.push_back(c);
|
||||
}
|
||||
headings.end_frame();
|
||||
drawn_organisms = static_cast<int>(scene.cells.size());
|
||||
scene_active = true;
|
||||
} else {
|
||||
|
||||
@@ -692,7 +692,7 @@ ImVec2 times(ImVec2 a, float k) noexcept {
|
||||
// only the viewer's own cell gets a faint focus ring.
|
||||
void draw_cell(ImDrawList& list, const SceneCell& c, float time) {
|
||||
const float r = std::max(c.radius, 5.0F);
|
||||
const float angle = static_cast<float>(c.seed % 628U) / 100.0F;
|
||||
const float angle = c.facing ? c.heading : static_cast<float>(c.seed % 628U) / 100.0F;
|
||||
const ImVec2 axis{std::cos(angle), std::sin(angle)};
|
||||
const ImVec2 normal{-axis.y, axis.x};
|
||||
const ImVec2 centre{c.x, c.y};
|
||||
@@ -1301,6 +1301,12 @@ void evolution_window(const PanelView& v, FormBuffers& form, PanelActions& a, bo
|
||||
form.evolution_open = false;
|
||||
ImGui::SameLine();
|
||||
disabled_wrapped("Earned feeding brings the next offer.");
|
||||
// A click outside closes the offer (the offer stays; E or the callout reopens it). Not
|
||||
// on the frame it appears: the click that opened it is outside it.
|
||||
if (!ImGui::IsWindowAppearing() && ImGui::IsMouseClicked(ImGuiMouseButton_Left) &&
|
||||
!ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows |
|
||||
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
|
||||
form.evolution_open = false;
|
||||
ImGui::End();
|
||||
}
|
||||
void cellular(const PanelView& v, FormBuffers& form, PanelActions& a) {
|
||||
|
||||
@@ -29,7 +29,9 @@ struct SceneCell {
|
||||
float x{}, y{}, radius{}, membrane{};
|
||||
int flagella{}, organelles{};
|
||||
bool own{}, dead{}, stale{};
|
||||
std::uint64_t seed{}; // Stable per organism: orientation and organelle layout.
|
||||
std::uint64_t seed{}; // Stable per organism: organelle layout (and orientation at rest).
|
||||
bool facing{}; // Heading is known: the cell faces it, flagella trailing.
|
||||
float heading{}; // Screen radians.
|
||||
};
|
||||
struct ScenePatch {
|
||||
float x{}, y{}, half{}; // Centre and half side of the 1 mm contact footprint.
|
||||
|
||||
@@ -12,7 +12,7 @@ spec:
|
||||
env:
|
||||
- {name: REGION_SESSION, value: "dev"}
|
||||
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261016T153551-32866:1792175751"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261016T153552-98691:1792175752"}
|
||||
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
|
||||
ports:
|
||||
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
|
||||
|
||||
@@ -517,6 +517,22 @@ void cellular_panels(const std::filesystem::path& review) {
|
||||
CHECK(app->request_screenshot((review / "cellular-evolution.bmp").string()));
|
||||
draw();
|
||||
}
|
||||
// A click outside closes it; E opens it again.
|
||||
const float outside_x = evolution->Pos.x / 2;
|
||||
const float outside_y = evolution->Pos.y + evolution->Size.y / 2;
|
||||
mouse(id, SDL_EVENT_MOUSE_MOTION, outside_x, outside_y);
|
||||
mouse(id, SDL_EVENT_MOUSE_BUTTON_DOWN, outside_x, outside_y);
|
||||
mouse(id, SDL_EVENT_MOUSE_BUTTON_UP, outside_x, outside_y);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
draw();
|
||||
CHECK(!form.evolution_open);
|
||||
(void)app->take_navigation();
|
||||
CHECK(SDL_PushEvent(&e_key));
|
||||
draw();
|
||||
CHECK(SDL_PushEvent(&e_up));
|
||||
for (int i = 0; i < 3; ++i)
|
||||
draw();
|
||||
CHECK(form.evolution_open);
|
||||
// Click the first production choice. Pointer ownership prevents world selection.
|
||||
const auto probe = [&](const ImGuiWindow* panel, float x_fraction, const auto& done) {
|
||||
const float x = panel->Pos.x + panel->Size.x * x_fraction;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "evo/client/session_host.hpp"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
@@ -511,6 +512,38 @@ void cellular_energy_and_birth_wait() {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// A cell faces the way it moved (y up in the world is up on screen), eases into a turn,
|
||||
// ignores sub-step jitter and camera panning, and is forgotten once it is not drawn.
|
||||
void cell_headings() {
|
||||
using namespace evo::client_app;
|
||||
auto camera = Camera::create({800, 600, 800, 600}, {5, 5}, 100);
|
||||
CHECK(camera);
|
||||
CellHeadings headings;
|
||||
CHECK(!headings.update(1, {5, 5}, *camera));
|
||||
headings.end_frame();
|
||||
CHECK(!headings.update(1, {5.001, 5}, *camera)); // Below the step: still unknown.
|
||||
headings.end_frame();
|
||||
const auto east = headings.update(1, {5.1, 5}, *camera);
|
||||
CHECK(east && std::abs(*east) < 1e-4F);
|
||||
headings.end_frame();
|
||||
auto panned = Camera::create({800, 600, 800, 600}, {9, 2}, 100);
|
||||
CHECK(panned);
|
||||
const auto still = headings.update(1, {5.1, 5}, *panned);
|
||||
CHECK(still && std::abs(*still) < 1e-4F);
|
||||
headings.end_frame();
|
||||
// Moving north is screen up (negative y): the heading eases toward -pi/2.
|
||||
const auto turning = headings.update(1, {5.1, 5.2}, *camera);
|
||||
CHECK(turning && *turning < 0 && *turning > -1.5707F);
|
||||
headings.end_frame();
|
||||
float heading = turning.value_or(0);
|
||||
for (int i = 0; i < 60; ++i) {
|
||||
heading = headings.update(1, {5.1, 5.2}, *camera).value_or(0);
|
||||
headings.end_frame();
|
||||
}
|
||||
CHECK(std::abs(heading + 1.5708F) < 1e-3F);
|
||||
headings.end_frame(); // Not drawn this frame: forgotten.
|
||||
CHECK(!headings.update(1, {6, 6}, *camera));
|
||||
}
|
||||
int main() try {
|
||||
labels();
|
||||
selection();
|
||||
@@ -520,6 +553,7 @@ int main() try {
|
||||
cellular_play();
|
||||
cellular_energy_and_birth_wait();
|
||||
cellular_assistance();
|
||||
cell_headings();
|
||||
std::puts("client UI model tests passed");
|
||||
return 0;
|
||||
} catch (const std::exception& e) {
|
||||
|
||||
Reference in New Issue
Block a user