1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

fixed centering in racing

This commit is contained in:
Zeno Rogue 2019-05-11 23:55:02 +02:00
parent 0c3b26c997
commit d994c92ab6
3 changed files with 26 additions and 14 deletions

View File

@ -19,7 +19,8 @@ int detaillevel = 0;
bool first_cell_to_draw = true; bool first_cell_to_draw = true;
bool hide_player() { bool hide_player() {
return DIM == 3 && playermoved && vid.yshift == 0 && vid.sspeed > -5 && pmodel == mdPerspective && first_cell_to_draw && (WDIM == 3 || geom3::camera == 0) && !inmirrorcount; return DIM == 3 && playermoved && vid.yshift == 0 && vid.sspeed > -5 && pmodel == mdPerspective && first_cell_to_draw && (WDIM == 3 || geom3::camera == 0) && !inmirrorcount
&& !(racing::on && !racing::standard_centering && !racing::player_relative);
} }
hookset<bool(int sym, int uni)> *hooks_handleKey; hookset<bool(int sym, int uni)> *hooks_handleKey;

View File

@ -1090,6 +1090,10 @@ void centerpc(ld aspd) {
if(geometry == gCrystal) if(geometry == gCrystal)
crystal::centerrug(aspd); crystal::centerrug(aspd);
#endif #endif
#if CAP_RACING
if(racing::on && racing::set_view()) return;
#endif
#if MAXMDIM >= 4 #if MAXMDIM >= 4
if(shmup::on && vid.sspeed > -5 && DIM == 3) { if(shmup::on && vid.sspeed > -5 && DIM == 3) {

View File

@ -651,7 +651,7 @@ bool inrec = false;
ld race_angle = 90; ld race_angle = 90;
void set_view() { bool set_view() {
multi::cpid = subscreens::in ? subscreens::current_player : 0; multi::cpid = subscreens::in ? subscreens::current_player : 0;
@ -672,12 +672,13 @@ void set_view() {
}); });
} }
if(DIM == 3) return; if(standard_centering) return false;
transmatrix at = ypush(-vid.yshift) * ggmatrix(who->base) * who->at; transmatrix at = ypush(-vid.yshift) * ggmatrix(who->base) * who->at;
if(racing::player_relative || quotient) if(racing::player_relative || quotient) {
View = spin(race_angle * degree) * inverse(at) * View; View = inverse(at) * View;
}
else { else {
int z = get_info(who->base).completion; int z = get_info(who->base).completion;
int steps = euclid ? 1000 : 20; int steps = euclid ? 1000 : 20;
@ -687,13 +688,17 @@ void set_view() {
transmatrix T2 = ypush(-vid.yshift) * ggmatrix(c2); transmatrix T2 = ypush(-vid.yshift) * ggmatrix(c2);
transmatrix T = spintox(inverse(T1) * T2 * C0); transmatrix T = spintox(inverse(T1) * T2 * C0);
hyperpoint h = T * inverse(T1) * at * C0; hyperpoint h = T * inverse(T1) * at * C0;
ld y = asin_auto(h[1]); ld y = GDIM == 2 ? asin_auto(h[1]) : asin_auto(hypot(h[1], h[2]));
ld x = asin_auto(h[0] / cos_auto(y)); ld x = asin_auto(h[0] / cos_auto(y));
x += race_advance; x += race_advance;
// printf("%d %lf\n", z, x); // printf("%d %lf\n", z, x);
transmatrix Z = T1 * inverse(T) * xpush(x); transmatrix Z = T1 * inverse(T) * xpush(x);
View = spin(race_angle * degree) * inverse(Z) * View; View = inverse(Z) * View;
} }
if(GDIM == 3 && WDIM == 2)
View = cspin(0, 1, M_PI) * cspin(2, 1, M_PI/2 + shmup::playerturny[multi::cpid]) * spin(-M_PI/2) * View;
else View = spin(race_angle * degree) * View;
return true;
} }
#if CAP_COMMANDLINE #if CAP_COMMANDLINE
@ -928,7 +933,7 @@ void race_projection() {
vid.smart_range_detail = 3; vid.smart_range_detail = 3;
}); });
if(pmodel == mdDisk) { if(true) {
dialog::addSelItem(XLAT("point of view"), XLAT(player_relative ? "player" : "track"), 'p'); dialog::addSelItem(XLAT("point of view"), XLAT(player_relative ? "player" : "track"), 'p');
if(quotient || racing::standard_centering) if(quotient || racing::standard_centering)
dialog::lastItem().value = XLAT("N/A"); dialog::lastItem().value = XLAT("N/A");
@ -942,12 +947,14 @@ void race_projection() {
} }
else dialog::addBreak(100); else dialog::addBreak(100);
dialog::addSelItem(XLAT("race angle"), fts(race_angle), 'a'); if(DIM == 2) {
dialog::add_action([] () { dialog::addSelItem(XLAT("race angle"), fts(race_angle), 'a');
dialog::editNumber(race_angle, 0, 360, 15, 90, XLAT("race angle"), ""); dialog::add_action([] () {
int q = conformal::model_orientation - race_angle; dialog::editNumber(race_angle, 0, 360, 15, 90, XLAT("race angle"), "");
dialog::reaction = [q] () { conformal::model_orientation = race_angle + q; }; int q = conformal::model_orientation - race_angle;
}); dialog::reaction = [q] () { conformal::model_orientation = race_angle + q; };
});
}
dialog::addSelItem(XLAT("show more in front"), fts(race_advance), 'A'); dialog::addSelItem(XLAT("show more in front"), fts(race_advance), 'A');
dialog::add_action([] () { dialog::add_action([] () {