mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-24 16:07:07 +00:00
intra:: cleaner scale changing
This commit is contained in:
parent
c94e927929
commit
c69bed4d12
@ -2263,6 +2263,10 @@ EX void optimizeview() {
|
|||||||
fixmatrix(View);
|
fixmatrix(View);
|
||||||
callhooks(hooks_postoptimize);
|
callhooks(hooks_postoptimize);
|
||||||
|
|
||||||
|
#if CAP_PORTALS
|
||||||
|
intra::apply_scale();
|
||||||
|
#endif
|
||||||
|
|
||||||
walking::handle();
|
walking::handle();
|
||||||
|
|
||||||
if(is_boundary(centerover))
|
if(is_boundary(centerover))
|
||||||
|
37
intra.cpp
37
intra.cpp
@ -527,21 +527,21 @@ EX void analyze_orthonormal(array<hyperpoint, 4> ds, ld sca) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EX void shift_view_portal(hyperpoint H) {
|
EX void shift_view_portal(hyperpoint H) {
|
||||||
shift_view(H);
|
shift_view(H * scale);
|
||||||
if(!through_portal()) return;
|
if(!through_portal()) return;
|
||||||
shift_view(-H);
|
shift_view(-H * scale);
|
||||||
ld minv = 0, maxv = 1;
|
ld minv = 0, maxv = 1;
|
||||||
for(int i=0; i<30; i++) {
|
for(int i=0; i<30; i++) {
|
||||||
ld t = (minv + maxv) / 2;
|
ld t = (minv + maxv) / 2;
|
||||||
shift_view(H * t);
|
shift_view(H * t * scale);
|
||||||
bool b = through_portal();
|
bool b = through_portal();
|
||||||
if(b) maxv = t; else minv = t;
|
if(b) maxv = t; else minv = t;
|
||||||
shift_view(H * -t);
|
shift_view(H * -t * scale);
|
||||||
}
|
}
|
||||||
println(hlog, "maxv = ", maxv);
|
println(hlog, "maxv = ", maxv);
|
||||||
shift_view(H * maxv);
|
shift_view(H * maxv * scale);
|
||||||
check_portal_movement();
|
check_portal_movement();
|
||||||
shift_view_portal(H * (1 - maxv));
|
shift_view_portal(H * (1 - maxv) * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
EX const connection_data* through_portal() {
|
EX const connection_data* through_portal() {
|
||||||
@ -552,6 +552,8 @@ EX const connection_data* through_portal() {
|
|||||||
return at_or_null(connections, cw1);
|
return at_or_null(connections, cw1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EX ld scale = 1;
|
||||||
|
|
||||||
EX void check_portal_movement() {
|
EX void check_portal_movement() {
|
||||||
auto p = through_portal();
|
auto p = through_portal();
|
||||||
|
|
||||||
@ -620,20 +622,27 @@ EX void check_portal_movement() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ld scale = p->id2.scale / p->id1.scale;
|
scale *= p->id2.scale / p->id1.scale;
|
||||||
|
|
||||||
camera_speed *= scale;
|
|
||||||
anims::cycle_length *= scale;
|
|
||||||
#if CAP_VR
|
|
||||||
vrhr::absolute_unit_in_meters *= scale;
|
|
||||||
#endif
|
|
||||||
if(walking::eye_level != -1) walking::eye_level *= scale;
|
|
||||||
|
|
||||||
walking::floor_dir = -1;
|
walking::floor_dir = -1;
|
||||||
walking::on_floor_of = nullptr;
|
walking::on_floor_of = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EX void apply_scale() {
|
||||||
|
if(scale != 1) {
|
||||||
|
camera_speed *= scale;
|
||||||
|
anims::cycle_length *= scale;
|
||||||
|
vid.ipd *= scale;
|
||||||
|
#if CAP_VR
|
||||||
|
vrhr::absolute_unit_in_meters *= scale;
|
||||||
|
#endif
|
||||||
|
if(walking::eye_level != -1) walking::eye_level *= scale;
|
||||||
|
scale = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
vector<cellwalker> unconnected;
|
vector<cellwalker> unconnected;
|
||||||
|
|
||||||
void erase_unconnected(cellwalker cw) {
|
void erase_unconnected(cellwalker cw) {
|
||||||
|
7
vr.cpp
7
vr.cpp
@ -1095,12 +1095,9 @@ EX void render() {
|
|||||||
dynamicval<transmatrix> tV(View, View);
|
dynamicval<transmatrix> tV(View, View);
|
||||||
dynamicval<transmatrix> tC(current_display->which_copy, current_display->which_copy);
|
dynamicval<transmatrix> tC(current_display->which_copy, current_display->which_copy);
|
||||||
dynamicval<transmatrix> trt(current_display->radar_transform);
|
dynamicval<transmatrix> trt(current_display->radar_transform);
|
||||||
|
dynamicval<ld> tcs(intra::scale);
|
||||||
|
|
||||||
/* changed in intra */
|
// just in case
|
||||||
dynamicval<ld> tcs(camera_speed);
|
|
||||||
dynamicval<ld> tcl(anims::cycle_length);
|
|
||||||
dynamicval<ld> tau(vrhr::absolute_unit_in_meters);
|
|
||||||
dynamicval<ld> tel(walking::eye_level);
|
|
||||||
dynamicval<int> tfd(walking::floor_dir);
|
dynamicval<int> tfd(walking::floor_dir);
|
||||||
dynamicval<cell*> tof(walking::on_floor_of);
|
dynamicval<cell*> tof(walking::on_floor_of);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user