diff --git a/apps/evo-client/main.cpp b/apps/evo-client/main.cpp index aad47b0..b74c2ae 100644 --- a/apps/evo-client/main.cpp +++ b/apps/evo-client/main.cpp @@ -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(channel))) channel = static_cast(c); const SeenDeposit seen{static_cast(d.x_um) / 1000, - static_cast(d.y_um) / 1000, d.radius_um, - channel}; + static_cast(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; diff --git a/apps/evo-client/panels.cpp b/apps/evo-client/panels.cpp index 1ed5891..0835ccd 100644 --- a/apps/evo-client/panels.cpp +++ b/apps/evo-client/panels.cpp @@ -782,18 +782,25 @@ std::size_t dominant_channel(const std::array& 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(std::max(1, d.stock.at(channel))); const float scale = std::clamp(0.7F + 0.12F * static_cast(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(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(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(d.seed % 7U)); + for (int ring = 3; ring >= 1; --ring) { + const auto glow = static_cast(phase * 34.0F / static_cast(ring)); + list.AddCircleFilled({d.x, d.y}, r * (1.0F + 0.45F * static_cast(ring)), + (color & 0x00FFFFFFU) | (glow << IM_COL32_A_SHIFT)); + } + } + const auto alpha = static_cast(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(220.0F * (1.0F - t)); - const auto color = - (nutrient_colors.at(static_cast(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::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(40.0F * (1.0F - t)) << IM_COL32_A_SHIFT)); + list.AddCircleFilled({p.x, p.y}, r, + base | (static_cast(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 diff --git a/apps/evo-server/cellular_bridge.hpp b/apps/evo-server/cellular_bridge.hpp index 75833e9..2e4cf33 100644 --- a/apps/evo-server/cellular_bridge.hpp +++ b/apps/evo-server/cellular_bridge.hpp @@ -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(); diff --git a/deploy/kubernetes/region/dev-session-route/listener.yaml b/deploy/kubernetes/region/dev-session-route/listener.yaml index 3d92b80..6e33b8f 100644 --- a/deploy/kubernetes/region/dev-session-route/listener.yaml +++ b/deploy/kubernetes/region/dev-session-route/listener.yaml @@ -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. diff --git a/src/client/session/region_session.cpp b/src/client/session/region_session.cpp index 70a73dc..f08d132 100644 --- a/src/client/session/region_session.cpp +++ b/src/client/session/region_session.cpp @@ -145,6 +145,11 @@ struct RegionSessionClient::Impl { return keep(action_outcomes, *m); if (const auto* m = std::get_if(&*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; } diff --git a/src/server/session/region_sessions.cpp b/src/server/session/region_sessions.cpp index 5fe0163..1609185 100644 --- a/src/server/session/region_sessions.cpp +++ b/src/server/session/region_sessions.cpp @@ -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))) diff --git a/tests/quic_sessions.cpp b/tests/quic_sessions.cpp index 5f14694..d4a0578 100644 --- a/tests/quic_sessions.cpp +++ b/tests/quic_sessions.cpp @@ -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.