diff --git a/rogueviz/ads/display.cpp b/rogueviz/ads/display.cpp index 4eac23ac..f5bfd620 100644 --- a/rogueviz/ads/display.cpp +++ b/rogueviz/ads/display.cpp @@ -182,12 +182,10 @@ void draw_game_cell(const cell_to_draw& cd) { queuestr(shiftless(rgpushxto0(rock.pt_main.h)), time_scale, str, 0xFFFFFF, 8); } } - - /* todo: binary search */ - if(paused || which_cross) for(auto& rock: ci.shipstates) { - cross_result cr; - if(hv) render_ship_parts([&] (const hpcshape& sh, color_t col, int sym) { + if(paused || which_cross) if(hv) for(auto& rock: ci.shipstates) { + + render_ship_parts([&] (const hpcshape& sh, color_t col, int sym) { int dx = sym ? -1 : 1; for(int i=sh.s; i b(geometry, gTwistedProduct); + auto h = V * ci.shipstates[med].at; + cr = cross0(current * h); + }); + if(cr.shift < -1e-6) hi = med - 1; + else lo = med; + } + + auto& rock = ci.shipstates[lo]; hybrid::in_actual([&]{ dynamicval b(geometry, gTwistedProduct); auto h = V * rock.at; cr = cross0(current * h); }); - - if(cr.shift < -1e-6 || cr.shift > rock.duration + 1e-6) continue; - render_ship_parts([&] (const hpcshape& sh, color_t col, int sym) { + bool ok = cr.shift >= -1e-6 && cr.shift < rock.duration + 1e-6; + + if(ok) render_ship_parts([&] (const hpcshape& sh, color_t col, int sym) { int dx = sym ? -1 : 1; vector pts; for(int i=sh.s; i