mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 09:00:34 +00:00
more accurate portal movement
This commit is contained in:
parent
8d0059a760
commit
0966d5e36c
@ -2904,13 +2904,8 @@ EX void shift_view(hyperpoint H) {
|
||||
if(callhandlers(false, hooks_shift_view, H)) return;
|
||||
static bool recursive = false;
|
||||
if(!recursive && intra::in) {
|
||||
H /= 10;
|
||||
recursive = true;
|
||||
for(int i=0; i<10; i++) {
|
||||
shift_view(H);
|
||||
intra::check_portal_movement();
|
||||
}
|
||||
recursive = false;
|
||||
dynamicval<bool> r(recursive, true);
|
||||
intra::shift_view_portal(H);
|
||||
return;
|
||||
}
|
||||
auto oView = View;
|
||||
|
26
intra.cpp
26
intra.cpp
@ -329,7 +329,25 @@ EX int full_wall_offset(cell *c) {
|
||||
return wo;
|
||||
}
|
||||
|
||||
EX void check_portal_movement() {
|
||||
EX void shift_view_portal(hyperpoint H) {
|
||||
shift_view(H);
|
||||
if(!through_portal()) return;
|
||||
shift_view(-H);
|
||||
ld minv = 0, maxv = 1;
|
||||
for(int i=0; i<30; i++) {
|
||||
ld t = (minv + maxv) / 2;
|
||||
shift_view(H * t);
|
||||
bool b = through_portal();
|
||||
if(b) maxv = t; else minv = t;
|
||||
shift_view(H * -t);
|
||||
}
|
||||
println(hlog, "maxv = ", maxv);
|
||||
shift_view(H * maxv);
|
||||
check_portal_movement();
|
||||
shift_view(H * (1 - maxv));
|
||||
}
|
||||
|
||||
EX const connection_data* through_portal() {
|
||||
transmatrix iView = view_inverse(View);
|
||||
ld dist = hdist0(iView * C0);
|
||||
int nei = -1;
|
||||
@ -339,8 +357,12 @@ EX void check_portal_movement() {
|
||||
}
|
||||
|
||||
auto cw1 = cellwalker(centerover, nei);
|
||||
return at_or_null(connections, cw1);
|
||||
}
|
||||
|
||||
EX void check_portal_movement() {
|
||||
auto p = through_portal();
|
||||
ld c = camera_speed;
|
||||
auto p = at_or_null(connections, cw1);
|
||||
if(p) {
|
||||
ld eps = 1e-3;
|
||||
c /= p->id1.scale;
|
||||
|
Loading…
Reference in New Issue
Block a user