Stop the cell vanishing for a frame; eating glows instead of pulsing
Foundation / checks (deploy) (push) Successful in 26s
Foundation / checks (network) (push) Successful in 29s
Foundation / checks (ecs) (push) Successful in 53s
Foundation / checks (client) (push) Successful in 57s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 5m32s
Foundation / checks (tsan) (push) Canceled after 5m8s
Foundation / checks (postgres) (push) Canceled after 5m33s

Every tick the server sent each cellular session an empty view and then the owner's
real view. When the two landed in different client frames the client saw no cell:
steering stopped, the "no active cell" panel popped up, and every visible bubble
"vanished" at once and played its pop, a wave across the screen at random moments
(likelier with v11's larger views).

- Server: a session given a view this tick is no longer cleared in the same tick; the
  clear now follows every owner's view and reaches only sessions that got none.
- Client: an empty view never replaces a real one of the same tick (older servers).
- Only a bubble that was being eaten when last seen fades when it disappears; leaving
  the view or an empty view draws nothing.
- Eating is a soft glow in the bubble's colour, fading in and out about 1.5 times a
  second, instead of a size pulse; a finished bubble's glow shrinks and fades.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-17 10:56:27 -04:00
co-authored by Claude Opus 5.5
parent 43113e6c35
commit fcc6c57320
7 changed files with 65 additions and 22 deletions
+13 -6
View File
@@ -476,6 +476,7 @@ int main(int argc, char** argv) try {
double x_mm{}, y_mm{};
std::uint32_t radius_um{};
int channel{};
bool drained{}, bubble{};
};
struct LivePop {
SeenDeposit at;
@@ -785,8 +786,12 @@ int main(int argc, char** argv) try {
if (stock.at(c) > stock.at(static_cast<std::size_t>(channel)))
channel = static_cast<int>(c);
const SeenDeposit seen{static_cast<double>(d.x_um) / 1000,
static_cast<double>(d.y_um) / 1000, d.radius_um,
channel};
static_cast<double>(d.y_um) / 1000,
d.radius_um,
channel,
d.drained,
d.shape ==
evo::network::CellularDepositShape::bubble};
current[d.id] = seen;
const auto centre = camera->world_to_screen({seen.x_mm, seen.y_mm});
const auto edge = camera->world_to_screen(
@@ -804,11 +809,13 @@ int main(int argc, char** argv) try {
drawn.seed = d.id;
scene.deposits.push_back(drawn);
}
// A bubble absent from a newer view while its old spot is still in
// sight ran out (or left the sensor's edge, which a pop also suits).
if (perception->tick != seen_deposit_tick) {
// A bubble that was being eaten and is gone from a newer view of the
// same life ran out: it fades. Anything else that leaves the view (out
// of range, or an empty view) just stops being drawn.
if (perception->tick != seen_deposit_tick && perception->life_identity != 0) {
for (const auto& [id, old] : seen_deposits)
if (!current.contains(id) && live_pops.size() < 256)
if (old.bubble && old.drained && !current.contains(id) &&
live_pops.size() < 64)
live_pops.push_back({old, now_pop});
seen_deposits = std::move(current);
seen_deposit_tick = perception->tick;
+21 -12
View File
@@ -782,18 +782,25 @@ std::size_t dominant_channel(const std::array<std::uint64_t, 5>& stock) {
return best;
}
// ADR-0136: a bubble is a translucent circle in its nutrient's colour, sized by what it
// holds (never below its contact disc), and pulsing while something drains it.
// holds (never below its contact disc). While something eats it, a soft glow of its own
// colour fades in and out around it; the bubble itself keeps its size.
void draw_bubble(ImDrawList& list, const SceneDeposit& d, float time) {
const auto channel = dominant_channel(d.stock);
const auto total = static_cast<double>(std::max<std::uint64_t>(1, d.stock.at(channel)));
const float scale =
std::clamp(0.7F + 0.12F * static_cast<float>(std::log10(total)), 0.8F, 2.2F);
float r = std::max(d.radius * scale * 0.5F, 2.5F);
if (d.drained)
r *=
1.0F + 0.25F * (0.5F + 0.5F * std::sin(time * 18.0F + static_cast<float>(d.seed % 7U)));
const float r = std::max(d.radius * scale * 0.5F, 2.5F);
auto color = nutrient_colors.at(channel);
const auto alpha = static_cast<unsigned>(d.stale ? 90 : (d.drained ? 255 : 200));
if (d.drained && !d.stale) {
// About 1.5 glows a second, eased: a breathing light, not a shock wave.
const float phase = 0.5F - 0.5F * std::cos(time * 9.0F + static_cast<float>(d.seed % 7U));
for (int ring = 3; ring >= 1; --ring) {
const auto glow = static_cast<unsigned>(phase * 34.0F / static_cast<float>(ring));
list.AddCircleFilled({d.x, d.y}, r * (1.0F + 0.45F * static_cast<float>(ring)),
(color & 0x00FFFFFFU) | (glow << IM_COL32_A_SHIFT));
}
}
const auto alpha = static_cast<unsigned>(d.stale ? 90 : 210);
color = (color & 0x00FFFFFFU) | (alpha << IM_COL32_A_SHIFT);
list.AddCircleFilled({d.x, d.y}, r, (color & 0x00FFFFFFU) | ((alpha / 3) << IM_COL32_A_SHIFT));
list.AddCircle({d.x, d.y}, r, color, 0, std::max(1.0F, r * 0.18F));
@@ -837,14 +844,16 @@ void draw_pool(ImDrawList& list, const SceneDeposit& d, float time) {
}
}
}
// A bubble that ran out: its glow shrinks and fades away where it was.
void draw_pop(ImDrawList& list, const ScenePop& p) {
const float t = std::clamp(p.age, 0.0F, 1.0F);
const auto alpha = static_cast<unsigned>(220.0F * (1.0F - t));
const auto color =
(nutrient_colors.at(static_cast<std::size_t>(std::clamp(p.channel, 0, 4))) & 0x00FFFFFFU) |
(alpha << IM_COL32_A_SHIFT);
list.AddCircle({p.x, p.y}, std::max(p.radius, 3.0F) * (0.6F + 1.6F * t), color, 0,
1.5F * (1.0F - t) + 0.5F);
const auto base =
nutrient_colors.at(static_cast<std::size_t>(std::clamp(p.channel, 0, 4))) & 0x00FFFFFFU;
const float r = std::max(p.radius * 0.5F, 2.5F) * (1.0F - 0.7F * t);
list.AddCircleFilled({p.x, p.y}, r * 1.6F,
base | (static_cast<unsigned>(40.0F * (1.0F - t)) << IM_COL32_A_SHIFT));
list.AddCircleFilled({p.x, p.y}, r,
base | (static_cast<unsigned>(160.0F * (1.0F - t)) << IM_COL32_A_SHIFT));
}
// The eyepiece: everything outside a rounded viewport is masked (a thick rounded stroke
// covers the corners) and a vignette darkens toward the rim. Zooming out of the cellular
+2 -1
View File
@@ -198,7 +198,6 @@ class CellularBridge {
return result;
};
sessions_->replicate(tick, source);
sessions_->clear_cellular_perceptions(tick);
for (const auto& life : state.lives()) {
if (life.presence == server::CellularPresence::suspended)
continue;
@@ -324,6 +323,8 @@ class CellularBridge {
(void)sessions_->send_cellular_perception(network::AccountId{life.account}, view);
send_offer(state, life, tick);
}
// After every owner's view: clear only the sessions that got none this tick.
sessions_->clear_cellular_perceptions(tick);
std::erase_if(offers_, [&](const SentOffer& sent) {
return std::ranges::find(state.lives(), sent.account,
&server::CellularOwnedLife::account) == state.lives().end();
@@ -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-20261017T140925-89543:1792256965"}
- {name: REGION_SESSION_WINDOW, value: "dev-20261017T145627-23067:1792259787"}
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
ports:
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
+5
View File
@@ -145,6 +145,11 @@ struct RegionSessionClient::Impl {
return keep(action_outcomes, *m);
if (const auto* m = std::get_if<network::CellularPerception>(&*decoded)) {
seen_tick(m->tick);
// An empty view never replaces a real one of the same tick: older servers
// sent both, and the cell vanished for a frame (input stopped, panels opened).
if (m->life_identity == 0 && cellular_perception &&
cellular_perception->tick == m->tick && cellular_perception->life_identity != 0)
return;
cellular_perception = *m;
return;
}
+7 -2
View File
@@ -92,6 +92,8 @@ struct RegionSessions::Impl {
std::string account;
Clock::time_point deadline; // Hello, pending (Welcome due) or close flush.
bool close_requested{};
// The tick of the last owner view sent; a clear never follows it in that tick.
std::uint64_t perceived_tick{};
// Durable control (ledger only).
network::AccountId account_id;
std::uint64_t generation{};
@@ -930,13 +932,14 @@ void RegionSessions::replicate(
bool RegionSessions::send_cellular_perception(const network::AccountId& account,
const network::CellularPerception& perception) {
auto& m = *impl_;
for (const auto& c : m.connections) {
for (auto& c : m.connections) {
if (c.state != Impl::State::established ||
(c.protocol_version != network::session_protocol_v8 &&
c.protocol_version != network::session_protocol_v9 &&
!network::cellular_v10_family(c.protocol_version)) ||
c.account_id != account)
continue;
c.perceived_tick = perception.tick;
auto delivered = perception;
// v11 sees deposits (ADR-0136), earlier versions square patches; never both.
if (c.protocol_version == network::session_protocol_v11)
@@ -976,8 +979,10 @@ void RegionSessions::clear_cellular_perceptions(std::uint64_t tick) {
return;
auto& m = *impl_;
const network::CellularPerception cleared{tick, 0, {}, {}};
// Only a connection with no view this tick is cleared: a clear arriving after (or
// before) the real view of the same tick made the client drop its cell for a frame.
for (const auto& c : m.connections)
if (c.state == Impl::State::established &&
if (c.state == Impl::State::established && c.perceived_tick != tick &&
(c.protocol_version == network::session_protocol_v8 ||
c.protocol_version == network::session_protocol_v9 ||
network::cellular_v10_family(c.protocol_version)))
+16
View File
@@ -791,6 +791,22 @@ void cellular_v5_spawn_and_v7_action_share_region_sessions(const Files& f) {
}));
CHECK(perception_owner->cellular_perception()->life_identity == 0 &&
perception_owner->cellular_perception()->patches.empty());
// A session given a view this tick is never cleared in the same tick (the cell would
// vanish for a frame); one without a view still is.
auto later = perception;
later.tick = 103;
CHECK(h.server->send_cellular_perception(owner_account, later));
h.server->clear_cellular_perceptions(103);
CHECK(h.until([&] {
return legacy_owner->cellular_perception() &&
legacy_owner->cellular_perception()->tick == 103;
}));
CHECK(legacy_owner->cellular_perception()->life_identity == 0);
CHECK(h.until([&] {
return perception_owner->cellular_perception() &&
perception_owner->cellular_perception()->tick == 103;
}));
CHECK(*perception_owner->cellular_perception() == later);
}
// M10.4: intentions, actions and their distinct answers against a simulated host.