1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 01:00:25 +00:00

zoom_or_fov takes panini limits into account

This commit is contained in:
Zeno Rogue 2020-11-08 12:43:07 +01:00
parent d7351d169a
commit 56164ab172
5 changed files with 48 additions and 22 deletions

View File

@ -558,6 +558,12 @@ EX void initConfig() {
addsaver(anims::rug_angle, "animation rug angle");
addsaver(anims::circle_radius, "animation circle radius");
addsaver(anims::circle_spins, "animation circle spins");
addsaver(anims::rug_movement_angle, "rug forward movement angle", 90);
addsaver(anims::rug_shift_angle, "rug forward shift angle", 0);
#endif
#if CAP_RUG
addsaver(rug::move_on_touch, "rug move on touch");
#endif
#if CAP_CRYSTAL

View File

@ -306,9 +306,11 @@ transmatrix zforward_push(ld z) {
EX void zoom_or_fov(ld t) {
if(in_perspective_v()) {
vid.fov *= 180 / max_fov_angle();
auto tanfov = tan(vid.fov * degree / 2);
tanfov *= t;
vid.fov = atan(tanfov) * 2 / degree;
vid.fov *= max_fov_angle() / 180;
}
else
vpconf.scale *= t;

View File

@ -350,9 +350,9 @@ EX void mobile_draw(MOBPAR_FORMAL) {
}
}
#if CAP_RUG
if(andmode == 1 && normal_reaction && rug::rugged && clicked)
rug::finger_on(2, (ticks - lticks_rug) / 2500.);
#if CAP_RUG && CAP_ANIMATIONS
if(andmode == 1 && normal_reaction && rug::rugged && clicked && rug::move_on_touch)
anims::animate_rug_movement(rug::move_on_touch * (ticks - lticks_rug) / 2500.);
#endif
lticks_rug = ticks;

18
rug.cpp
View File

@ -123,7 +123,6 @@ EX int renderlate = 0;
EX bool rendernogl = false;
EX int texturesize = 1024;
EX ld scale = 1;
EX ld ruggo = 0;
EX ld anticusp_factor = 1;
EX ld anticusp_dist;
@ -1272,7 +1271,7 @@ EX void finger_on(int coord, ld val) {
transmatrix last_orientation;
EX ld ruggospeed = 1;
EX ld move_on_touch = 1;
EX void actDraw() {
try {
@ -1291,8 +1290,6 @@ EX void actDraw() {
double alpha = (ticks - lastticks) / 1000.0;
lastticks = ticks;
// if(ruggo) move_forward(ruggo * alpha);
#if CAP_HOLDKEYS
Uint8 *keystate = SDL_GetKeyState(NULL);
if(keystate[SDLK_LALT]) alpha /= 10;
@ -1496,7 +1493,9 @@ EX void show() {
if(rug::rugged)
dialog::lastItem().value += " (" + fts(err_zero_current) + ")";
}
dialog::addSelItem(XLAT("automatic move speed"), fts(ruggo), 'G');
#if ISMOBILE
dialog::addSelItem(XLAT("move on touch"), fts(move_on_touch), 'G');
#endif
dialog::addSelItem(XLAT("anti-crossing"), fts(anticusp_factor), 'A');
dialog::addBoolItem(XLAT("3D monsters/walls on the surface"), spatial_rug, 'S');
dialog::add_action([] () { spatial_rug = !spatial_rug; });
@ -1539,9 +1538,8 @@ EX void show() {
else if(uni == 'o')
renderonce = !renderonce;
else if(uni == 'G') {
dialog::editNumber(ruggo, -1, 1, .1, 0, XLAT("automatic move speed"),
XLAT("Move automatically without pressing any keys.")
);
dialog::editNumber(move_on_touch, -1, 1, .1, 0, XLAT("move on touch"), "");
dialog::extra_options = anims::rug_angle_options;
}
else if(uni == 'A') {
dialog::editNumber(anticusp_factor, 0, 1.5, .1, 0, XLAT("anti-crossing"),
@ -1787,10 +1785,6 @@ int rugArgs() {
shift_arg_formula(lwidth);
}
else if(argis("-rugauto")) {
shift_arg_formula(ruggo);
}
else if(argis("-rugorth")) {
rconf.model = mdEquidistant;
}

View File

@ -1085,7 +1085,7 @@ EX ld skiprope_rotation;
int lastticks, bak_turncount;
EX ld rug_rotation1, rug_rotation2, ballangle_rotation, env_ocean, env_volcano;
EX ld rug_rotation1, rug_rotation2, rug_forward, ballangle_rotation, env_ocean, env_volcano, rug_movement_angle, rug_shift_angle;
EX bool env_shmup;
EX ld rug_angle;
@ -1180,6 +1180,13 @@ bool clearup;
EX purehookset hooks_anim;
EX void animate_rug_movement(ld t) {
rug::using_rugview urv;
shift_view(
cspin(0, GDIM-1, rug_movement_angle * degree) * spin(rug_shift_angle * degree) * xtangent(t)
);
}
EX void apply() {
int t = ticks - lastticks;
lastticks = ticks;
@ -1283,6 +1290,8 @@ EX void apply() {
if(rug_rotation2) {
rug::rugView = rug::rugView * cspin(0, 1, rug_rotation2 * 2 * M_PI * t / period);
}
if(rug_forward)
animate_rug_movement(rug_forward * t / period);
}
#endif
pconf.skiprope += skiprope_rotation * t * 2 * M_PI / period;
@ -1451,6 +1460,19 @@ void list_animated_parameters() {
ld animation_period;
EX void rug_angle_options() {
dialog::addSelItem(XLAT("shift"), fts(rug_shift_angle) + "°", 'C');
dialog::add_action([] () {
popScreen();
dialog::editNumber(rug_shift_angle, 0, 90, 15, 0, XLAT("shift"), "");
});
dialog::addSelItem(XLAT("movement angle"), fts(rug_movement_angle) + "°", 'M');
dialog::add_action([] () {
popScreen();
dialog::editNumber(rug_movement_angle, 0, 360, 15, 0, XLAT("movement angle"), "");
});
}
EX void show() {
cmode = sm::SIDE; needs_highqual = false;
animation_lcm = 1;
@ -1609,14 +1631,16 @@ EX void show() {
}
else dialog::addBreak(100);
animator(XLAT("model-relative rotation"), rug_rotation2, 'r');
animator(XLAT("automatic move speed"), rug::ruggo, 'M');
animator(XLAT("automatic move speed"), rug_forward, 'M');
dialog::add_action([] () {
dialog::editNumber(rug::ruggo, 0, 10, 1, 1, XLAT("automatic move speed"), XLAT("Move automatically without pressing any keys."));
if(among(rug::gwhere, gSphere, gElliptic))
dialog::extra_options = [] () {
dialog::editNumber(rug_forward, 0, 10, 1, 1, XLAT("automatic move speed"), XLAT("Move automatically without pressing any keys."));
dialog::extra_options = [] () {
if(among(rug::gwhere, gSphere, gElliptic)) {
dialog::addItem(XLAT("synchronize"), 'S');
dialog::add_action([] () { rug::ruggo = 2 * M_PI * 1000 / period; popScreen(); });
};
dialog::add_action([] () { rug_forward = 2 * M_PI; popScreen(); });
}
rug_angle_options();
};
});
}
#endif