diff --git a/control.cpp b/control.cpp index c534d9a7..364ee60e 100644 --- a/control.cpp +++ b/control.cpp @@ -643,6 +643,9 @@ void mainloopiter() { View = cspin(0, 2, -mouseaim_x) * cspin(1, 2, -mouseaim_y) * View; mouseaim_x = mouseaim_y = 0; #endif + #if CAP_ORIENTATION + apply_orientation(); + #endif } if(smooth_scrolling && !shmup::on && !rug::rugged) { diff --git a/hypgraph.cpp b/hypgraph.cpp index aaa852ce..804a45e2 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1096,7 +1096,7 @@ void spinEdge(ld aspd) { while(downspin > +M_PI) downspin -= 2*M_PI; aspd = (1 + 2 * abs(downspin)) * aspd; } - else if(WDIM == 2 && GDIM == 3 && vid.fixed_yz) { + else if(WDIM == 2 && GDIM == 3 && vid.fixed_yz && !CAP_ORIENTATION) { aspd = 999999; if(straightDownSeek) { if(straightDownPoint[0]) diff --git a/init.cpp b/init.cpp index 9240ae4d..a9b558ef 100644 --- a/init.cpp +++ b/init.cpp @@ -223,6 +223,31 @@ int touchedAt; void shareScore(MOBPAR_FORMAL); #endif +#if CAP_ORIENTATION +int first_check, last_check; +transmatrix main_last_orientation; + +void apply_orientation() { + if(ticks > last_check + 2000) first_check = ticks; + last_check = ticks; + transmatrix T = MirrorX * hr::getOrientation() * MirrorX; + if(ticks < first_check + 500) + main_last_orientation = T; + else { + transmatrix next_orientation = T; + View = main_last_orientation * View; + if(WDIM == 2 && vid.fixed_yz) { + if(View[0][2] || View[1][2] || View[2][2]) { + View = cspin(0, 2, -atan2(View[0][2], View[2][2])) * View; + View = cspin(1, 2, -atan2(View[1][2], View[2][2])) * View; + } + } + View = inverse(next_orientation) * View; + main_last_orientation = next_orientation; + } + } +#endif + void mobile_draw(MOBPAR_FORMAL) { apply_memory_reserve(); @@ -234,6 +259,9 @@ void mobile_draw(MOBPAR_FORMAL) { ors::check_orientation(); + if(DIM == 3 && !shmup::on && !rug::rugged) + apply_orientation(); + if(playermoved && vid.sspeed > -4.99) centerpc(tdiff / 1000.0 * exp(vid.sspeed)); @@ -339,7 +367,7 @@ void mobile_draw(MOBPAR_FORMAL) { if(lclicked && !clicked) { if(rug::rugged) rug::select(); - else if(ors::mode && !verylongclick) + else if((ors::mode || DIM == 3) && !verylongclick) normal_reaction = true; else pushScreen(showStereo);