mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-06-16 05:14:06 +00:00
ads-game:: priority_queue-based rendering
This commit is contained in:
parent
7a7ee1a13f
commit
03a3fd14a0
@ -217,17 +217,19 @@ void view_ads_game() {
|
|||||||
make_shape();
|
make_shape();
|
||||||
|
|
||||||
set<cell*> visited;
|
set<cell*> visited;
|
||||||
queue<pair<cell*, ads_matrix>> dq;
|
using key = tuple<ld, cell*, ads_matrix>;
|
||||||
auto visit = [&] (cell *c, const ads_matrix& V) {
|
auto cmp = [] (const key& a1, const key& a2) { return get<0>(a1) < get<0>(a2); };
|
||||||
|
std::priority_queue<key, vector<key>, decltype(cmp)> dq(cmp);
|
||||||
|
auto visit = [&] (ld t, cell *c, const ads_matrix& V) {
|
||||||
auto w = hybrid::get_where(c);
|
auto w = hybrid::get_where(c);
|
||||||
if(visited.count(w.first)) return;
|
if(visited.count(w.first)) return;
|
||||||
visited.insert(w.first);
|
visited.insert(w.first);
|
||||||
dq.emplace(c, V);
|
dq.emplace(t, c, V);
|
||||||
};
|
};
|
||||||
|
|
||||||
hybrid::in_actual([&] {
|
hybrid::in_actual([&] {
|
||||||
dynamicval<eGeometry> b(geometry, gRotSpace);
|
dynamicval<eGeometry> b(geometry, gRotSpace);
|
||||||
visit(vctr, vctrV);
|
visit(0, vctr, vctrV);
|
||||||
vctr_dist = HUGE_VAL;
|
vctr_dist = HUGE_VAL;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -235,9 +237,9 @@ void view_ads_game() {
|
|||||||
while(!dq.empty()) {
|
while(!dq.empty()) {
|
||||||
|
|
||||||
i++; if(i > draw_per_frame) break;
|
i++; if(i > draw_per_frame) break;
|
||||||
auto& p = dq.front();
|
auto& p = dq.top();
|
||||||
cell *c = p.first;
|
cell *c = get<1>(p);
|
||||||
ads_matrix V = p.second;
|
ads_matrix V = get<2>(p);
|
||||||
dq.pop();
|
dq.pop();
|
||||||
|
|
||||||
draw_game_cell(c, V, plev);
|
draw_game_cell(c, V, plev);
|
||||||
@ -247,7 +249,13 @@ void view_ads_game() {
|
|||||||
cell *c2 = c->cmove(i);
|
cell *c2 = c->cmove(i);
|
||||||
auto V1 = V * currentmap->adj(c, i);
|
auto V1 = V * currentmap->adj(c, i);
|
||||||
optimize_shift(V1);
|
optimize_shift(V1);
|
||||||
visit(c2, V1);
|
|
||||||
|
auto g = hybrid::get_where(c2);
|
||||||
|
adjust_to_zero(V1, g, plev);
|
||||||
|
c2 = hybrid::get_at(g.first, 0);
|
||||||
|
auto center = findflat(V1 * C0);
|
||||||
|
|
||||||
|
visit(-hdist0(center.h), c2, V1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user