camera rotation by device orientation in 3D

This commit is contained in:
Zeno Rogue 2019-06-28 09:56:39 +02:00
parent 93813f4cf1
commit 4a65e11c1d
3 changed files with 33 additions and 2 deletions

View File

@ -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) {

View File

@ -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])

View File

@ -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);