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

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:
dingo
2026-10-16 11:35:52 -04:00
co-authored by Claude Opus 5.5
parent 7929dea2fc
commit 521372607a
7 changed files with 132 additions and 4 deletions
+57
View File
@@ -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