diff --git a/basegraph.cpp b/basegraph.cpp index d75df159..bdc700a7 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -193,9 +193,9 @@ void eyewidth_translate(int ed) { glhr::glmatrix model_orientation_gl() { glhr::glmatrix s = glhr::id; for(int a=0; axsize/current_display->radius/2, -cd->ysize/current_display->radius/2, 1); - using conformal::clip_max; - using conformal::clip_min; + using models::clip_max; + using models::clip_min; M[2][2] = 2 / (clip_max - clip_min); M[3][2] = (clip_min + clip_max) / (clip_max - clip_min); glhr::projection_multiply(M); @@ -382,7 +382,7 @@ void display_data::set_projection(int ed) { glhr::projection_multiply(model_orientation_gl()); glhr::projection_multiply(glhr::translate(0, 1, 0)); glhr::projection_multiply(glhr::scale(-1, 1, 1)); - glhr::projection_multiply(glhr::scale(conformal::halfplane_scale, conformal::halfplane_scale, DIM == 3 ? conformal::halfplane_scale : 1)); + glhr::projection_multiply(glhr::scale(models::halfplane_scale, models::halfplane_scale, DIM == 3 ? models::halfplane_scale : 1)); glhr::projection_multiply(glhr::translate(0, 0.5, 0)); } } diff --git a/classes.cpp b/classes.cpp index 30bd1b38..579e224e 100644 --- a/classes.cpp +++ b/classes.cpp @@ -574,7 +574,7 @@ vector ginf = { #define X3(x) x, x, x -const modelinfo models[int(mdPolynomial)+1] = { +const modelinfo mdinf[int(mdPolynomial)+1] = { {"disk/Gans", "general perspective", "general perspective", mf::azimuthal | mf::conformal}, {"half-plane", "inversion", "half-plane", mf::conformal}, {"band", "band", "Mercator", mf::band | mf::conformal}, diff --git a/classes.h b/classes.h index 5e0fd24f..ba3706f5 100644 --- a/classes.h +++ b/classes.h @@ -306,6 +306,6 @@ struct modelinfo { const char* name; }; -extern const modelinfo models[int(mdPolynomial)+1]; +extern const modelinfo mdinf[int(mdPolynomial)+1]; } diff --git a/compileunits.h b/compileunits.h index 63e7b889..c6cfbbd6 100644 --- a/compileunits.h +++ b/compileunits.h @@ -98,7 +98,8 @@ namespace hr { namespace inv { bool on, activating; } } #include "racing.cpp" #endif -#include "conformal.cpp" +#include "models.cpp" +#include "history.cpp" #include "rug.cpp" #include "control.cpp" #include "hud.cpp" diff --git a/complex.cpp b/complex.cpp index b379af8a..08d63465 100644 --- a/complex.cpp +++ b/complex.cpp @@ -2472,7 +2472,7 @@ namespace dragon { c = c->move(i); goto findhead; } if(cmode & sm::MAP) return c; - if(!conformal::includeHistory) { + if(!history::includeHistory) { printf("dragon bug #3 (%p -> %p)\n", cor, c); dragbugs = true; } @@ -2543,7 +2543,7 @@ namespace dragon { int maxlen = 1000; while(maxlen-->0) { if(!isDragon(c->monst)) { - if(!conformal::includeHistory) printf("dragon bug #4\n"); + if(!history::includeHistory) printf("dragon bug #4\n"); return total; } total += c->hitpoints; @@ -2583,7 +2583,7 @@ namespace dragon { if(c->mondir == NODIR) { printf("dragon bug\n"); break; } c = c->move(c->mondir); if(!c) { - if(!conformal::includeHistory) printf("dragon bug #2\n"); + if(!history::includeHistory) printf("dragon bug #2\n"); break; } } diff --git a/config.cpp b/config.cpp index 9270618b..43aaff8e 100644 --- a/config.cpp +++ b/config.cpp @@ -241,9 +241,9 @@ EX void initConfig() { addsaver(polygonal::SI, "polygon sides"); addsaver(polygonal::STAR, "polygon star factor"); addsaver(polygonal::deg, "polygonal degree"); - addsaver(conformal::autobandhistory, "include history"); // check! - addsaver(conformal::lvspeed, "lineview speed"); - addsaver(conformal::extra_line_steps, "lineview extension"); + addsaver(history::autobandhistory, "include history"); // check! + addsaver(history::lvspeed, "lineview speed"); + addsaver(history::extra_line_steps, "lineview extension"); addsaver(polygonal::maxcoef, "polynomial degree"); for(int i=0; i params = { {"rug_model_distance", rug::model_distance}, #endif {"star", polygonal::STAR}, - {"lvspeed", conformal::lvspeed}, - {"rotation", conformal::rotation}, - {"mori", conformal::model_orientation}, - {"mori_yz", conformal::model_orientation_yz}, - {"clipmin", conformal::clip_min}, - {"clipmax", conformal::clip_max}, - {"topz", conformal::top_z}, - {"mtrans", conformal::model_transition}, - {"hp", conformal::halfplane_scale}, + {"lvspeed", history::lvspeed}, + {"rotation", models::rotation}, + {"mori", models::model_orientation}, + {"mori_yz", models::model_orientation_yz}, + {"clipmin", models::clip_min}, + {"clipmax", models::clip_max}, + {"topz", models::top_z}, + {"mtrans", models::model_transition}, + {"hp", models::halfplane_scale}, {"back", backbrightness}, {"ipd", vid.ipd}, {"lr", vid.lr_eyewidth}, @@ -2268,9 +2268,9 @@ EX unordered_map params = { {"b", anims::b}, #endif {"mobius", vid.skiprope}, - {"sang", conformal::spiral_angle}, - {"spiralx", conformal::spiral_x}, - {"spiraly", conformal::spiral_y}, + {"sang", models::spiral_angle}, + {"spiralx", models::spiral_x}, + {"spiraly", models::spiral_y}, #if CAP_CRYSTAL {"cprob", crystal::compass_probability}, #endif diff --git a/control.cpp b/control.cpp index 17ccbed3..283a476d 100644 --- a/control.cpp +++ b/control.cpp @@ -296,32 +296,32 @@ EX void handlePanning(int sym, int uni) { View = solmul(cpush(2, +0.2*shiftmul), View), didsomething = true, playermoved = false; } if(sym == SDLK_RIGHT) { - if(conformal::on) - conformal::lvspeed += 0.1 * shiftmul; + if(history::on) + history::lvspeed += 0.1 * shiftmul; else if(DIM == 3) View = cspin(0, 2, -0.2*shiftmul) * View, didsomething = true; else View = xpush(-0.2*shiftmul) * View, playermoved = false, didsomething = true; } if(sym == SDLK_LEFT) { - if(conformal::on) - conformal::lvspeed -= 0.1 * shiftmul; + if(history::on) + history::lvspeed -= 0.1 * shiftmul; else if(DIM == 3) View = cspin(0, 2, 0.2*shiftmul) * View, didsomething = true; else View = xpush(+0.2*shiftmul) * View, playermoved = false, didsomething = true; } if(sym == SDLK_UP) { - if(conformal::on) - conformal::lvspeed += 0.1 * shiftmul; + if(history::on) + history::lvspeed += 0.1 * shiftmul; else if(DIM == 3) View = cspin(1, 2, 0.2*shiftmul) * View, didsomething = true; else View = ypush(+0.2*shiftmul) * View, playermoved = false, didsomething = true; } if(sym == SDLK_DOWN) { - if(conformal::on) - conformal::lvspeed -= 0.1 * shiftmul; + if(history::on) + history::lvspeed -= 0.1 * shiftmul; else if(DIM == 3) View = cspin(1, 2, -0.2*shiftmul) * View, didsomething = true; else @@ -329,14 +329,14 @@ EX void handlePanning(int sym, int uni) { } #endif if(sym == SDLK_PAGEUP) { - if(conformal::on) - conformal::rotation++; + if(history::on) + models::rotation++; else View = spin(M_PI/cgi.S21/2*shiftmul) * View, didsomething = true; } if(sym == SDLK_PAGEDOWN) { - if(conformal::on) - conformal::rotation++; + if(history::on) + models::rotation++; else View = spin(-M_PI/cgi.S21/2*shiftmul) * View, didsomething = true; } @@ -563,7 +563,7 @@ EX void mainloopiter() { optimizeview(); - conformal::configure(); + models::configure(); lastt = ticks; ticks = SDL_GetTicks(); @@ -689,14 +689,14 @@ EX void mainloopiter() { if(keystate[SDLK_DOWN] && DEFAULTNOR(SDLK_DOWN)) View = (DIM == 2 ? ypush(-t) : cspin(1, 2, -t)) * View, didsomething = true, playermoved = playermoved && DIM == 3; if(keystate[SDLK_PAGEUP] && DEFAULTNOR(SDLK_PAGEUP)) { - if(conformal::on) - conformal::rotation+=t; + if(history::on) + models::rotation+=t; else View = spin(t) * View, didsomething = true; } if(keystate[SDLK_PAGEDOWN] && DEFAULTNOR(SDLK_PAGEDOWN)) { - if(conformal::on) - conformal::rotation-=t; + if(history::on) + models::rotation-=t; else View = spin(-t) * View, didsomething = true; } diff --git a/drawing.cpp b/drawing.cpp index f397a7f3..f300ec1e 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -177,7 +177,7 @@ EX bool two_sided_model() { if(pmodel == mdDisk) return sphere; if(pmodel == mdHemisphere) return true; if(pmodel == mdRotatedHyperboles) return true; - if(pmodel == mdSpiral && conformal::spiral_cone < 360) return true; + if(pmodel == mdSpiral && models::spiral_cone < 360) return true; return false; } @@ -190,15 +190,15 @@ EX int get_side(const hyperpoint& H) { if(pmodel == mdRotatedHyperboles) return H[1] > 0 ? -1 : 1; if(pmodel == mdHyperboloid && hyperbolic) - return (conformal::sin_ball * H[2] > -conformal::cos_ball * H[1]) ? -1 : 1; + return (models::sin_ball * H[2] > -models::cos_ball * H[1]) ? -1 : 1; if(pmodel == mdHyperboloid && sphere) - return (conformal::sin_ball * H[2] > conformal::cos_ball * H[1]) ? -1 : 1; + return (models::sin_ball * H[2] > models::cos_ball * H[1]) ? -1 : 1; if(pmodel == mdHemisphere) { hyperpoint res; applymodel(H, res); return res[2] < 0 ? -1 : 1; } - if(pmodel == mdSpiral && conformal::spiral_cone < 360) { + if(pmodel == mdSpiral && models::spiral_cone < 360) { return cone_side(H); } return 0; @@ -278,7 +278,7 @@ void addpoint(const hyperpoint& H) { else { Hscr[0] *= z; Hscr[1] *= z * vid.stretch; - Hscr[2] = 1 - 2 * (-Hscr[2] - conformal::clip_min) / (conformal::clip_max - conformal::clip_min); + Hscr[2] = 1 - 2 * (-Hscr[2] - models::clip_min) / (models::clip_max - models::clip_min); } add1(Hscr); } @@ -453,11 +453,11 @@ void glapplymatrix(const transmatrix& V) { if(vid.stretch != 1) mat[1] *= vid.stretch, mat[5] *= vid.stretch, mat[9] *= vid.stretch, mat[13] *= vid.stretch; - if(conformal::model_has_orientation()) { + if(models::model_has_orientation()) { if(DIM == 3) for(int a=0; a<4; a++) - conformal::apply_orientation_yz(mat[a*4+1], mat[a*4+2]); + models::apply_orientation_yz(mat[a*4+1], mat[a*4+2]); for(int a=0; a<4; a++) - conformal::apply_orientation(mat[a*4], mat[a*4+1]); + models::apply_orientation(mat[a*4], mat[a*4+1]); } glhr::set_modelview(glhr::as_glmatrix(mat)); @@ -633,9 +633,9 @@ void fixMercator(bool tinf) { else mercator_period = 2 * current_display->radius; - if(!conformal::model_straight) + if(!models::model_straight) for(auto& g: glcoords) - conformal::apply_orientation(g[0], g[1]); + models::apply_orientation(g[0], g[1]); if(pmodel == mdSinusoidal) for(int i = 0; iradius / vid.stretch * M_PI); - if(!conformal::model_straight) + if(!models::model_straight) for(auto& g: glcoords) - conformal::apply_orientation(g[1], g[0]); + models::apply_orientation(g[1], g[0]); } else { if(tinf) { @@ -733,9 +733,9 @@ void fixMercator(bool tinf) { auto& v = glcoords[isize(glcoords)-u][1-mercator_coord]; v = v < 0 ? dmin : dmax; } - if(!conformal::model_straight) + if(!models::model_straight) for(auto& g: glcoords) - conformal::apply_orientation(g[1], g[0]); + models::apply_orientation(g[1], g[0]); /* printf("cycling %d -> %d\n", base, qglcoords); for(int a=0; a 0) continue; ld c1 = ah1[1], c2 = -ah2[1]; if(c1 < 0) c1 = -c1, c2 = -c2; @@ -1034,11 +1034,11 @@ void dqi_poly::draw() { for(int i=0; iradius * cos(y / current_display->radius / vid.stretch * M_PI); } - glcoords[i][mercator_coord] += conformal::ocos * mercator_period * (l - lastl); - glcoords[i][1-mercator_coord] += conformal::osin * mercator_period * (l - lastl); + glcoords[i][mercator_coord] += models::ocos * mercator_period * (l - lastl); + glcoords[i][1-mercator_coord] += models::osin * mercator_period * (l - lastl); } lastl = l; } diff --git a/game.cpp b/game.cpp index dd9676fb..13ece957 100644 --- a/game.cpp +++ b/game.cpp @@ -2144,7 +2144,7 @@ EX void killMonster(cell *c, eMonster who, flagtype deathflags IS(0)) { #ifdef HASLINEVIEW if(!isBug(m) && !isAnyIvy(m)) { - conformal::killhistory.push_back(make_pair(c,m)); + history::killhistory.push_back(make_pair(c,m)); } #endif @@ -7289,7 +7289,7 @@ EX bool collectItem(cell *c2, bool telekinesis IS(false)) { #ifdef HASLINEVIEW // temporary variable to avoid the "cannot bind bitfield" problem in C++11 eItem dummy = c2->item; - conformal::findhistory.emplace_back(c2, dummy); + history::findhistory.emplace_back(c2, dummy); #endif if(c2->item == itBombEgg && c2->land == laMinefield) { @@ -7779,7 +7779,7 @@ EX void monstersTurn() { #ifdef HASLINEVIEW for(int i=0; imonst == moWormtail) c->monst = moWormwait; if(c->monst == moTentacletail || c->monst == moTentacleGhost) c->monst = moTentacle; diff --git a/geom-exp.cpp b/geom-exp.cpp index ab80df4f..d754607b 100644 --- a/geom-exp.cpp +++ b/geom-exp.cpp @@ -449,7 +449,7 @@ void ge_select_tiling(const vector& lst) { string current_proj_name() { if(pmodel != mdDisk || nonisotropic) - return conformal::get_model_name(pmodel); + return models::get_model_name(pmodel); else if(hyperbolic && vid.alpha == 1) return XLAT("Poincaré model"); else if(hyperbolic && vid.alpha == 0) @@ -724,7 +724,7 @@ EX void showEuclideanMenu() { dialog::add_action_push(show3D); } dialog::addSelItem(XLAT("projection"), current_proj_name(), '1'); - dialog::add_action_push(conformal::model_menu); + dialog::add_action_push(models::model_menu); if(nonisotropic) dialog::addBoolItem_action(XLAT("geodesic movement in Sol/Nil"), nisot::geodesic_movement, 'G'); #if CAP_CRYSTAL && MAXMDIM >= 4 diff --git a/geometry.cpp b/geometry.cpp index b929b864..01dd9654 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -393,7 +393,7 @@ EX void switch_always3() { if(rug::rugged) rug::close(); if(dual::split(switch_fpp)) return; check_cgi(); cgi.require_basics(); - View = inverse(conformal::rotmatrix()) * View; + View = inverse(models::rotmatrix()) * View; if(!vid.always3) { vid.always3 = true; ld ms = min(cgi.scalefactor, 1); @@ -425,7 +425,7 @@ EX void switch_always3() { swapmatrix(View); callhooks(hooks_swapdim); } - View = conformal::rotmatrix() * View; + View = models::rotmatrix() * View; #endif } diff --git a/graph.cpp b/graph.cpp index da3f3ff3..8c2a29cd 100644 --- a/graph.cpp +++ b/graph.cpp @@ -865,7 +865,7 @@ EX bool drawItemType(eItem it, cell *c, const transmatrix& V, color_t icol, int if(DIM == 3 && c && it != itBabyTortoise) Vit = face_the_player(Vit); // V * cspin(0, 2, ptick(618, 0)); - if(c && conformal::includeHistory && conformal::infindhistory.count(c)) poly_outline = OUTLINE_DEAD; + if(c && history::includeHistory && history::infindhistory.count(c)) poly_outline = OUTLINE_DEAD; if(!mmitem && it) return true; @@ -2399,7 +2399,7 @@ EX bool dont_face_pc = false; bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col, bool mirrored, color_t asciicol) { #if CAP_SHAPES - bool darkhistory = conformal::includeHistory && conformal::inkillhistory.count(c); + bool darkhistory = history::includeHistory && history::inkillhistory.count(c); if(doHighlight()) poly_outline = @@ -2481,7 +2481,7 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col, bool m } else { if(c->monst == moTentacleGhost) { - hyperpoint V0 = conformal::on ? tC0(Vs) : inverse(cwtV) * tC0(Vs); + hyperpoint V0 = history::on ? tC0(Vs) : inverse(cwtV) * tC0(Vs); hyperpoint V1 = spintox(V0) * V0; Vs = cwtV * rspintox(V0) * rpushxto0(V1) * pispin; drawMonsterType(moGhost, c, Vs, col, footphase, asciicol); @@ -2734,7 +2734,7 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col, bool m // golems, knights, and hyperbugs don't face the player (mondir-controlled) // also whatever in the lineview mode, and whatever in the quotient geometry - else if((hasFacing(c) && c->mondir != NODIR) || conformal::on || quotient || euwrap || dont_face_pc) { + else if((hasFacing(c) && c->mondir != NODIR) || history::on || quotient || euwrap || dont_face_pc) { if(c->monst == moKrakenH) Vs = Vb, nospins = nospinb; if(!nospins && c->mondir < c->type) Vs = Vs * ddspin(c, c->mondir, M_PI); if(c->monst == moPair) Vs = Vs * xpush(-.12); @@ -2818,7 +2818,7 @@ array,AURA+1> aurac; EX bool haveaura() { if(!(vid.aurastr>0 && !svg::in && (auraNOGL || vid.usingGL))) return false; if(sphere && mdAzimuthalEqui()) return true; - if(among(pmodel, mdJoukowsky, mdJoukowskyInverted) && hyperbolic && conformal::model_transition < 1) + if(among(pmodel, mdJoukowsky, mdJoukowskyInverted) && hyperbolic && models::model_transition < 1) return true; return pmodel == mdDisk && (!sphere || vid.alpha > 10) && !euclid; } @@ -2836,7 +2836,7 @@ EX void clearaura() { } void apply_joukowsky_aura(hyperpoint& h) { - bool joukowsky = among(pmodel, mdJoukowskyInverted, mdJoukowsky) && hyperbolic && conformal::model_transition < 1; + bool joukowsky = among(pmodel, mdJoukowskyInverted, mdJoukowsky) && hyperbolic && models::model_transition < 1; if(joukowsky) { hyperpoint ret; applymodel(h, ret); @@ -2958,7 +2958,7 @@ void drawaura() { cmul[1] = cmul[0]; bool inversion = vid.alpha <= -1 || pmodel == mdJoukowsky; - bool joukowsky = among(pmodel, mdJoukowskyInverted, mdJoukowsky) && hyperbolic && conformal::model_transition < 1; + bool joukowsky = among(pmodel, mdJoukowskyInverted, mdJoukowsky) && hyperbolic && models::model_transition < 1; for(int r=0; r<=AURA; r++) for(int z=0; z<11; z++) { float rr = (M_PI * 2 * r) / AURA; @@ -2970,11 +2970,11 @@ void drawaura() { if(joukowsky) { ld c1 = c, s1 = s; if(inversion) - conformal::apply_orientation(s1, c1); + models::apply_orientation(s1, c1); else - conformal::apply_orientation(c1, s1); + models::apply_orientation(c1, s1); - ld& mt = conformal::model_transition; + ld& mt = models::model_transition; ld mt2 = 1 - mt; ld m = sqrt(c1*c1 + s1*s1 / mt2 / mt2); @@ -3743,7 +3743,7 @@ void setcolors(cell *c, color_t& wcol, color_t& fcol) { } case waFloorA: case waFloorB: // isAlch - if(c->item && !(conformal::includeHistory && conformal::infindhistory.count(c))) + if(c->item && !(history::includeHistory && history::infindhistory.count(c))) fcol = wcol = iinf[c->item].color; else fcol = wcol; @@ -5086,7 +5086,7 @@ EX void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { viewBuggyCells(c,V); #endif - if(conformal::on || inHighQual || WDIM == 3 || sightrange_bonus > gamerange_bonus) checkTide(c); + if(history::on || inHighQual || WDIM == 3 || sightrange_bonus > gamerange_bonus) checkTide(c); // save the player's view center if(isPlayerOn(c) && !shmup::on) { @@ -5252,7 +5252,7 @@ EX void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { bool hidden = itemHidden(c); bool hiddens = itemHiddenFromSight(c); - if(conformal::includeHistory && conformal::infindhistory.count(c)) { + if(history::includeHistory && history::infindhistory.count(c)) { hidden = true; hiddens = false; } @@ -5956,7 +5956,7 @@ EX void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { queuepoly((*Vdp), cgi.shHeptaMarker, wmblack ? 0x80808080 : 0x00000080); } - if(conformal::includeHistory && conformal::inmovehistory.count(c)) + if(history::includeHistory && history::inmovehistory.count(c)) queuepoly((*Vdp), cgi.shHeptaMarker, 0x000000C0); char xch = winf[c->wall].glyph; @@ -6620,7 +6620,7 @@ EX void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { if(0); #if CAP_BT - else if(binarytiling && conformal::do_rotate >= 2) { + else if(binarytiling && models::do_rotate >= 2) { if(!straightDownSeek || c->master->distance < straightDownSeek->master->distance) { usethis = true; spd = 1; @@ -6631,7 +6631,7 @@ EX void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { else if(isGravityLand(cwt.at->land) && cwt.at->land != laMountain) { if(cwt.at->land == laDungeon) side = 2; if(cwt.at->land == laWestWall) side = 1; - if(conformal::do_rotate >= 1) + if(models::do_rotate >= 1) if(!straightDownSeek || edgeDepth(c) < edgeDepth(straightDownSeek)) { usethis = true; spd = cwt.at->landparam / 10.; @@ -6639,8 +6639,8 @@ EX void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { } else if(c->master->alt && cwt.at->master->alt && - ((cwt.at->land == laMountain && conformal::do_rotate >= 1)|| - (conformal::do_rotate >= 2 && + ((cwt.at->land == laMountain && models::do_rotate >= 1)|| + (models::do_rotate >= 2 && (cwt.at->land == laTemple || cwt.at->land == laWhirlpool || (cheater && (cwt.at->land == laClearing || cwt.at->land == laCaribbean || cwt.at->land == laCamelot || cwt.at->land == laPalace))) @@ -6653,7 +6653,7 @@ EX void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { } } - else if(conformal::do_rotate >= 2 && cwt.at->land == laOcean && cwt.at->landparam < 25) { + else if(models::do_rotate >= 2 && cwt.at->land == laOcean && cwt.at->landparam < 25) { if(!straightDownSeek || coastval(c, laOcean) < coastval(straightDownSeek, laOcean)) { usethis = true; spd = cwt.at->landparam / 10; @@ -7500,9 +7500,9 @@ EX void drawfullmap() { /* - if(conformal::on) { + if(models::on) { char ch = 'A'; - for(auto& v: conformal::v) { + for(auto& v: history::v) { queuepoly(ggmatrix(v->base) * v->at, cgi.shTriangle, 0x306090C0); queuechr(ggmatrix(v->base) * v->at * C0, 10, ch++, 0xFF0000); } @@ -7587,7 +7587,7 @@ EX void gamescreen(int _darken) { darken = _darken; - if(conformal::includeHistory) conformal::restore(); + if(history::includeHistory) history::restore(); anims::apply(); #if CAP_RUG @@ -7598,7 +7598,7 @@ EX void gamescreen(int _darken) { wrap_drawfullmap(); anims::rollback(); - if(conformal::includeHistory) conformal::restoreBack(); + if(history::includeHistory) history::restoreBack(); poly_outline = OUTLINE_DEFAULT; diff --git a/hypgraph.cpp b/hypgraph.cpp index f0c11d16..0e19e355 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -109,7 +109,7 @@ void ballmodel(hyperpoint& ret, double alpha, double d, double zl) { ret[1] = ay; ret[2] = ax * sa; - conformal::apply_ball(ret[2], ret[1]); + models::apply_ball(ret[2], ret[1]); } void apply_depth(hyperpoint &f, ld z) { @@ -189,8 +189,8 @@ void move_y_to_z(hyperpoint& H, pair coef) { template void makeband(hyperpoint H, hyperpoint& ret, const T& f) { ld zlev = find_zlev(H); - conformal::apply_orientation_yz(H[1], H[2]); - conformal::apply_orientation(H[0], H[1]); + models::apply_orientation_yz(H[1], H[2]); + models::apply_orientation(H[0], H[1]); auto r = move_z_to_y(H); ld x, y, yf, zf=0; @@ -208,8 +208,8 @@ template void makeband(hyperpoint H, hyperpoint& ret, const T& f) { ld yzf = y * zf; y *= yf; ret = hpxyz(x / M_PI, y / M_PI, 0); move_y_to_z(ret, r); - conformal::apply_orientation(ret[1], ret[0]); - conformal::apply_orientation_yz(ret[2], ret[1]); + models::apply_orientation(ret[1], ret[0]); + models::apply_orientation_yz(ret[2], ret[1]); if(zlev != 1 && current_display->stereo_active()) apply_depth(ret, yzf / M_PI); return; @@ -383,8 +383,8 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { ld zlev = find_zlev(H); H = space_to_perspective(H); - conformal::apply_orientation_yz(H[1], H[2]); - conformal::apply_orientation(H[0], H[1]); + models::apply_orientation_yz(H[1], H[2]); + models::apply_orientation(H[0], H[1]); H[1] += 1; double rad = sqhypot_d(DIM, H); @@ -393,30 +393,30 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { if(DIM == 3) { // a bit simpler when we do not care about 3D - H *= conformal::halfplane_scale; + H *= models::halfplane_scale; ret[0] = -H[0]; ret[1] = 1 + H[1]; ret[2] = H[2]; ret[3] = 1; - conformal::apply_orientation(ret[1], ret[0]); - conformal::apply_orientation_yz(ret[2], ret[1]); + models::apply_orientation(ret[1], ret[0]); + models::apply_orientation_yz(ret[2], ret[1]); break; } - conformal::apply_orientation(H[0], H[1]); + models::apply_orientation(H[0], H[1]); - H *= conformal::halfplane_scale; + H *= models::halfplane_scale; - ret[0] = -conformal::osin - H[0]; + ret[0] = -models::osin - H[0]; if(zlev != 1) { - if(abs(conformal::ocos) > 1e-5) - H[1] = H[1] * pow(zlev, conformal::ocos); - if(abs(conformal::ocos) > 1e-5 && conformal::osin) - H[1] += H[0] * conformal::osin * (pow(zlev, conformal::ocos) - 1) / conformal::ocos; - else if(conformal::osin) - H[1] += H[0] * conformal::osin * log(zlev); + if(abs(models::ocos) > 1e-5) + H[1] = H[1] * pow(zlev, models::ocos); + if(abs(models::ocos) > 1e-5 && models::osin) + H[1] += H[0] * models::osin * (pow(zlev, models::ocos) - 1) / models::ocos; + else if(models::osin) + H[1] += H[0] * models::osin * log(zlev); } - ret[1] = conformal::ocos + H[1]; + ret[1] = models::ocos + H[1]; ret[2] = DIM == 3 ? H[2] : 0; if(MAXMDIM == 4) ret[3] = 1; if(zlev != 1 && current_display->stereo_active()) @@ -457,7 +457,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { swap(ret[1], ret[2]); - conformal::apply_ball(ret[2], ret[1]); + models::apply_ball(ret[2], ret[1]); break; } @@ -466,7 +466,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { case mdHyperboloid: { if(pmodel == mdHyperboloid) { - ld& topz = conformal::top_z; + ld& topz = models::top_z; if(H[2] > topz) { ld scale = sqrt(topz*topz-1) / hypot_d(2, H); H *= scale; @@ -482,7 +482,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { ret[1] = (1 - H[2]) / 3; ret[2] = H[1] / 3; - conformal::apply_ball(ret[2], ret[1]); + models::apply_ball(ret[2], ret[1]); break; } @@ -496,8 +496,8 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { } case mdSimulatedPerspective: { - conformal::apply_orientation_yz(H[1], H[2]); - conformal::apply_orientation(H[0], H[1]); + models::apply_orientation_yz(H[1], H[2]); + models::apply_orientation(H[0], H[1]); auto yz = move_z_to_y(H); hyperpoint Hl = xpush(-vid.twopoint_param) * H; hyperpoint Hr = xpush(+vid.twopoint_param) * H; @@ -514,29 +514,29 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { ret[2] = 0; move_y_to_z(ret, yz); - conformal::apply_orientation(ret[0], ret[1]); - conformal::apply_orientation_yz(ret[2], ret[1]); + models::apply_orientation(ret[0], ret[1]); + models::apply_orientation_yz(ret[2], ret[1]); break; } case mdTwoHybrid: { - conformal::apply_orientation_yz(H[1], H[2]); - conformal::apply_orientation(H[0], H[1]); + models::apply_orientation_yz(H[1], H[2]); + models::apply_orientation(H[0], H[1]); auto yz = move_z_to_y(H); ret = compute_hybrid(H, whateveri[0]); move_y_to_z(ret, yz); - conformal::apply_orientation(ret[0], ret[1]); - conformal::apply_orientation_yz(ret[2], ret[1]); + models::apply_orientation(ret[0], ret[1]); + models::apply_orientation_yz(ret[2], ret[1]); break; } case mdJoukowsky: case mdJoukowskyInverted: { - conformal::apply_orientation_yz(H[1], H[2]); - conformal::apply_orientation(H[0], H[1]); - // with equal speed skiprope: conformal::apply_orientation(H[1], H[0]); + models::apply_orientation_yz(H[1], H[2]); + models::apply_orientation(H[0], H[1]); + // with equal speed skiprope: models::apply_orientation(H[1], H[0]); if(vid.skiprope) { static ld last_skiprope = 0; @@ -563,7 +563,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { ld r = hypot_d(2, H); ld c = H[0] / r; ld s = H[1] / r; - ld& mt = conformal::model_transition; + ld& mt = models::model_transition; ld a = 1 - .5 * mt, b = .5 * mt; swap(a, b); @@ -579,7 +579,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { ret[0] = ret[0] / r2; ret[1] = -ret[1] / r2; move_y_to_z(ret, yz); - conformal::apply_orientation(ret[1], ret[0]); + models::apply_orientation(ret[1], ret[0]); /* @@ -593,9 +593,9 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { } else { move_y_to_z(ret, yz); - conformal::apply_orientation(ret[0], ret[1]); + models::apply_orientation(ret[0], ret[1]); } - conformal::apply_orientation_yz(ret[2], ret[1]); + models::apply_orientation_yz(ret[2], ret[1]); break; } @@ -604,11 +604,11 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { H = space_to_perspective(H); - conformal::apply_orientation(H[0], H[1]); + models::apply_orientation(H[0], H[1]); pair p = polygonal::compute(H[0], H[1]); - conformal::apply_orientation(p.second, p.first); + models::apply_orientation(p.second, p.first); ret[0] = p.first; ret[1] = p.second; ret[2] = 0; @@ -616,12 +616,12 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { } case mdBand: - if(conformal::model_transition != 1) { - ld& mt = conformal::model_transition; + if(models::model_transition != 1) { + ld& mt = models::model_transition; H = space_to_perspective(H); - conformal::apply_orientation(H[0], H[1]); + models::apply_orientation(H[0], H[1]); H[0] += 1; double rad = H[0]*H[0] + H[1]*H[1]; @@ -642,7 +642,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { ret[0] /= -(1-mt) * M_PI / 2; ret[1] /= (1-mt) * M_PI / 2; - conformal::apply_orientation(ret[1], ret[0]); + models::apply_orientation(ret[1], ret[0]); } else makeband(H, ret, band_conformal); @@ -694,7 +694,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { case mdRotatedHyperboles: { // ld zlev = <- not implemented find_zlev(H); // + vid.depth; - conformal::apply_orientation(H[0], H[1]); + models::apply_orientation(H[0], H[1]); ld y = asin_auto(H[1]); ld x = asin_auto_clamp(H[0] / cos_auto(y)); @@ -706,7 +706,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { ret[1] = cosh(x) * factor; ret[2] = 0; - if(conformal::use_atan) { + if(models::use_atan) { ret[0] = atan(ret[0]); ret[1] = atan(ret[1]); } @@ -715,7 +715,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { } case mdFormula: { - dynamicval m(pmodel, conformal::basic_model); + dynamicval m(pmodel, models::basic_model); applymodel(H, ret); exp_parser ep; ep.extra_params["z"] = cld(ret[0], ret[1]); @@ -725,7 +725,7 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { ep.extra_params["ux"] = H[0]; ep.extra_params["uy"] = H[1]; ep.extra_params["uz"] = H[2]; - ep.s = conformal::formula; + ep.s = models::formula; cld res = ep.parse(); ret[0] = real(res); ret[1] = imag(res); @@ -737,18 +737,18 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) { cld z; if(hyperbolic || sphere) makeband(H, ret, band_conformal); else ret = H; - z = cld(ret[0], ret[1]) * conformal::spiral_multiplier; + z = cld(ret[0], ret[1]) * models::spiral_multiplier; - if(conformal::spiral_cone < 360) { - ld alpha = imag(z) * 360 / conformal::spiral_cone; + if(models::spiral_cone < 360) { + ld alpha = imag(z) * 360 / models::spiral_cone; ld r = real(z); r = exp(r); ret[0] = -sin(alpha) * r; ret[1] = cos(alpha) * r; - ret[2] = (r-1) * sqrt( pow(360/conformal::spiral_cone, 2) - 1); + ret[2] = (r-1) * sqrt( pow(360/models::spiral_cone, 2) - 1); - conformal::apply_ball(ret[2], ret[1]); + models::apply_ball(ret[2], ret[1]); } else { z = exp(z); @@ -923,8 +923,8 @@ EX bool in_smart_range(const transmatrix& T) { if(y > current_display->ytop + current_display->ysize * 2) return false; if(y < current_display->ytop - current_display->ysize * 1) return false; if(DIM == 3) { - if(-h1[2] < conformal::clip_min * 2 - conformal::clip_max) return false; - if(-h1[2] > conformal::clip_max * 2 - conformal::clip_min) return false; + if(-h1[2] < models::clip_min * 2 - models::clip_max) return false; + if(-h1[2] > models::clip_max * 2 - models::clip_min) return false; } ld epsilon = 0.01; @@ -941,7 +941,7 @@ EX bool in_smart_range(const transmatrix& T) { } if(DIM == 3) { - if(-h1[2] + 2 * dz < conformal::clip_min || -h1[2] - 2 * dz > conformal::clip_max) return false; + if(-h1[2] + 2 * dz < models::clip_min || -h1[2] - 2 * dz > models::clip_max) return false; sort(dh, dh+DIM); ld scale = sqrt(dh[1] * dh[2]) * cgi.scalefactor * hcrossf7; if(scale <= (WDIM == 2 ? vid.smart_range_detail : vid.smart_range_detail_3)) return false; @@ -1025,8 +1025,8 @@ bool in_multi = false; void hrmap_standard::draw() { if(sphere && pmodel == mdSpiral && !in_multi) { in_multi = true; - if(conformal::ring_not_spiral) { - int qty = ceil(1. / conformal::sphere_spiral_multiplier); + if(models::ring_not_spiral) { + int qty = ceil(1. / models::sphere_spiral_multiplier); if(qty > 100) qty = 100; for(int i=-qty; i < qty; i++) { band_shift = 2 * M_PI * i; @@ -1205,7 +1205,7 @@ EX void spinEdge(ld aspd) { aspd = 999999; if(straightDownSeek) { if(straightDownPoint[0]) - downspin = conformal::rotation * degree - atan2(straightDownPoint[0], straightDownPoint[1]); + downspin = models::rotation * degree - atan2(straightDownPoint[0], straightDownPoint[1]); } else { if(View[0][2]) @@ -1215,7 +1215,7 @@ EX void spinEdge(ld aspd) { else if(straightDownSeek) { downspin = atan2(straightDownPoint[1], straightDownPoint[0]); downspin -= M_PI/2; - downspin += conformal::rotation * degree; + downspin += models::rotation * degree; while(downspin < -M_PI) downspin += 2*M_PI; while(downspin > +M_PI) downspin -= 2*M_PI; downspin = downspin * min(straightDownSpeed, (double)1); @@ -1396,7 +1396,7 @@ void ballgeometry() { EX void resetview() { DEBBI(DF_GRAPH, ("reset view")); - View = conformal::rotmatrix(); + View = models::rotmatrix(); // EUCLIDEAN if(!masterless) viewctr.at = cwt.at->master, @@ -1417,7 +1417,7 @@ EX void panning(hyperpoint hf, hyperpoint ht) { EX int cells_drawn, cells_generated; EX void fullcenter() { - conformal::path_for_lineanimation.clear(); + history::path_for_lineanimation.clear(); if(playerfound && false) centerpc(INF); else { bfs(); @@ -1506,8 +1506,8 @@ EX void draw_model_elements() { hyperpoint H = xpush(p * vid.twopoint_param) * ypush0(h); hyperpoint res = compute_hybrid(H, 2 | mode); - conformal::apply_orientation(res[0], res[1]); - conformal::apply_orientation_yz(res[2], res[1]); + models::apply_orientation(res[0], res[1]); + models::apply_orientation_yz(res[2], res[1]); curvepoint(res * current_display->radius); } queuecurve(ringcolor, 0, PPR::CIRCLE); @@ -1518,7 +1518,7 @@ EX void draw_model_elements() { } case mdTwoPoint: case mdSimulatedPerspective: { - ld a = -conformal::model_orientation * degree; + ld a = -models::model_orientation * degree; queuechr(xspinpush0(a, +vid.twopoint_param), vid.xres / 100, 'X', ringcolor >> 8); queuechr(xspinpush0(a, -vid.twopoint_param), vid.xres / 100, 'X', ringcolor >> 8); return; @@ -1537,12 +1537,12 @@ EX void draw_model_elements() { curvepoint(point3(0,0,-vid.alpha)); queuecurve(ringcolor, 0, PPR::CIRCLE); - ld& tz = conformal::top_z; + ld& tz = models::top_z; ld z = acosh(tz); hyperpoint a = xpush0(z); - ld cb = conformal::cos_ball; - ld sb = conformal::sin_ball; + ld cb = models::cos_ball; + ld sb = models::sin_ball; a[1] = sb * a[2] / -cb; a[0] = sqrt(-1 + a[2] * a[2] - a[1] * a[1]); @@ -1639,13 +1639,13 @@ EX void draw_boundary(int w) { ld x = sin(a * vid.twopoint_param * b / 90); ld y = 0; ld z = -sqrt(1 - x*x); - conformal::apply_orientation(y, x); + models::apply_orientation(y, x); hyperpoint h1; applymodel(hpxyz(x,y,z), h1); - conformal::apply_orientation(h1[0], h1[1]); + models::apply_orientation(h1[0], h1[1]); h1[1] = abs(h1[1]) * b; - conformal::apply_orientation(h1[1], h1[0]); + models::apply_orientation(h1[1], h1[0]); curvepoint(h1); } @@ -1656,9 +1656,9 @@ EX void draw_boundary(int w) { case mdBand: case mdBandEquidistant: case mdBandEquiarea: case mdSinusoidal: { if(DIM == 3) return; - if(pmodel == mdBand && conformal::model_transition != 1) return; + if(pmodel == mdBand && models::model_transition != 1) return; bool bndband = ((pmodel == mdBand) ? hyperbolic : sphere); - transmatrix T = spin(-conformal::model_orientation * degree); + transmatrix T = spin(-models::model_orientation * degree); ld right = M_PI/2 - 1e-5; if(bndband) queuestraight(T * ypush0(hyperbolic ? 10 : right), 2, lc, fc, p); @@ -1682,7 +1682,7 @@ EX void draw_boundary(int w) { case mdHalfplane: if(hyperbolic && DIM == 2) { - queuestraight(xspinpush0(-conformal::model_orientation * degree - M_PI/2, fakeinf), 1, lc, fc, p); + queuestraight(xspinpush0(-models::model_orientation * degree - M_PI/2, fakeinf), 1, lc, fc, p); return; } break; @@ -1692,7 +1692,7 @@ EX void draw_boundary(int w) { queuereset(mdUnchanged, p); for(int i=0; i<=360; i++) { ld s = sin(i * degree); - curvepoint(point3(current_display->radius * cos(i * degree), current_display->radius * s * (conformal::cos_ball * s >= 0 - 1e-6 ? 1 : abs(conformal::sin_ball)), 0)); + curvepoint(point3(current_display->radius * cos(i * degree), current_display->radius * s * (models::cos_ball * s >= 0 - 1e-6 ? 1 : abs(models::sin_ball)), 0)); } queuecurve(lc, fc, p); queuereset(pmodel, p); @@ -1701,7 +1701,7 @@ EX void draw_boundary(int w) { for(int i=0; i<=360; i++) { ld s = sin(i * degree); - curvepoint(point3(current_display->radius * cos(i * degree), current_display->radius * s * conformal::sin_ball, 0)); + curvepoint(point3(current_display->radius * cos(i * degree), current_display->radius * s * models::sin_ball, 0)); } queuecurve(lc, fc, p); queuereset(pmodel, p); @@ -1719,10 +1719,10 @@ EX void draw_boundary(int w) { case mdHyperboloid: { if(hyperbolic) { - ld& tz = conformal::top_z; + ld& tz = models::top_z; ld mz = acosh(tz); - ld cb = conformal::cos_ball; - ld sb = conformal::sin_ball; + ld cb = models::cos_ball; + ld sb = models::sin_ball; if(abs(sb) <= abs(cb) + 1e-5) { ld step = .01 / (1 << vid.linequality); @@ -1771,9 +1771,9 @@ EX void draw_boundary(int w) { case mdSpiral: { if(euclid) return; - if(conformal::ring_not_spiral) return; + if(models::ring_not_spiral) return; // if(p == PPR::CIRCLE) p = PPR::OUTCIRCLE; - auto& sm = conformal::spiral_multiplier; + auto& sm = models::spiral_multiplier; ld u = hypot(1, imag(sm) / real(sm)); if(real(sm)) { queuereset(mdUnchanged, p); @@ -1806,10 +1806,10 @@ EX void draw_boundary(int w) { EX ld band_shift = 0; EX void fix_the_band(transmatrix& T) { - if(((models[pmodel].flags & mf::quasiband) && T[DIM][DIM] > 1e6) || (sphere && pmodel == mdSpiral)) { + if(((mdinf[pmodel].flags & mf::quasiband) && T[DIM][DIM] > 1e6) || (sphere && pmodel == mdSpiral)) { hyperpoint H = tC0(T); find_zlev(H); - conformal::apply_orientation(H[0], H[1]); + models::apply_orientation(H[0], H[1]); ld y = asin_auto(H[1]); ld x = asin_auto_clamp(H[0] / cos_auto(y)); @@ -1907,17 +1907,17 @@ EX bool do_draw(cell *c, const transmatrix& T) { if(euclid && pmodel == mdSpiral) { hyperpoint h = tC0(T); cld z(h[0], h[1]); - z = z * conformal::spiral_multiplier; + z = z * models::spiral_multiplier; ld iz = imag(z) + 1.14279e-2; // make it never fall exactly on PI if(iz < -M_PI || iz >= M_PI) return false; } - if(pmodel == mdSpiral && conformal::ring_not_spiral) { + if(pmodel == mdSpiral && models::ring_not_spiral) { cld z; hyperpoint H = tC0(T); hyperpoint ret; makeband(H, ret, band_conformal); - z = cld(ret[0], ret[1]) * conformal::spiral_multiplier; - if(imag(z) < -conformal::spiral_cone_rad/2-1e-5 || imag(z) >= conformal::spiral_cone_rad/2-1e-5) return false; + z = cld(ret[0], ret[1]) * models::spiral_multiplier; + if(imag(z) < -models::spiral_cone_rad/2-1e-5 || imag(z) >= models::spiral_cone_rad/2-1e-5) return false; } if(cells_drawn > vid.cells_drawn_limit) return false; bool usr = vid.use_smart_range || quotient || euwrap; @@ -1930,10 +1930,10 @@ EX int cone_side(const hyperpoint H) { hyperpoint ret; if(hyperbolic) makeband(H, ret, band_conformal); else ret = H; - cld z = cld(ret[0], ret[1]) * conformal::spiral_multiplier; + cld z = cld(ret[0], ret[1]) * models::spiral_multiplier; auto zth = [&] (cld z) { - ld alpha = imag(z) * 360 / conformal::spiral_cone; + ld alpha = imag(z) * 360 / models::spiral_cone; ld r = real(z); r = exp(r); @@ -1941,9 +1941,9 @@ EX int cone_side(const hyperpoint H) { ret[0] = -sin(alpha) * r; ret[1] = cos(alpha) * r; - ret[2] = (r-1) * sqrt( pow(360/conformal::spiral_cone, 2) - 1); + ret[2] = (r-1) * sqrt( pow(360/models::spiral_cone, 2) - 1); - conformal::apply_ball(ret[2], ret[1]); + models::apply_ball(ret[2], ret[1]); return ret; }; diff --git a/init.cpp b/init.cpp index 091eb831..95eebc12 100644 --- a/init.cpp +++ b/init.cpp @@ -328,7 +328,7 @@ void mobile_draw(MOBPAR_FORMAL) { mousex = vid.xres/2, mousey = vid.yres/2, mouseh = sphereflip * C0; frames++; - conformal::configure(); + models::configure(); if(ticks > lastt) tortoise::updateVals(ticks - lastt); diff --git a/legacy.cpp b/legacy.cpp index 55f653a8..5bfbd138 100644 --- a/legacy.cpp +++ b/legacy.cpp @@ -85,22 +85,22 @@ void loadOldConfig(FILE *f) { rug::model_distance = 2/rs; #endif - aa=conformal::autobandhistory; - double ps = polygonal::STAR, lv = conformal::lvspeed; + aa=history::autobandhistory; + double ps = polygonal::STAR, lv = history::lvspeed; int pmb = pmodel; err=fscanf(f, "%d%d%lf%d%d%lf", &pmb, &polygonal::SI, &ps, &polygonal::deg, &aa, &lv); pmodel = eModel(pmb); - conformal::autobandhistory = aa; polygonal::STAR = ps; conformal::lvspeed = lv; + history::autobandhistory = aa; polygonal::STAR = ps; history::lvspeed = lv; - aa=conformal::autoband; bb=conformal::autobandhistory; cc=conformal::dospiral; + aa=history::autoband; bb=history::autobandhistory; cc=history::dospiral; int crot; err=fscanf(f, "%d%d%d%d%d%d", - &conformal::bandhalf, &conformal::bandsegment, &crot, + &history::bandhalf, &history::bandsegment, &crot, &aa, &bb, &cc); - conformal::autoband = aa; conformal::autobandhistory = bb; conformal::dospiral = cc; - conformal::rotation = crot * 90; + history::autoband = aa; history::autobandhistory = bb; history::dospiral = cc; + models::rotation = crot * 90; err=fscanf(f, "%d", &polygonal::maxcoef); if(polygonal::maxcoef < 0) polygonal::maxcoef = 0; diff --git a/menus.cpp b/menus.cpp index 7368c285..d44f8f70 100644 --- a/menus.cpp +++ b/menus.cpp @@ -456,8 +456,8 @@ EX void showCreative() { dialog::add_action_push(anims::show); #endif - dialog::addBoolItem(XLAT("history mode"), conformal::on || conformal::includeHistory, 'h'); - dialog::add_action_push(conformal::history_menu); + dialog::addBoolItem(XLAT("history mode"), history::on || history::includeHistory, 'h'); + dialog::add_action_push(history::history_menu); #if CAP_TEXTURE if(DIM == 2) { diff --git a/conformal.cpp b/models.cpp similarity index 52% rename from conformal.cpp rename to models.cpp index f3fa909a..12258d70 100644 --- a/conformal.cpp +++ b/models.cpp @@ -1,1353 +1,721 @@ -// Hyperbolic Rogue -- the conformal/history mode -// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details - -namespace hr { - -#if ISMOBWEB -typedef double precise; -#else -typedef long double precise; -#endif - -EX namespace polygonal { - - #if HDR - static const int MSI = 120; - #endif - - typedef long double xld; - - typedef complex cxld; - - EX int SI = 4; - EX ld STAR = 0; - - EX int deg = ISMOBWEB ? 2 : 20; - - precise matrix[MSI][MSI]; - precise ans[MSI]; - - cxld coef[MSI]; - EX ld coefr[MSI], coefi[MSI]; - EX int maxcoef, coefid; - - EX void solve() { - if(pmodel == mdPolynomial) { - for(int i=0; i 0 ? (1+STAR) : 1) - - sin(i0 * (j + 1./SI)) * (STAR > 0 ? STAR : STAR/(1+STAR)); - } - - for(int i=0; i=0; i--) { - for(int j=0; j compute(ld x, ld y, int prec) { - if(x*x+y*y > 1) { - xld r = hypot(x,y); - x /= r; - y /= r; - } - if(pmodel == mdPolynomial) { - cxld z(x,y); - cxld res (0,0); - for(int i=maxcoef; i>=0; i--) { res += coef[i]; if(i) res *= z; } - return make_pair(real(res), imag(res)); - } - - cxld z(x, y); - cxld res (0,0); - cxld zp = 1; for(int i=0; i0; i--) { - res += ans[i]; - res *= zp; - } - res += ans[0]; res *= z; - return make_pair(real(res), imag(res)); - } - - pair compute(ld x, ld y) { return compute(x,y,deg); } - EX } - -#if CAP_SDL -namespace spiral { - - typedef long double ld; - typedef complex cxld; - - int shiftx, shifty, velx, vely; - - vector > quickmap; - - int CX, CY, SX, SY, Yshift; - - vector band; - SDL_Surface *out; - - bool displayhelp = true; - - color_t& bandpixel(int x, int y) { - int i = 0; - while(i < isize(band) && x >= band[i]->w) - x -= band[i]->w, i++; - return qpixel(band[i], x, y); - } - - void precompute() { - - CX = 0; - for(int i=0; iw; - if(CX == 0) { printf("ERROR: no CX\n"); return; } - CY = band[0]->h; - SX = out->w; - SY = out->h; - - ld k = -2*M_PI*M_PI / log(2.6180339); - -// cxld mnoznik = cxld(0, M_PI) / cxld(k, M_PI); - - cxld factor = cxld(0, -CY/2/M_PI/M_PI) * cxld(k, M_PI); - - Yshift = CY * k / M_PI; - - quickmap.clear(); - - double xc = ((SX | 1) - 2) / 2.; - double yc = ((SY | 1) - 2) / 2.; - - for(int y=0; y p = quickmap[c++]; - int cx = p.first + shiftx; - int cy = p.second + + shifty; - int d = cy / CY; - cy -= d * CY; cx -= d * Yshift; - if(cy<0) cy += CY, cx += Yshift; - cx %= CX; if(cx<0) cx += CX; - qpixel(out, x, y) = bandpixel(cx, cy); - } - } - - void loop(vector _band) { - - band = _band; - out = s; - precompute(); - if(CX == 0) return; - shiftx = shifty = 0; - velx=1; vely=1; - bool dosave = false; - - bool saveGL = vid.usingGL; - if(saveGL) switchGL(); // { vid.usingGL = false; setvideomode(); } - - while(true) { - - time_t timer; - timer = time(NULL); - char buf[128]; - strftime(buf, 128, "spiral-%y%m%d-%H%M%S" IMAGEEXT, localtime(&timer)); - - SDL_LockSurface(s); - draw(); - if(dosave) { dosave = false; IMAGESAVE(s, buf); } - SDL_UnlockSurface(s); - if(displayhelp) { - displaystr(SX/2, vid.fsize*2, 0, vid.fsize, "arrows = navigate, ESC = return, h = hide help", forecolor, 8); - displaystr(SX/2, SY - vid.fsize*2, 0, vid.fsize, XLAT("s = save to " IMAGEEXT, buf), forecolor, 8); - } - SDL_UpdateRect(s, 0, 0, 0, 0); - shiftx += velx; shifty += vely; - - SDL_Event event; - while(SDL_PollEvent(&event)) switch (event.type) { - - case SDL_VIDEORESIZE: { - resize_screen_to(event.resize.w, event.resize.h); - precompute(); - break; - } - case SDL_QUIT: case SDL_MOUSEBUTTONDOWN: - goto breakloop; - - case SDL_KEYDOWN: { - int sym = event.key.keysym.sym; - int uni = event.key.keysym.unicode; - numlock_on = event.key.keysym.mod & KMOD_NUM; - if(DKEY == SDLK_RIGHT) velx++; - if(DKEY == SDLK_LEFT) velx--; - if(DKEY == SDLK_UP) vely++; - if(DKEY == SDLK_DOWN) vely--; - if(sym == SDLK_ESCAPE) goto breakloop; - if(uni == 'h') displayhelp = !displayhelp; - if(uni == 's') dosave = true; - } - } - } - - breakloop: - quickmap.clear(); - if(saveGL) switchGL(); // { vid.usingGL = true; setvideomode(); } - } - - } -#endif - -bool isbad(ld z) { return !isfinite(z) || fabs(z) > 1e6; } - -EX namespace conformal { - - EX string formula = "z^2"; - EX eModel basic_model; - - void handleKeyC(int sym, int uni); - - int lastprogress; - - EX void progress_screen() { - gamescreen(0); - mouseovers = ""; - } - - EX void progress(string str) { -#if CAP_SDL - int tick = SDL_GetTicks(); - if(tick > lastprogress + 250) { - lastprogress = tick; - msgs.clear(); - addMessage(str); - drawscreen(); - } -#endif - } - - EX bool on; - EX vector v; - int llv; - EX double phase; - - EX vector > killhistory; - EX vector > findhistory; - EX vector movehistory; - - EX bool includeHistory; - EX ld lvspeed = 1; - EX int bandhalf = 200; - EX int bandsegment = 16000; - EX ld rotation = 0; - EX ld rotation_xz = 90; - EX ld rotation_xy2 = 90; - EX int do_rotate = 1; - EX ld model_orientation, halfplane_scale, model_orientation_yz; - EX ld clip_min, clip_max; - EX ld ocos, osin, ocos_yz, osin_yz; - EX ld cos_ball, sin_ball; - EX bool model_straight, model_straight_yz; - EX ld top_z = 5; - EX ld model_transition = 1; - - EX bool autoband = false; - EX bool autobandhistory = false; - EX bool dospiral = true; - - #if HDR - // screen coordinates to logical coordinates: apply_orientation(x,y) - // logical coordinates back to screen coordinates: apply_orientation(y,x) - template - void apply_orientation(A& x, A& y) { if(!model_straight) tie(x,y) = make_pair(x*ocos + y*osin, y*ocos - x*osin); } - template - void apply_orientation_yz(A& x, A& y) { if(!model_straight_yz) tie(x,y) = make_pair(x*ocos_yz + y*osin_yz, y*ocos_yz - x*osin_yz); } - template - void apply_ball(A& x, A& y) { tie(x,y) = make_pair(x*cos_ball + y*sin_ball, y*cos_ball - x*sin_ball); } - #endif - - EX ld extra_line_steps = 0; - - EX vector path_for_lineanimation; - - EX void clear() { - on = false; - int N = isize(v); - for(int i=0; i 1)) { - addMessage("Must go a distance from the starting point"); - return; - } - - on = true; - - if(!quotient) try { - path_for_lineanimation = build_shortest_path(start, target); - } - catch(hr_shortest_path_exception&) { - addMessage("Error: could not build a path"); - return; - } - - for(cell *c: path_for_lineanimation) { - shmup::monster *m = new shmup::monster; - m->at = Id; - m->base = c; - v.push_back(m); - } - - v.back()->at = last; - - int Q = isize(v)-1; - // virtualRebase(v[0], false); - // virtualRebase(v[Q], false); - - for(int i=0; i<1000; i++) { - progress(XLAT("Preparing the line (%1/1000)...", its(i+1))); - - for(int j=1; jbase, v[j]->base, C0) * - v[j-1]->at * C0; - - hyperpoint next = calc_relative_matrix(v[j+1]->base, v[j]->base, C0) * - v[j+1]->at * C0; - - hyperpoint hmid = mid(prev, next); - - transmatrix at = rgpushxto0(hmid); - - v[j]->at = at * rspintox(inverse(at) * next); - fixmatrix(v[j]->at); - } - } - - hyperpoint next0 = calc_relative_matrix(v[1]->base, v[0]->base, C0) * v[1]->at * C0; - v[0]->at = v[0]->at * rspintox(inverse(v[0]->at) * next0); - - llv = ticks; - phase = 0; - } - - EX void create_playerpath() { - create(currentmap->gamestart(), cwt.at, Id); - } - - EX void create_recenter_to_view(bool precise) { - cell *c = centerover.at ? centerover.at : cwt.at; - create(path_for_lineanimation[0], c, precise ? inverse(ggmatrix(c)) : Id); - } - - EX transmatrix rotmatrix() { - if(DIM == 2) return spin(rotation * degree); - return spin(rotation_xy2 * degree) * cspin(0, 2, -rotation_xz * degree) * spin(rotation * degree); - } - - EX void movetophase() { - - int ph = int(phase); - int siz = isize(v); - if(ph<0) ph = 0; - if(ph >= siz-1) ph = siz-2; - - heptagon *old = viewctr.at; - - viewctr.at = v[ph]->base->master; - viewctr.spin = 0; - - ld angle = 0; - if(DIM == 3) { - hyperpoint h = inverse(rotmatrix()) * View * hpxy3(1,2,3); - angle = atan2(h[1], h[2]); - } - - View = inverse(master_relative(v[ph]->base) * v[ph]->at); - - hyperpoint now = v[ph]->at * C0; - - hyperpoint next = calc_relative_matrix(v[ph+1]->base, v[ph]->base, C0) * - v[ph+1]->at * C0; - - View = xpush(-(phase-ph) * hdist(now, next)) * View; - if(WDIM == 2) { - View = rotmatrix() * View; - } - else { - if(celldistance(v[ph]->base, old->c7) <= 2) { - hyperpoint h1 = View * currentmap->relative_matrix(old, viewctr.at) * hpxy3(1,2,3); - ld angle1 = atan2(h1[1], h1[2]); - View = cspin(2, 1, angle1 - angle) * View; - } - View = rotmatrix() * View; - } - - playermoved = false; - centerover.at = v[ph]->base; - compute_graphical_distance(); - } - - EX void apply() { - int t = ticks; - phase += (t-llv) * lvspeed / 400.; - llv = t; - - int siz = isize(v); - - while(phase > siz-1 + extra_line_steps) phase -= (siz + 2 * extra_line_steps-1); - while(phase < - extra_line_steps) phase += (siz + 2 * extra_line_steps-1); - - movetophase(); - } - - EX ld spiral_angle = 70; - EX ld spiral_x = 10; - EX ld spiral_y = 7; - int spiral_id = 7; - EX bool use_atan = false; - - cld spiral_multiplier; - ld right_spiral_multiplier = 1; - ld any_spiral_multiplier = 1; - ld sphere_spiral_multiplier = 2; - EX ld spiral_cone = 360; - ld spiral_cone_rad; - bool ring_not_spiral; - - EX void configure() { - ld ball = -vid.ballangle * degree; - cos_ball = cos(ball), sin_ball = sin(ball); - ocos = cos(model_orientation * degree); - osin = sin(model_orientation * degree); - ocos_yz = cos(model_orientation_yz * degree); - osin_yz = sin(model_orientation_yz * degree); - model_straight = (ocos > 1 - 1e-9); - model_straight_yz = DIM == 2 || (ocos_yz > 1-1e-9); - if(conformal::on) conformal::apply(); - - if(!euclid) { - ld b = spiral_angle * degree; - ld cos_spiral = cos(b); - ld sin_spiral = sin(b); - spiral_cone_rad = spiral_cone * degree; - ring_not_spiral = abs(cos_spiral) < 1e-3; - ld mul = 1; - if(sphere) mul = .5 * sphere_spiral_multiplier; - else if(ring_not_spiral) mul = right_spiral_multiplier; - else mul = any_spiral_multiplier * cos_spiral; - - spiral_multiplier = cld(cos_spiral, sin_spiral) * cld(spiral_cone_rad * mul / 2., 0); - } - if(euclid) { - hyperpoint h = tC0(eumove(spiral_x, spiral_y)); - spiral_multiplier = cld(0, 2 * M_PI) / cld(h[0], h[1]); - } - - if(centerover.at && !on) - if(isize(path_for_lineanimation) == 0 || (quotient && path_for_lineanimation.back() != centerover.at)) { - path_for_lineanimation.push_back(centerover.at); - } - - band_shift = 0; - } - - ld measureLength() { - ld r = bandhalf * vid.scale; - - ld tpixels = 0; - int siz = isize(v); - - for(int j=0; jat) * - calc_relative_matrix(v[j+1]->base, v[j]->base, C0) * - v[j+1]->at * C0; - - hyperpoint nextscr; - applymodel(next, nextscr); - tpixels += nextscr[0] * r; - - if(j == 0 || j == siz-2) - tpixels += nextscr[0] * r * extra_line_steps; - } - - return tpixels; - } - - void restore(); - void restoreBack(); - -#if CAP_SDL - void createImage(bool dospiral) { - int segid = 1; - if(includeHistory) restore(); - - int bandfull = 2*bandhalf; - ld len = measureLength(); - - time_t timer; - timer = time(NULL); - char timebuf[128]; - strftime(timebuf, 128, "%y%m%d-%H%M%S", localtime(&timer)); - - vector bands; - - resetbuffer rbuf; - - if(1) { - // block for RAII - dynamicval dv(vid, vid); - dynamicval dr(rotation, 0); - dynamicval di(inHighQual, true); - - renderbuffer glbuf(bandfull, bandfull, vid.usingGL); - vid.xres = vid.yres = bandfull; - glbuf.enable(); current_display->radius = bandhalf; - calcparam(); - - ld xpos = 0; - - int seglen = min(int(len), bandsegment); - - SDL_Surface *band = SDL_CreateRGBSurface(SDL_SWSURFACE, seglen, bandfull,32,0,0,0,0); - - if(!band) { - addMessage("Could not create an image of that size."); - } - else { - - int siz = isize(v); - - int bonus = ceil(extra_line_steps); - - cell *last_base = NULL; - hyperpoint last_relative; - - for(int j=-bonus; jradius = bandhalf; - phase = j; movetophase(); - - glbuf.clear(backcolor); - drawfullmap(); - - if(last_base) { - hyperpoint last = ggmatrix(last_base) * last_relative; - hyperpoint hscr; - applymodel(last, hscr); - ld bwidth = -current_display->radius * hscr[0]; - print(hlog, "bwidth = ", bwidth, "/", len); - - drawsegment: - SDL_Surface *gr = glbuf.render(); - - for(int cy=0; cy bandsegment) { - char buf[154]; - sprintf(buf, "bandmodel-%s-%03d" IMAGEEXT, timebuf, segid++); - - IMAGESAVE(band, buf); - - if(dospiral) - bands.push_back(band); - else - SDL_FreeSurface(band); - - len -= bandsegment; xpos -= bandsegment; - seglen = min(int(len), bandsegment); - band = SDL_CreateRGBSurface(SDL_SWSURFACE, seglen, bandfull,32,0,0,0,0); - goto drawsegment; - } - xpos += bwidth; - } - - last_base = viewctr.at->c7; - last_relative = inverse(ggmatrix(last_base)) * C0; - } - } - - char buf[154]; - sprintf(buf, "bandmodel-%s-%03d" IMAGEEXT, timebuf, segid++); - IMAGESAVE(band, buf); - addMessage(XLAT("Saved the band image as: ") + buf); - - if(dospiral) - bands.push_back(band); - else - SDL_FreeSurface(band); - } - - rbuf.reset(); - - if(includeHistory) restoreBack(); - - if(dospiral) { - spiral::loop(bands); - for(int i=0; i > torus_zeros; - - void match_torus_period() { - torus_zeros.clear(); - for(int y=0; y<=200; y++) - for(int x=-200; x<=200; x++) { - if(y == 0 && x <= 0) continue; - auto zero = vec_to_cellwalker(euclid_getvec(x, y)); - if(zero.at == currentmap->gamestart() && !zero.mirrored) - torus_zeros.emplace_back(x, y); - } - sort(torus_zeros.begin(), torus_zeros.end(), [] (const pair p1, const pair p2) { - ld d1 = hdist0(tC0(eumove(p1.first, p1.second))); - ld d2 = hdist0(tC0(eumove(p2.first, p2.second))); - if(d1 < d2 - 1e-6) return true; - if(d1 > d2 + 1e-6) return false; - return p1 < p2; - }); - if(spiral_id > isize(torus_zeros)) spiral_id = 0; - dialog::editNumber(spiral_id, 0, isize(torus_zeros)-1, 1, 10, XLAT("match the period of the torus"), ""); - dialog::reaction = [] () { - tie(spiral_x, spiral_y) = torus_zeros[spiral_id]; - }; - dialog::bound_low(0); - dialog::bound_up(isize(torus_zeros)-1); - } - - EX void edit_formula() { - if(pmodel != mdFormula) basic_model = pmodel; - dialog::edit_string(formula, "formula", - XLAT( - "This lets you specify the projection as a formula f. " - "The formula has access to the value 'z', which is a complex number corresponding to the (x,y) coordinates in the currently selected model; " - "the point z is mapped to f(z). You can also use the underlying coordinates ux, uy, uz." - ) + "\n\n" + parser_help() - ); - #if CAP_QUEUE && CAP_CURVE - dialog::extra_options = [] () { - initquickqueue(); - queuereset(mdUnchanged, PPR::LINE); - for(int a=-1; a<=1; a++) { - curvepoint(point2(-M_PI/2 * current_display->radius, a*current_display->radius)); - curvepoint(point2(+M_PI/2 * current_display->radius, a*current_display->radius)); - queuecurve(forecolor, 0, PPR::LINE); - curvepoint(point2(a*current_display->radius, -M_PI/2*current_display->radius)); - curvepoint(point2(a*current_display->radius, +M_PI/2*current_display->radius)); - queuecurve(forecolor, 0, PPR::LINE); - } - queuereset(pmodel, PPR::LINE); - quickqueue(); - }; - #endif - dialog::reaction_final = [] () { - pmodel = mdFormula; - }; - } - - EX void edit_rotation(ld& which) { - dialog::editNumber(which, 0, 360, 90, 0, XLAT("rotation"), - "This controls the automatic rotation of the world. " - "It affects the line animation in the history mode, and " - "lands which have a special direction. Note that if finding this special direction is a part of the puzzle, " - "it works only in the cheat mode."); - dialog::dialogflags |= sm::CENTER; - dialog::extra_options = [] () { - dialog::addBreak(100); - dialog::addBoolItem_choice("line animation only", conformal::do_rotate, 0, 'N'); - dialog::addBoolItem_choice("gravity lands", conformal::do_rotate, 1, 'G'); - dialog::addBoolItem_choice("all directional lands", conformal::do_rotate, 2, 'D'); - if(DIM == 3) { - dialog::addBreak(100); - dialog::addSelItem(XLAT("XY plane"), fts(conformal::rotation) + "°", 'A'); - dialog::add_action([] { popScreen(); edit_rotation(conformal::rotation); }); - dialog::addSelItem(XLAT("XZ plane"), fts(conformal::rotation_xz) + "°", 'B'); - dialog::add_action([] { popScreen(); edit_rotation(conformal::rotation_xz); }); - dialog::addSelItem(XLAT("XY plane #2"), fts(conformal::rotation_xy2) + "°", 'C'); - dialog::add_action([] { popScreen(); edit_rotation(conformal::rotation_xy2); }); - } - }; - } - - EX void model_menu() { - cmode = sm::SIDE | sm::MAYDARK | sm::CENTER; - gamescreen(0); - dialog::init(XLAT("models & projections")); - string chars = "0123456789!@#$%^&*()][{}'\""; - int cpos = 0; - for(int i=0; i 1e-3 && pmodel != mdBall && pmodel != mdHyperboloid && pmodel != mdHemisphere && pmodel != mdDisk) { - dialog::addBreak(50); - dialog::addInfo("NOTE: this works 'correctly' only if the Poincaré model/stereographic projection is used."); - dialog::addBreak(50); - } - - if(among(pmodel, mdDisk, mdBall, mdHyperboloid, mdRotatedHyperboles)) { - dialog::addSelItem(XLAT("projection distance"), - fts(vid.alpha) + " (" + current_proj_name() + ")", 'p'); - } - - if(model_has_orientation()) { - dialog::addSelItem(XLAT("model orientation"), fts(model_orientation) + "°", 'l'); - dialog::add_action([] () { - dialog::editNumber(model_orientation, 0, 360, 90, 0, XLAT("model orientation"), ""); - }); - if(DIM == 3) { - dialog::addSelItem(XLAT("model orientation (y/z plane)"), fts(model_orientation_yz) + "°", 'L'); - dialog::add_action([] () { - dialog::editNumber(model_orientation_yz, 0, 360, 90, 0, XLAT("model orientation (y/z plane)"), ""); - }); - } - } - - if(DIM == 3 && pmodel != mdPerspective) { - const string cliphelp = XLAT( - "Your view of the 3D model is naturally bounded from four directions by your window. " - "Here, you can also set up similar bounds in the Z direction. Radius of the ball/band " - "models, and the distance from the center to the plane in the halfspace model, are 1.\n\n"); - dialog::addSelItem(XLAT("near clipping plane"), fts(clip_max), 'c'); - dialog::add_action([cliphelp] () { - dialog::editNumber(clip_max, -10, 10, 0.2, 1, XLAT("near clipping plane"), - cliphelp + XLAT("Objects with Z coordinate " - "bigger than this parameter are not shown. This is useful with the models which " - "extend infinitely in the Z direction, or if you want things close to your character " - "to be not obscured by things closer to the camera.")); - }); - dialog::addSelItem(XLAT("far clipping plane"), fts(clip_min), 'C'); - dialog::add_action([cliphelp] () { - dialog::editNumber(clip_min, -10, 10, 0.2, -1, XLAT("far clipping plane"), - cliphelp + XLAT("Objects with Z coordinate " - "smaller than this parameter are not shown; it also affects the fog effect" - " (near clipping plane = 0% fog, far clipping plane = 100% fog).")); - }); - } - - if(pmodel == mdPolynomial) { - dialog::addSelItem(XLAT("coefficient"), - fts(polygonal::coefr[polygonal::coefid]), 'x'); - dialog::add_action([] () { - polygonal::maxcoef = max(polygonal::maxcoef, polygonal::coefid); - int ci = polygonal::coefid + 1; - dialog::editNumber(polygonal::coefr[polygonal::coefid], -10, 10, .01/ci/ci, 0, XLAT("coefficient"), ""); - }); - dialog::addSelItem(XLAT("coefficient (imaginary)"), - fts(polygonal::coefi[polygonal::coefid]), 'y'); - dialog::add_action([] () { - polygonal::maxcoef = max(polygonal::maxcoef, polygonal::coefid); - int ci = polygonal::coefid + 1; - dialog::editNumber(polygonal::coefi[polygonal::coefid], -10, 10, .01/ci/ci, 0, XLAT("coefficient (imaginary)"), ""); - }); - dialog::addSelItem(XLAT("which coefficient"), its(polygonal::coefid), 'n'); - dialog::add_action([] () { - dialog::editNumber(polygonal::coefid, 0, polygonal::MSI-1, 1, 0, XLAT("which coefficient"), ""); - dialog::bound_low(0); dialog::bound_up(polygonal::MSI-1); - }); - } - - if(pmodel == mdHalfplane) { - dialog::addSelItem(XLAT("half-plane scale"), fts(halfplane_scale), 'b'); - dialog::add_action([] () { - dialog::editNumber(halfplane_scale, 0, 2, 0.25, 1, XLAT("half-plane scale"), ""); - }); - } - - if(pmodel == mdRotatedHyperboles) { - dialog::addBoolItem_action(XLAT("use atan to make it finite"), use_atan, 'x'); - } - - if(pmodel == mdBall) { - dialog::addSelItem(XLAT("projection in ball model"), fts(vid.ballproj), 'x'); - dialog::add_action([] () { - dialog::editNumber(vid.ballproj, 0, 100, .1, 0, XLAT("projection in ball model"), - "This parameter affects the ball model the same way as the projection parameter affects the disk model."); - }); - } - - if(pmodel == mdPolygonal) { - dialog::addSelItem(XLAT("polygon sides"), its(polygonal::SI), 'x'); - dialog::add_action([] () { - dialog::editNumber(polygonal::SI, 3, 10, 1, 4, XLAT("polygon sides"), ""); - dialog::reaction = polygonal::solve; - }); - dialog::addSelItem(XLAT("star factor"), fts(polygonal::STAR), 'y'); - dialog::add_action([]() { - dialog::editNumber(polygonal::STAR, -1, 1, .1, 0, XLAT("star factor"), ""); - dialog::reaction = polygonal::solve; - }); - dialog::addSelItem(XLAT("degree of the approximation"), its(polygonal::deg), 'n'); - dialog::add_action([](){ - dialog::editNumber(polygonal::deg, 2, polygonal::MSI-1, 1, 2, XLAT("degree of the approximation"), ""); - dialog::reaction = polygonal::solve; - dialog::bound_low(0); dialog::bound_up(polygonal::MSI-1); - }); - } - - if(pmodel == mdBall || pmodel == mdHyperboloid || pmodel == mdHemisphere || (pmodel == mdSpiral && spiral_cone != 360)) { - dialog::addSelItem(XLAT("camera rotation in 3D models"), fts(vid.ballangle) + "°", 'b'); - dialog::add_action(config_camera_rotation); - } - - if(pmodel == mdHyperboloid) { - dialog::addSelItem(XLAT("maximum z coordinate to show"), fts(top_z), 'l'); - dialog::add_action([](){ - dialog::editNumber(top_z, 1, 20, 0.25, 4, XLAT("maximum z coordinate to show"), ""); - }); - } - - if(model_has_transition()) { - dialog::addSelItem(XLAT("model transition"), fts(model_transition), 't'); - dialog::add_action([]() { - dialog::editNumber(model_transition, 0, 1, 0.1, 1, XLAT("model transition"), - "You can change this parameter for a transition from another model to this one." - ); - }); - } - - if(among(pmodel, mdJoukowsky, mdJoukowskyInverted, mdSpiral) && DIM == 2) { - dialog::addSelItem(XLAT("Möbius transformations"), fts(vid.skiprope) + "°", 'S'); - dialog::add_action([](){ - dialog::editNumber(vid.skiprope, 0, 360, 15, 0, XLAT("Möbius transformations"), ""); - }); - } - - if(pmodel == mdHemisphere && euclid) { - dialog::addSelItem(XLAT("parameter"), fts(vid.euclid_to_sphere), 'l'); - dialog::add_action([] () { - dialog::editNumber(vid.euclid_to_sphere, 0, 10, .1, 1, XLAT("parameter"), - "Stereographic projection to a sphere. Choose the radius of the sphere." - ); - dialog::scaleLog(); - }); - } - - if(among(pmodel, mdTwoPoint, mdSimulatedPerspective, mdTwoHybrid)) { - dialog::addSelItem(XLAT("parameter"), fts(vid.twopoint_param), 'b'); - dialog::add_action([](){ - dialog::editNumber(vid.twopoint_param, 1e-3, 10, .1, 1, XLAT("parameter"), - "This model maps the world so that the distances from two points " - "are kept. This parameter gives the distance from the two points to " - "the center." - ); - dialog::scaleLog(); - }); - } - - if(pmodel == mdSpiral && !euclid) { - dialog::addSelItem(XLAT("spiral angle"), fts(spiral_angle) + "°", 'x'); - dialog::add_action([](){ - dialog::editNumber(spiral_angle, 0, 360, 15, 0, XLAT("spiral angle"), - XLAT("set to 90° for the ring projection") - ); - }); - - ld& which = - sphere ? sphere_spiral_multiplier : - ring_not_spiral ? right_spiral_multiplier : - any_spiral_multiplier; - - dialog::addSelItem(XLAT("spiral multiplier"), fts(which) + "°", 'M'); - dialog::add_action([&which](){ - dialog::editNumber(which, 0, 10, -.1, 1, XLAT("spiral multiplier"), - XLAT( - "This parameter has a bit different scale depending on the settings:\n" - "(1) in spherical geometry (with spiral angle=90°, 1 produces a stereographic projection)\n" - "(2) in hyperbolic geometry, with spiral angle being +90° or -90°\n" - "(3) in hyperbolic geometry, with other spiral angles (1 makes the bands fit exactly)" - ) - ); - }); - - dialog::addSelItem(XLAT("spiral cone"), fts(spiral_cone) + "°", 'C'); - dialog::add_action([](){ - dialog::editNumber(spiral_cone, 0, 360, -45, 360, XLAT("spiral cone"), ""); - }); - } - - if(pmodel == mdSpiral && euclid) { - dialog::addSelItem(XLAT("spiral period: x"), fts(spiral_x), 'x'); - dialog::add_action([](){ - dialog::editNumber(spiral_x, -20, 20, 1, 10, XLAT("spiral period: x"), ""); - }); - dialog::addSelItem(XLAT("spiral period: y"), fts(spiral_y), 'y'); - dialog::add_action([](){ - dialog::editNumber(spiral_y, -20, 20, 1, 10, XLAT("spiral period: y"), ""); - }); - if(euwrap) { - dialog::addSelItem(XLAT("match the period"), its(spiral_id), 'n'); - dialog::add_action(match_torus_period); - } - } - - dialog::addSelItem(XLAT("vertical stretch"), fts(vid.stretch), 's'); - - dialog::addBoolItem(XLAT("use GPU to compute projections"), vid.consider_shader_projection, 'G'); - if(vid.consider_shader_projection && !shaderside_projection) - dialog::lastItem().value = XLAT("N/A"); - if(vid.consider_shader_projection && shaderside_projection && pmodel) - dialog::lastItem().value += XLAT(" (2D only)"); - dialog::add_action([] { vid.consider_shader_projection = !vid.consider_shader_projection; }); - - menuitem_sightrange('R'); - - dialog::addBreak(100); - dialog::addItem(XLAT("history mode"), 'a'); -#if CAP_RUG - if(GDIM == 2) dialog::addItem(XLAT("hypersian rug mode"), 'u'); -#endif - dialog::addBack(); - - dialog::display(); - mouseovers = XLAT("see http://www.roguetemple.com/z/hyper/models.php"); - - keyhandler = [] (int sym, int uni) { - dialog::handleNavigation(sym, uni); - - if(uni == 'z') - editScale(); - else if(uni == 'p') - projectionDialog(); -#if CAP_RUG - else if(uni == 'u' && DIM == 2) - pushScreen(rug::show); -#endif - else if(uni == 's') { - dialog::editNumber(vid.stretch, 0, 10, .1, 1, XLAT("vertical stretch"), - "Vertical stretch factor." - ); - dialog::extra_options = [] () { - dialog::addBreak(100); - if(sphere && pmodel == mdBandEquiarea) { - dialog::addBoolItem("Gall-Peters", vid.stretch == 2, 'O'); - dialog::add_action([] { vid.stretch = 2; dialog::ne.s = "2"; }); - } - if(pmodel == mdBandEquiarea) { - // y = K * sin(phi) - // cos(phi) * cos(phi) = 1/K - if(sphere && vid.stretch >= 1) { - ld phi = acos(sqrt(1/vid.stretch)); - dialog::addInfo(XLAT("The current value makes the map conformal at the latitude of %1 (%2°).", fts(phi), fts(phi / degree))); - } - else if(hyperbolic && abs(vid.stretch) <= 1 && abs(vid.stretch) >= 1e-9) { - ld phi = acosh(abs(sqrt(1/vid.stretch))); - dialog::addInfo(XLAT("The current value makes the map conformal %1 units from the main line.", fts(phi))); - } - else dialog::addInfo(""); - } - }; - } - else if(uni == 'a') - pushScreen(history_menu); - else if(doexiton(sym, uni)) popScreen(); - }; - } - - EX bool band_renderable_now() { - return on && (pmodel == mdBand || pmodel == mdBandEquidistant || pmodel == mdBandEquiarea) && !euclid && !sphere; - } - - EX void history_menu() { - cmode = sm::SIDE | sm::MAYDARK; - gamescreen(0); - - dialog::init(XLAT("history mode")); - - dialog::addBoolItem(XLAT("include history"), (includeHistory), 'i'); - - // bool notconformal0 = (pmodel >= 5 && pmodel <= 6) && !euclid; - // bool notconformal = notconformal0 || abs(vid.alpha-1) > 1e-3; - - dialog::addSelItem(XLAT("projection"), current_proj_name(), 'm'); - - dialog::addBoolItem(XLAT("animate from start to current player position"), (on), 'e'); - dialog::addBoolItem(XLAT("animate from last recenter to current view"), (on), 'E'); - dialog::addBoolItem(XLAT("animate from last recenter to precise current view"), (on), 'E'-64); - if(on) dialog::addSelItem(XLAT("animation speed"), fts(lvspeed), 'a'); - else dialog::addBreak(100); - dialog::addSelItem(XLAT("extend the ends"), fts(extra_line_steps), 'p'); - -#if CAP_SDL - dialog::addBoolItem(XLAT("render bands automatically"), (autoband), 'o'); - if(autoband) - dialog::addBoolItem(XLAT("include history when auto-rendering"), (autobandhistory), 'j'); - - if(band_renderable_now() || autoband) { - dialog::addSelItem(XLAT("band width"), "2*"+its(bandhalf), 'd'); - dialog::addSelItem(XLAT("length of a segment"), its(bandsegment), 's'); - dialog::addBoolItem(XLAT("spiral on rendering"), (dospiral), 'g'); - if(band_renderable_now()) - dialog::addItem(XLAT("render now (length: %1)", fts(measureLength())), 'f'); - } -#endif - - dialog::addBack(); - dialog::display(); - mouseovers = XLAT("see http://www.roguetemple.com/z/hyper/models.php"); - keyhandler = handleKeyC; - } - - void handleKeyC(int sym, int uni) { - dialog::handleNavigation(sym, uni); - - if(uni == 'e' || uni == 'E' || uni == 'E'-64) { - if(on) clear(); - else { - if(canmove && !cheater) { - addMessage("Enable cheat mode or GAME OVER to use this"); - return; - } - if(canmove && cheater) cheater++; - if(uni == 'E') create_recenter_to_view(false); - else if(uni == 'E'-64) create_recenter_to_view(true); - else create_playerpath(); - } - } - else if(uni == 'o') - autoband = !autoband; - else if(uni == 'm') - pushScreen(model_menu); - else if(uni == 'a') - dialog::editNumber(lvspeed, -5, 5, .1, 1, XLAT("animation speed"), ""); - else if(uni == 'd') { - dialog::editNumber(bandhalf, 5, 1000, 5, 200, XLAT("band width"), ""); - dialog::bound_low(5); - } - else if(uni == 's') { - dialog::editNumber(bandsegment, 500, 32000, 500, 16000, XLAT("band segment"), ""); - dialog::bound_low(500); - } - else if(uni == 'p') - dialog::editNumber(extra_line_steps, 0, 5, 1, 1, XLAT("extend the ends"), - "0 = start at the game start, endat the end position; " - "larger numbers give extra space at the ends." - ); - else if(uni == 'g') { dospiral = !dospiral; } - else if(uni == 'i') { - if(canmove && !cheater) { - addMessage("Enable cheat mode or GAME OVER to use this"); - return; - } - if(canmove && cheater) cheater++; - includeHistory = !includeHistory; - } -#if CAP_SDL - else if(uni == 'f' && band_renderable_now()) createImage(dospiral); -#endif - else if(uni == 'j') { - autobandhistory = !autobandhistory; - } - else if(doexiton(sym, uni)) popScreen(); - } - - set inmovehistory, inkillhistory, infindhistory; - - EX void restore() { - inmovehistory.clear(); - inkillhistory.clear(); - infindhistory.clear(); - for(int i=0; imonst; - killhistory[i].first->monst = m; - inkillhistory.insert(killhistory[i].first); - } - int si = isize(findhistory); - for(int i=0; iitem; - findhistory[i].first->item = m; - infindhistory.insert(findhistory[i].first); - } - } - - EX void restoreBack() { - int sk = isize(killhistory); - for(int i=sk-1; i>=0; i--) { - eMonster m = killhistory[i].second; - killhistory[i].second = killhistory[i].first->monst; - killhistory[i].first->monst = m; - } - int si = isize(findhistory); - for(int i=si-1; i>=0; i--) { - eItem m = findhistory[i].second; - findhistory[i].second = findhistory[i].first->item; - findhistory[i].first->item = m; - } - } - - EX void renderAutoband() { -#if CAP_SDL - if(!cwt.at || celldist(cwt.at) <= 7) return; - if(!autoband) return; - eModel spm = pmodel; - bool ih = includeHistory; - includeHistory = autobandhistory; - pmodel = mdBand; - create_playerpath(); - createImage(dospiral); - clear(); - pmodel = spm; - includeHistory = ih; -#endif - } - - #if CAP_COMMANDLINE - int readArgs() { - using namespace arg; - - if(0) ; - else if(argis("-els")) { - shift_arg_formula(conformal::extra_line_steps); - } - else if(argis("-stretch")) { - PHASEFROM(2); shift_arg_formula(vid.stretch); - } - else if(argis("-PM")) { - PHASEFROM(2); shift(); pmodel = eModel(argi()); - if(pmodel == mdFormula) { - shift(); basic_model = eModel(argi()); - shift(); formula = args(); - } - } - else if(argis("-ballangle")) { - PHASEFROM(2); - shift_arg_formula(vid.ballangle); - } - else if(argis("-topz")) { - PHASEFROM(2); - shift_arg_formula(conformal::top_z); - } - else if(argis("-twopoint")) { - PHASEFROM(2); - shift_arg_formula(vid.twopoint_param); - } - else if(argis("-hp")) { - PHASEFROM(2); - shift_arg_formula(conformal::halfplane_scale); - } - else if(argis("-mori")) { - PHASEFROM(2); - shift_arg_formula(conformal::model_orientation); - } - else if(argis("-mori2")) { - PHASEFROM(2); - shift_arg_formula(conformal::model_orientation); - shift_arg_formula(conformal::model_orientation_yz); - } - else if(argis("-crot")) { - PHASEFROM(2); - shift_arg_formula(conformal::rotation); - if(DIM == 3) shift_arg_formula(conformal::rotation_xz); - if(DIM == 3) shift_arg_formula(conformal::rotation_xy2); - } - else if(argis("-playerpath")) { - conformal::create_playerpath(); - } - else if(argis("-clip")) { - PHASEFROM(2); - shift_arg_formula(conformal::clip_min); - shift_arg_formula(conformal::clip_max); - } - else if(argis("-mtrans")) { - PHASEFROM(2); - shift_arg_formula(conformal::model_transition); - } - else if(argis("-sang")) { - PHASEFROM(2); - shift_arg_formula(conformal::spiral_angle); - if(sphere) - shift_arg_formula(conformal::sphere_spiral_multiplier); - else if(conformal::spiral_angle == 90) - shift_arg_formula(conformal::right_spiral_multiplier); - } - else if(argis("-ssm")) { - PHASEFROM(2); - shift_arg_formula(conformal::any_spiral_multiplier); - } - else if(argis("-scone")) { - PHASEFROM(2); - shift_arg_formula(conformal::spiral_cone); - } - else if(argis("-sxy")) { - PHASEFROM(2); - shift_arg_formula(conformal::spiral_x); - shift_arg_formula(conformal::spiral_y); - } - else if(argis("-mob")) { - PHASEFROM(2); - shift_arg_formula(vid.skiprope); - } - else if(argis("-zoom")) { - PHASEFROM(2); shift_arg_formula(vid.scale); - } - else if(argis("-alpha")) { - PHASEFROM(2); shift_arg_formula(vid.alpha); - } - else if(argis("-d:model")) - launch_dialog(model_menu); - else if(argis("-d:formula")) { - launch_dialog(); - edit_formula(); - } - else if(argis("-d:match")) { - launch_dialog(match_torus_period); - edit_formula(); - } - else return 1; - return 0; - } - - auto hookArg = addHook(hooks_args, 100, readArgs); - #endif - - auto hooks = addHook(clearmemory, 0, [] () { - conformal::renderAutoband(); - conformal::on = false; - conformal::killhistory.clear(); - conformal::findhistory.clear(); - conformal::movehistory.clear(); - conformal::path_for_lineanimation.clear(); - conformal::includeHistory = false; - }); - - } - -} +namespace hr { + +EX namespace polygonal { + + #if ISMOBWEB + typedef double precise; + #else + typedef long double precise; + #endif + + #if HDR + static const int MSI = 120; + #endif + + typedef long double xld; + + typedef complex cxld; + + EX int SI = 4; + EX ld STAR = 0; + + EX int deg = ISMOBWEB ? 2 : 20; + + precise matrix[MSI][MSI]; + precise ans[MSI]; + + cxld coef[MSI]; + EX ld coefr[MSI], coefi[MSI]; + EX int maxcoef, coefid; + + EX void solve() { + if(pmodel == mdPolynomial) { + for(int i=0; i 0 ? (1+STAR) : 1) + - sin(i0 * (j + 1./SI)) * (STAR > 0 ? STAR : STAR/(1+STAR)); + } + + for(int i=0; i=0; i--) { + for(int j=0; j compute(ld x, ld y, int prec) { + if(x*x+y*y > 1) { + xld r = hypot(x,y); + x /= r; + y /= r; + } + if(pmodel == mdPolynomial) { + cxld z(x,y); + cxld res (0,0); + for(int i=maxcoef; i>=0; i--) { res += coef[i]; if(i) res *= z; } + return make_pair(real(res), imag(res)); + } + + cxld z(x, y); + cxld res (0,0); + cxld zp = 1; for(int i=0; i0; i--) { + res += ans[i]; + res *= zp; + } + res += ans[0]; res *= z; + return make_pair(real(res), imag(res)); + } + + pair compute(ld x, ld y) { return compute(x,y,deg); } + EX } + +EX namespace models { + + EX string formula = "z^2"; + EX eModel basic_model; + + EX ld rotation = 0; + EX ld rotation_xz = 90; + EX ld rotation_xy2 = 90; + EX int do_rotate = 1; + EX ld model_orientation, halfplane_scale, model_orientation_yz; + EX ld clip_min, clip_max; + EX ld ocos, osin, ocos_yz, osin_yz; + EX ld cos_ball, sin_ball; + EX bool model_straight, model_straight_yz; + EX ld top_z = 5; + EX ld model_transition = 1; + + #if HDR + // screen coordinates to logical coordinates: apply_orientation(x,y) + // logical coordinates back to screen coordinates: apply_orientation(y,x) + template + void apply_orientation(A& x, A& y) { if(!model_straight) tie(x,y) = make_pair(x*ocos + y*osin, y*ocos - x*osin); } + template + void apply_orientation_yz(A& x, A& y) { if(!model_straight_yz) tie(x,y) = make_pair(x*ocos_yz + y*osin_yz, y*ocos_yz - x*osin_yz); } + template + void apply_ball(A& x, A& y) { tie(x,y) = make_pair(x*cos_ball + y*sin_ball, y*cos_ball - x*sin_ball); } + #endif + + EX transmatrix rotmatrix() { + if(DIM == 2) return spin(rotation * degree); + return spin(rotation_xy2 * degree) * cspin(0, 2, -rotation_xz * degree) * spin(rotation * degree); + } + + EX ld spiral_angle = 70; + EX ld spiral_x = 10; + EX ld spiral_y = 7; + int spiral_id = 7; + EX bool use_atan = false; + + cld spiral_multiplier; + ld right_spiral_multiplier = 1; + ld any_spiral_multiplier = 1; + ld sphere_spiral_multiplier = 2; + EX ld spiral_cone = 360; + ld spiral_cone_rad; + bool ring_not_spiral; + + EX void configure() { + ld ball = -vid.ballangle * degree; + cos_ball = cos(ball), sin_ball = sin(ball); + ocos = cos(model_orientation * degree); + osin = sin(model_orientation * degree); + ocos_yz = cos(model_orientation_yz * degree); + osin_yz = sin(model_orientation_yz * degree); + model_straight = (ocos > 1 - 1e-9); + model_straight_yz = DIM == 2 || (ocos_yz > 1-1e-9); + if(history::on) history::apply(); + + if(!euclid) { + ld b = spiral_angle * degree; + ld cos_spiral = cos(b); + ld sin_spiral = sin(b); + spiral_cone_rad = spiral_cone * degree; + ring_not_spiral = abs(cos_spiral) < 1e-3; + ld mul = 1; + if(sphere) mul = .5 * sphere_spiral_multiplier; + else if(ring_not_spiral) mul = right_spiral_multiplier; + else mul = any_spiral_multiplier * cos_spiral; + + spiral_multiplier = cld(cos_spiral, sin_spiral) * cld(spiral_cone_rad * mul / 2., 0); + } + if(euclid) { + hyperpoint h = tC0(eumove(spiral_x, spiral_y)); + spiral_multiplier = cld(0, 2 * M_PI) / cld(h[0], h[1]); + } + + if(centerover.at && !history::on) + if(isize(history::path_for_lineanimation) == 0 || (quotient && history::path_for_lineanimation.back() != centerover.at)) { + history::path_for_lineanimation.push_back(centerover.at); + } + + band_shift = 0; + } + + EX bool model_available(eModel pm) { + if(nonisotropic) return among(pm, mdDisk, mdPerspective, mdGeodesic); + if(pm == mdGeodesic && !sol) return false; + if(sphere && (pm == mdHalfplane || pm == mdBall)) + return false; + if(DIM == 2 && pm == mdPerspective) return false; + if(DIM == 2 && pm == mdEquivolume) return false; + if(DIM == 3 && among(pm, mdBall, mdHyperboloid, mdFormula, mdPolygonal, mdRotatedHyperboles, mdSpiral, mdHemisphere)) return false; + if(pm == mdCentralInversion && !euclid) return false; + return true; + } + + EX bool model_has_orientation() { + return + among(pmodel, mdHalfplane, mdPolynomial, mdPolygonal, mdTwoPoint, mdJoukowsky, mdJoukowskyInverted, mdSpiral, mdSimulatedPerspective, mdTwoHybrid) || mdBandAny(); + } + + EX bool model_has_transition() { + return among(pmodel, mdJoukowsky, mdJoukowskyInverted, mdBand) && DIM == 2; + } + + int editpos = 0; + + EX string get_model_name(eModel m) { + if(m == mdDisk && DIM == 3 && hyperbolic) return XLAT("ball model/Gans"); + if(nonisotropic) { + if(m == mdDisk) return XLAT("simple model: projection"); + if(m == mdPerspective) return XLAT("simple model: perspective"); + if(m == mdGeodesic) return XLAT("native perspective"); + } + if(m == mdDisk && DIM == 3) return XLAT("perspective in 4D"); + if(m == mdHalfplane && DIM == 3 && hyperbolic) return XLAT("half-space"); + if(sphere) + return XLAT(mdinf[m].name_spherical); + if(euclid) + return XLAT(mdinf[m].name_euclidean); + if(hyperbolic) + return XLAT(mdinf[m].name_hyperbolic); + return "?"; + } + + vector > torus_zeros; + + void match_torus_period() { + torus_zeros.clear(); + for(int y=0; y<=200; y++) + for(int x=-200; x<=200; x++) { + if(y == 0 && x <= 0) continue; + auto zero = vec_to_cellwalker(euclid_getvec(x, y)); + if(zero.at == currentmap->gamestart() && !zero.mirrored) + torus_zeros.emplace_back(x, y); + } + sort(torus_zeros.begin(), torus_zeros.end(), [] (const pair p1, const pair p2) { + ld d1 = hdist0(tC0(eumove(p1.first, p1.second))); + ld d2 = hdist0(tC0(eumove(p2.first, p2.second))); + if(d1 < d2 - 1e-6) return true; + if(d1 > d2 + 1e-6) return false; + return p1 < p2; + }); + if(spiral_id > isize(torus_zeros)) spiral_id = 0; + dialog::editNumber(spiral_id, 0, isize(torus_zeros)-1, 1, 10, XLAT("match the period of the torus"), ""); + dialog::reaction = [] () { + tie(spiral_x, spiral_y) = torus_zeros[spiral_id]; + }; + dialog::bound_low(0); + dialog::bound_up(isize(torus_zeros)-1); + } + + EX void edit_formula() { + if(pmodel != mdFormula) basic_model = pmodel; + dialog::edit_string(formula, "formula", + XLAT( + "This lets you specify the projection as a formula f. " + "The formula has access to the value 'z', which is a complex number corresponding to the (x,y) coordinates in the currently selected model; " + "the point z is mapped to f(z). You can also use the underlying coordinates ux, uy, uz." + ) + "\n\n" + parser_help() + ); + #if CAP_QUEUE && CAP_CURVE + dialog::extra_options = [] () { + initquickqueue(); + queuereset(mdUnchanged, PPR::LINE); + for(int a=-1; a<=1; a++) { + curvepoint(point2(-M_PI/2 * current_display->radius, a*current_display->radius)); + curvepoint(point2(+M_PI/2 * current_display->radius, a*current_display->radius)); + queuecurve(forecolor, 0, PPR::LINE); + curvepoint(point2(a*current_display->radius, -M_PI/2*current_display->radius)); + curvepoint(point2(a*current_display->radius, +M_PI/2*current_display->radius)); + queuecurve(forecolor, 0, PPR::LINE); + } + queuereset(pmodel, PPR::LINE); + quickqueue(); + }; + #endif + dialog::reaction_final = [] () { + pmodel = mdFormula; + }; + } + + EX void edit_rotation(ld& which) { + dialog::editNumber(which, 0, 360, 90, 0, XLAT("rotation"), + "This controls the automatic rotation of the world. " + "It affects the line animation in the history mode, and " + "lands which have a special direction. Note that if finding this special direction is a part of the puzzle, " + "it works only in the cheat mode."); + dialog::dialogflags |= sm::CENTER; + dialog::extra_options = [] () { + dialog::addBreak(100); + dialog::addBoolItem_choice("line animation only", models::do_rotate, 0, 'N'); + dialog::addBoolItem_choice("gravity lands", models::do_rotate, 1, 'G'); + dialog::addBoolItem_choice("all directional lands", models::do_rotate, 2, 'D'); + if(DIM == 3) { + dialog::addBreak(100); + dialog::addSelItem(XLAT("XY plane"), fts(models::rotation) + "°", 'A'); + dialog::add_action([] { popScreen(); edit_rotation(models::rotation); }); + dialog::addSelItem(XLAT("XZ plane"), fts(models::rotation_xz) + "°", 'B'); + dialog::add_action([] { popScreen(); edit_rotation(models::rotation_xz); }); + dialog::addSelItem(XLAT("XY plane #2"), fts(models::rotation_xy2) + "°", 'C'); + dialog::add_action([] { popScreen(); edit_rotation(models::rotation_xy2); }); + } + }; + } + + EX void model_menu() { + cmode = sm::SIDE | sm::MAYDARK | sm::CENTER; + gamescreen(0); + dialog::init(XLAT("models & projections")); + string chars = "0123456789!@#$%^&*()][{}'\""; + int cpos = 0; + for(int i=0; i 1e-3 && pmodel != mdBall && pmodel != mdHyperboloid && pmodel != mdHemisphere && pmodel != mdDisk) { + dialog::addBreak(50); + dialog::addInfo("NOTE: this works 'correctly' only if the Poincaré model/stereographic projection is used."); + dialog::addBreak(50); + } + + if(among(pmodel, mdDisk, mdBall, mdHyperboloid, mdRotatedHyperboles)) { + dialog::addSelItem(XLAT("projection distance"), + fts(vid.alpha) + " (" + current_proj_name() + ")", 'p'); + } + + if(model_has_orientation()) { + dialog::addSelItem(XLAT("model orientation"), fts(model_orientation) + "°", 'l'); + dialog::add_action([] () { + dialog::editNumber(model_orientation, 0, 360, 90, 0, XLAT("model orientation"), ""); + }); + if(DIM == 3) { + dialog::addSelItem(XLAT("model orientation (y/z plane)"), fts(model_orientation_yz) + "°", 'L'); + dialog::add_action([] () { + dialog::editNumber(model_orientation_yz, 0, 360, 90, 0, XLAT("model orientation (y/z plane)"), ""); + }); + } + } + + if(DIM == 3 && pmodel != mdPerspective) { + const string cliphelp = XLAT( + "Your view of the 3D model is naturally bounded from four directions by your window. " + "Here, you can also set up similar bounds in the Z direction. Radius of the ball/band " + "models, and the distance from the center to the plane in the halfspace model, are 1.\n\n"); + dialog::addSelItem(XLAT("near clipping plane"), fts(clip_max), 'c'); + dialog::add_action([cliphelp] () { + dialog::editNumber(clip_max, -10, 10, 0.2, 1, XLAT("near clipping plane"), + cliphelp + XLAT("Objects with Z coordinate " + "bigger than this parameter are not shown. This is useful with the models which " + "extend infinitely in the Z direction, or if you want things close to your character " + "to be not obscured by things closer to the camera.")); + }); + dialog::addSelItem(XLAT("far clipping plane"), fts(clip_min), 'C'); + dialog::add_action([cliphelp] () { + dialog::editNumber(clip_min, -10, 10, 0.2, -1, XLAT("far clipping plane"), + cliphelp + XLAT("Objects with Z coordinate " + "smaller than this parameter are not shown; it also affects the fog effect" + " (near clipping plane = 0% fog, far clipping plane = 100% fog).")); + }); + } + + if(pmodel == mdPolynomial) { + dialog::addSelItem(XLAT("coefficient"), + fts(polygonal::coefr[polygonal::coefid]), 'x'); + dialog::add_action([] () { + polygonal::maxcoef = max(polygonal::maxcoef, polygonal::coefid); + int ci = polygonal::coefid + 1; + dialog::editNumber(polygonal::coefr[polygonal::coefid], -10, 10, .01/ci/ci, 0, XLAT("coefficient"), ""); + }); + dialog::addSelItem(XLAT("coefficient (imaginary)"), + fts(polygonal::coefi[polygonal::coefid]), 'y'); + dialog::add_action([] () { + polygonal::maxcoef = max(polygonal::maxcoef, polygonal::coefid); + int ci = polygonal::coefid + 1; + dialog::editNumber(polygonal::coefi[polygonal::coefid], -10, 10, .01/ci/ci, 0, XLAT("coefficient (imaginary)"), ""); + }); + dialog::addSelItem(XLAT("which coefficient"), its(polygonal::coefid), 'n'); + dialog::add_action([] () { + dialog::editNumber(polygonal::coefid, 0, polygonal::MSI-1, 1, 0, XLAT("which coefficient"), ""); + dialog::bound_low(0); dialog::bound_up(polygonal::MSI-1); + }); + } + + if(pmodel == mdHalfplane) { + dialog::addSelItem(XLAT("half-plane scale"), fts(halfplane_scale), 'b'); + dialog::add_action([] () { + dialog::editNumber(halfplane_scale, 0, 2, 0.25, 1, XLAT("half-plane scale"), ""); + }); + } + + if(pmodel == mdRotatedHyperboles) { + dialog::addBoolItem_action(XLAT("use atan to make it finite"), use_atan, 'x'); + } + + if(pmodel == mdBall) { + dialog::addSelItem(XLAT("projection in ball model"), fts(vid.ballproj), 'x'); + dialog::add_action([] () { + dialog::editNumber(vid.ballproj, 0, 100, .1, 0, XLAT("projection in ball model"), + "This parameter affects the ball model the same way as the projection parameter affects the disk model."); + }); + } + + if(pmodel == mdPolygonal) { + dialog::addSelItem(XLAT("polygon sides"), its(polygonal::SI), 'x'); + dialog::add_action([] () { + dialog::editNumber(polygonal::SI, 3, 10, 1, 4, XLAT("polygon sides"), ""); + dialog::reaction = polygonal::solve; + }); + dialog::addSelItem(XLAT("star factor"), fts(polygonal::STAR), 'y'); + dialog::add_action([]() { + dialog::editNumber(polygonal::STAR, -1, 1, .1, 0, XLAT("star factor"), ""); + dialog::reaction = polygonal::solve; + }); + dialog::addSelItem(XLAT("degree of the approximation"), its(polygonal::deg), 'n'); + dialog::add_action([](){ + dialog::editNumber(polygonal::deg, 2, polygonal::MSI-1, 1, 2, XLAT("degree of the approximation"), ""); + dialog::reaction = polygonal::solve; + dialog::bound_low(0); dialog::bound_up(polygonal::MSI-1); + }); + } + + if(pmodel == mdBall || pmodel == mdHyperboloid || pmodel == mdHemisphere || (pmodel == mdSpiral && spiral_cone != 360)) { + dialog::addSelItem(XLAT("camera rotation in 3D models"), fts(vid.ballangle) + "°", 'b'); + dialog::add_action(config_camera_rotation); + } + + if(pmodel == mdHyperboloid) { + dialog::addSelItem(XLAT("maximum z coordinate to show"), fts(top_z), 'l'); + dialog::add_action([](){ + dialog::editNumber(top_z, 1, 20, 0.25, 4, XLAT("maximum z coordinate to show"), ""); + }); + } + + if(model_has_transition()) { + dialog::addSelItem(XLAT("model transition"), fts(model_transition), 't'); + dialog::add_action([]() { + dialog::editNumber(model_transition, 0, 1, 0.1, 1, XLAT("model transition"), + "You can change this parameter for a transition from another model to this one." + ); + }); + } + + if(among(pmodel, mdJoukowsky, mdJoukowskyInverted, mdSpiral) && DIM == 2) { + dialog::addSelItem(XLAT("Möbius transformations"), fts(vid.skiprope) + "°", 'S'); + dialog::add_action([](){ + dialog::editNumber(vid.skiprope, 0, 360, 15, 0, XLAT("Möbius transformations"), ""); + }); + } + + if(pmodel == mdHemisphere && euclid) { + dialog::addSelItem(XLAT("parameter"), fts(vid.euclid_to_sphere), 'l'); + dialog::add_action([] () { + dialog::editNumber(vid.euclid_to_sphere, 0, 10, .1, 1, XLAT("parameter"), + "Stereographic projection to a sphere. Choose the radius of the sphere." + ); + dialog::scaleLog(); + }); + } + + if(among(pmodel, mdTwoPoint, mdSimulatedPerspective, mdTwoHybrid)) { + dialog::addSelItem(XLAT("parameter"), fts(vid.twopoint_param), 'b'); + dialog::add_action([](){ + dialog::editNumber(vid.twopoint_param, 1e-3, 10, .1, 1, XLAT("parameter"), + "This model maps the world so that the distances from two points " + "are kept. This parameter gives the distance from the two points to " + "the center." + ); + dialog::scaleLog(); + }); + } + + if(pmodel == mdSpiral && !euclid) { + dialog::addSelItem(XLAT("spiral angle"), fts(spiral_angle) + "°", 'x'); + dialog::add_action([](){ + dialog::editNumber(spiral_angle, 0, 360, 15, 0, XLAT("spiral angle"), + XLAT("set to 90° for the ring projection") + ); + }); + + ld& which = + sphere ? sphere_spiral_multiplier : + ring_not_spiral ? right_spiral_multiplier : + any_spiral_multiplier; + + dialog::addSelItem(XLAT("spiral multiplier"), fts(which) + "°", 'M'); + dialog::add_action([&which](){ + dialog::editNumber(which, 0, 10, -.1, 1, XLAT("spiral multiplier"), + XLAT( + "This parameter has a bit different scale depending on the settings:\n" + "(1) in spherical geometry (with spiral angle=90°, 1 produces a stereographic projection)\n" + "(2) in hyperbolic geometry, with spiral angle being +90° or -90°\n" + "(3) in hyperbolic geometry, with other spiral angles (1 makes the bands fit exactly)" + ) + ); + }); + + dialog::addSelItem(XLAT("spiral cone"), fts(spiral_cone) + "°", 'C'); + dialog::add_action([](){ + dialog::editNumber(spiral_cone, 0, 360, -45, 360, XLAT("spiral cone"), ""); + }); + } + + if(pmodel == mdSpiral && euclid) { + dialog::addSelItem(XLAT("spiral period: x"), fts(spiral_x), 'x'); + dialog::add_action([](){ + dialog::editNumber(spiral_x, -20, 20, 1, 10, XLAT("spiral period: x"), ""); + }); + dialog::addSelItem(XLAT("spiral period: y"), fts(spiral_y), 'y'); + dialog::add_action([](){ + dialog::editNumber(spiral_y, -20, 20, 1, 10, XLAT("spiral period: y"), ""); + }); + if(euwrap) { + dialog::addSelItem(XLAT("match the period"), its(spiral_id), 'n'); + dialog::add_action(match_torus_period); + } + } + + dialog::addSelItem(XLAT("vertical stretch"), fts(vid.stretch), 's'); + + dialog::addBoolItem(XLAT("use GPU to compute projections"), vid.consider_shader_projection, 'G'); + if(vid.consider_shader_projection && !shaderside_projection) + dialog::lastItem().value = XLAT("N/A"); + if(vid.consider_shader_projection && shaderside_projection && pmodel) + dialog::lastItem().value += XLAT(" (2D only)"); + dialog::add_action([] { vid.consider_shader_projection = !vid.consider_shader_projection; }); + + menuitem_sightrange('R'); + + dialog::addBreak(100); + dialog::addItem(XLAT("history mode"), 'a'); +#if CAP_RUG + if(GDIM == 2) dialog::addItem(XLAT("hypersian rug mode"), 'u'); +#endif + dialog::addBack(); + + dialog::display(); + mouseovers = XLAT("see http://www.roguetemple.com/z/hyper/models.php"); + + keyhandler = [] (int sym, int uni) { + dialog::handleNavigation(sym, uni); + + if(uni == 'z') + editScale(); + else if(uni == 'p') + projectionDialog(); +#if CAP_RUG + else if(uni == 'u' && DIM == 2) + pushScreen(rug::show); +#endif + else if(uni == 's') { + dialog::editNumber(vid.stretch, 0, 10, .1, 1, XLAT("vertical stretch"), + "Vertical stretch factor." + ); + dialog::extra_options = [] () { + dialog::addBreak(100); + if(sphere && pmodel == mdBandEquiarea) { + dialog::addBoolItem("Gall-Peters", vid.stretch == 2, 'O'); + dialog::add_action([] { vid.stretch = 2; dialog::ne.s = "2"; }); + } + if(pmodel == mdBandEquiarea) { + // y = K * sin(phi) + // cos(phi) * cos(phi) = 1/K + if(sphere && vid.stretch >= 1) { + ld phi = acos(sqrt(1/vid.stretch)); + dialog::addInfo(XLAT("The current value makes the map conformal at the latitude of %1 (%2°).", fts(phi), fts(phi / degree))); + } + else if(hyperbolic && abs(vid.stretch) <= 1 && abs(vid.stretch) >= 1e-9) { + ld phi = acosh(abs(sqrt(1/vid.stretch))); + dialog::addInfo(XLAT("The current value makes the map conformal %1 units from the main line.", fts(phi))); + } + else dialog::addInfo(""); + } + }; + } + else if(uni == 'a') + pushScreen(history::history_menu); + else if(doexiton(sym, uni)) popScreen(); + }; + } + + #if CAP_COMMANDLINE + int readArgs() { + using namespace arg; + + if(0) ; + else if(argis("-els")) { + shift_arg_formula(history::extra_line_steps); + } + else if(argis("-stretch")) { + PHASEFROM(2); shift_arg_formula(vid.stretch); + } + else if(argis("-PM")) { + PHASEFROM(2); shift(); pmodel = eModel(argi()); + if(pmodel == mdFormula) { + shift(); basic_model = eModel(argi()); + shift(); formula = args(); + } + } + else if(argis("-ballangle")) { + PHASEFROM(2); + shift_arg_formula(vid.ballangle); + } + else if(argis("-topz")) { + PHASEFROM(2); + shift_arg_formula(models::top_z); + } + else if(argis("-twopoint")) { + PHASEFROM(2); + shift_arg_formula(vid.twopoint_param); + } + else if(argis("-hp")) { + PHASEFROM(2); + shift_arg_formula(models::halfplane_scale); + } + else if(argis("-mori")) { + PHASEFROM(2); + shift_arg_formula(models::model_orientation); + } + else if(argis("-mori2")) { + PHASEFROM(2); + shift_arg_formula(models::model_orientation); + shift_arg_formula(models::model_orientation_yz); + } + else if(argis("-crot")) { + PHASEFROM(2); + shift_arg_formula(models::rotation); + if(DIM == 3) shift_arg_formula(models::rotation_xz); + if(DIM == 3) shift_arg_formula(models::rotation_xy2); + } + else if(argis("-clip")) { + PHASEFROM(2); + shift_arg_formula(models::clip_min); + shift_arg_formula(models::clip_max); + } + else if(argis("-mtrans")) { + PHASEFROM(2); + shift_arg_formula(models::model_transition); + } + else if(argis("-sang")) { + PHASEFROM(2); + shift_arg_formula(models::spiral_angle); + if(sphere) + shift_arg_formula(models::sphere_spiral_multiplier); + else if(models::spiral_angle == 90) + shift_arg_formula(models::right_spiral_multiplier); + } + else if(argis("-ssm")) { + PHASEFROM(2); + shift_arg_formula(models::any_spiral_multiplier); + } + else if(argis("-scone")) { + PHASEFROM(2); + shift_arg_formula(models::spiral_cone); + } + else if(argis("-sxy")) { + PHASEFROM(2); + shift_arg_formula(models::spiral_x); + shift_arg_formula(models::spiral_y); + } + else if(argis("-mob")) { + PHASEFROM(2); + shift_arg_formula(vid.skiprope); + } + else if(argis("-zoom")) { + PHASEFROM(2); shift_arg_formula(vid.scale); + } + else if(argis("-alpha")) { + PHASEFROM(2); shift_arg_formula(vid.alpha); + } + else if(argis("-d:model")) + launch_dialog(model_menu); + else if(argis("-d:formula")) { + launch_dialog(); + edit_formula(); + } + else if(argis("-d:match")) { + launch_dialog(match_torus_period); + edit_formula(); + } + else return 1; + return 0; + } + + auto hookArg = addHook(hooks_args, 100, readArgs); + #endif + } + +} \ No newline at end of file diff --git a/quit.cpp b/quit.cpp index 77e0c8e3..de0e06b1 100644 --- a/quit.cpp +++ b/quit.cpp @@ -147,7 +147,7 @@ hint hints[] = { dialog::addItem(XLAT("special display modes"), 'z'); }, []() { - pushScreen(conformal::model_menu); + pushScreen(models::model_menu); }}, { @@ -212,15 +212,15 @@ hint hints[] = { popScreen(); auto m = pmodel; pmodel = mdBand; - int r = conformal::rotation; - bool h = conformal::includeHistory; - conformal::rotation = 0; - conformal::includeHistory = true; - conformal::create_playerpath(); + int r = models::rotation; + bool h = history::includeHistory; + models::rotation = 0; + history::includeHistory = true; + history::create_playerpath(); cancel = [m,r,h] () { - conformal::clear(); pmodel = m; - conformal::rotation = r; - conformal::includeHistory = h; + history::clear(); pmodel = m; + models::rotation = r; + history::includeHistory = h; fullcenter(); }; } }, diff --git a/racing.cpp b/racing.cpp index 22101bea..4715fb31 100644 --- a/racing.cpp +++ b/racing.cpp @@ -771,8 +771,8 @@ void restore_time(int t) { bool akh(int sym, int uni) { if(uni == '1') { tstart = ticks; sview = viewctr; } else if(uni == '2') { tstop = ticks; } - else if(uni == '3') { conformal::model_orientation = 90; pmodel = mdBand; player_relative = false; } - else if(uni == '4') { conformal::model_orientation = 180; pmodel = mdHalfplane; conformal::halfplane_scale = 2; player_relative = false; } + else if(uni == '3') { models::model_orientation = 90; pmodel = mdBand; player_relative = false; } + else if(uni == '4') { models::model_orientation = 180; pmodel = mdHalfplane; models::halfplane_scale = 2; player_relative = false; } else if(uni == '5') { pmodel = mdDisk; player_relative = true; } else if(uni == '6') { vid.use_smart_range = true; vid.smart_range_detail = 2; } else if(uni == '7' && tstart && tstop) { @@ -932,7 +932,7 @@ void race_projection() { dialog::addBoolItem(XLAT("band"), pmodel == mdBand, '2'); dialog::add_action([] () { pmodel = mdBand; - conformal::model_orientation = race_angle; + models::model_orientation = race_angle; race_advance = 1; vid.yshift = 0; vid.camera_angle = 0; @@ -946,7 +946,7 @@ void race_projection() { dialog::addBoolItem(XLAT("half-plane"), pmodel == mdHalfplane, '3'); dialog::add_action([] () { pmodel = mdHalfplane; - conformal::model_orientation = race_angle + 90; + models::model_orientation = race_angle + 90; race_advance = 0.5; vid.yshift = 0; vid.camera_angle = 0; @@ -988,8 +988,8 @@ void race_projection() { dialog::addSelItem(XLAT("race angle"), fts(race_angle), 'a'); dialog::add_action([] () { dialog::editNumber(race_angle, 0, 360, 15, 90, XLAT("race angle"), ""); - int q = conformal::model_orientation - race_angle; - dialog::reaction = [q] () { conformal::model_orientation = race_angle + q; }; + int q = models::model_orientation - race_angle; + dialog::reaction = [q] () { models::model_orientation = race_angle + q; }; }); } diff --git a/rogueviz-video.cpp b/rogueviz-video.cpp index a828c3a5..ca0c76ba 100644 --- a/rogueviz-video.cpp +++ b/rogueviz-video.cpp @@ -19,7 +19,7 @@ void rvvideo(const string &fname) { collatz::lookup(763, 60); - conformal::create_playerpath(), conformal::rotation = 1; + history::create_playerpath(), models::rotation = 1; // pmodel = mdBand; #define STORYCOUNT 24 @@ -98,8 +98,8 @@ struct storydata { int s; int e; const char *text; } story[] = { vid.grid = drawnet; - conformal::phase = 1 + (isize(conformal::v)-3) * i * .95 / FRAMECOUNT; - conformal::movetophase(); + history::phase = 1 + (isize(history::v)-3) * i * .95 / FRAMECOUNT; + history::movetophase(); char buf[500]; snprintf(buf, 500, fname.c_str(), i); diff --git a/rug.cpp b/rug.cpp index b82dc852..9ffc828b 100644 --- a/rug.cpp +++ b/rug.cpp @@ -378,7 +378,7 @@ void buildTorusRug() { using namespace torusconfig; calcparam_rug(); - conformal::configure(); + models::configure(); struct toruspoint { int x,y; @@ -1281,7 +1281,7 @@ void prepareTexture() { dynamicval d(vid.stereo_mode, sOFF); calcparam_rug(); - conformal::configure(); + models::configure(); glbuf->enable(); glbuf->clear(0); @@ -1788,7 +1788,7 @@ hyperpoint gethyper(ld x, ld y) { double px = rx1 * TEXTURESIZE, py = (1-ry1) * TEXTURESIZE; calcparam_rug(); - conformal::configure(); + models::configure(); hyperpoint h = hr::gethyper(px, py); calcparam(); diff --git a/screenshot.cpp b/screenshot.cpp index fb9a3c4c..b9ebbd1e 100644 --- a/screenshot.cpp +++ b/screenshot.cpp @@ -321,7 +321,7 @@ void take(string fname, const function& what) { vid.xres = shotx * multiplier; vid.yres = shoty * multiplier; calcparam(); - conformal::configure(); + models::configure(); if(make_svg) { #if CAP_SVG @@ -583,9 +583,9 @@ EX void apply() { switch(ma) { case maTranslation: - if(conformal::on) { - conformal::phase = (isize(conformal::v) - 1) * ticks * 1. / period; - conformal::movetophase(); + if(history::on) { + history::phase = (isize(history::v) - 1) * ticks * 1. / period; + history::movetophase(); } else if(centerover.at) { reflect_view(); @@ -681,8 +681,8 @@ EX void apply() { vid.skiprope += skiprope_rotation * t * 2 * M_PI / period; if(ballangle_rotation) { - if(conformal::model_has_orientation()) - conformal::model_orientation += ballangle_rotation * 360 * t / period; + if(models::model_has_orientation()) + models::model_orientation += ballangle_rotation * 360 * t / period; else vid.ballangle += ballangle_rotation * 360 * t / period; } @@ -690,11 +690,11 @@ EX void apply() { ld t = ticks / period; t = t - floor(t); if(pmodel == mdBand) { - conformal::model_transition = t * 4 - 1; + models::model_transition = t * 4 - 1; } else { - conformal::model_transition = t / 1.1; - vid.scale = (1 - conformal::model_transition) / 2.; + models::model_transition = t / 1.1; + vid.scale = (1 - models::model_transition) / 2.; } } apply_animated_parameters(); @@ -724,13 +724,13 @@ bool record_animation() { if(playermoved) centerpc(INF), optimizeview(); dynamicval v2(inHighQual, true); apply(); - conformal::configure(); - if(conformal::on) { - ld len = (isize(conformal::v)-1) + 2 * conformal::extra_line_steps; - conformal::phase = len * i / (noframes-1); - if(conformal::lvspeed < 0) conformal::phase = len - conformal::phase; - conformal::phase -= conformal::extra_line_steps; - conformal::movetophase(); + models::configure(); + if(history::on) { + ld len = (isize(history::v)-1) + 2 * history::extra_line_steps; + history::phase = len * i / (noframes-1); + if(history::lvspeed < 0) history::phase = len - history::phase; + history::phase -= history::extra_line_steps; + history::movetophase(); } char buf[1000]; @@ -874,7 +874,7 @@ EX void show() { case maTranslation: case maTranslationRotation: case maParabolic: { - if(ma == maTranslation && conformal::on) + if(ma == maTranslation && history::on) dialog::addBreak(300); else if(ma == maTranslation) { dialog::addSelItem(XLAT("cycle length"), fts(cycle_length), 'c'); @@ -951,7 +951,7 @@ EX void show() { }); } #endif - if(conformal::model_has_orientation()) + if(models::model_has_orientation()) animator(XLAT("model rotation"), ballangle_rotation, 'I'); else if(among(pmodel, mdHyperboloid, mdHemisphere, mdBall)) animator(XLAT("3D rotation"), ballangle_rotation, '3'); @@ -968,8 +968,8 @@ EX void show() { dialog::extra_options = list_animated_parameters; }); - dialog::addBoolItem(XLAT("history mode"), (conformal::on || conformal::includeHistory), 'h'); - dialog::add_action_push(conformal::history_menu); + dialog::addBoolItem(XLAT("history mode"), (history::on || history::includeHistory), 'h'); + dialog::add_action_push(history::history_menu); #if CAP_FILES && CAP_SHOT dialog::addItem(XLAT("shot settings"), 's'); @@ -1081,7 +1081,7 @@ auto animhook = addHook(hooks_frame, 100, display_animation) ; EX bool any_animation() { - if(conformal::on) return true; + if(history::on) return true; if(ma) return true; if(ballangle_rotation || rug_rotation1 || rug_rotation2) return true; if(ap_changes) return true; @@ -1089,7 +1089,7 @@ EX bool any_animation() { } EX bool any_on() { - return any_animation() || conformal::includeHistory; + return any_animation() || history::includeHistory; } EX bool center_music() { @@ -1109,19 +1109,19 @@ EX void null_animation() { void joukowsky() { dynamicval dm(pmodel, mdJoukowskyInverted); - dynamicval dt(conformal::model_orientation, ticks / 25.); + dynamicval dt(models::model_orientation, ticks / 25.); dynamicval dv(vid.use_smart_range, 2); dynamicval ds(vid.scale, 1/4.); - conformal::configure(); + models::configure(); dynamicval dc(ringcolor, 0); gamescreen(2); } void bandspin() { dynamicval dm(pmodel, mdBand); - dynamicval dt(conformal::model_orientation, ticks / 25.); + dynamicval dt(models::model_orientation, ticks / 25.); dynamicval dv(vid.use_smart_range, 2); - conformal::configure(); + models::configure(); gamescreen(2); } diff --git a/surface.cpp b/surface.cpp index 6d642728..2b523f48 100644 --- a/surface.cpp +++ b/surface.cpp @@ -496,7 +496,7 @@ void run_kuen() { for(auto p: mesh) { auto px = map_to_surface(p->h, m); p->surface_point = px; - conformal::progress(XLAT("solving the geodesics on: %1, %2/%3", XLAT(captions[part]), its(p->dexp_id), its(isize(mesh)))); + history::progress(XLAT("solving the geodesics on: %1, %2/%3", XLAT(captions[part]), its(p->dexp_id), its(isize(mesh)))); } for(auto p: mesh) { // make it a bit nicer by including the edges where only one endpoint is valid @@ -568,7 +568,7 @@ void run_other() { p->surface_point = map_to_surface(h, dp); p->flat = coord(p->surface_point.params); - conformal::progress(XLAT("solving the geodesics on: %1, %2/%3", XLAT(shape_name[sh]), its(it), its(isize(rug::points)))); + history::progress(XLAT("solving the geodesics on: %1, %2/%3", XLAT(shape_name[sh]), its(it), its(isize(rug::points)))); if(p->surface_point.remaining_distance == 0) coverage.emplace_back(h, rchar(it) + 256 * 7); } @@ -597,7 +597,7 @@ EX void run_shape(eShape s) { rug::init(); // if(!rug::rugged) rug::reopen(); - pushScreen(conformal::progress_screen); + pushScreen(history::progress_screen); if(sh != dsNone) rug::good_shape = true; switch(sh) { diff --git a/textures.cpp b/textures.cpp index 547afff7..c58585d9 100644 --- a/textures.cpp +++ b/textures.cpp @@ -1060,7 +1060,7 @@ bool texture_config::load() { if(!data.readtexture(texturename)) return false; if(!data.loadTextureGL()) return false; calcparam(); - conformal::configure(); + models::configure(); drawthemap(); config.tstate = config.tstate_max = tsActive; string s = move(texture_tuner); @@ -1582,7 +1582,7 @@ EX void drawLine(hyperpoint h1, hyperpoint h2, color_t col, int steps IS(10)) { } void texture_config::true_remap() { - conformal::configure(); + models::configure(); drawthemap(); if(DIM == 3) return; clear_texture_map(); @@ -1644,7 +1644,7 @@ void texture_config::remap() { else if(tstate == tsAdjusting) { printf("perform_mapping %d/%d\n", config.tstate, config.tstate_max); calcparam(); - conformal::configure(); + models::configure(); drawthemap(); perform_mapping(); finish_mapping(); diff --git a/tour.cpp b/tour.cpp index 82e91b5a..29374d35 100644 --- a/tour.cpp +++ b/tour.cpp @@ -243,7 +243,7 @@ bool handleKeyTour(int sym, int uni) { return true; } if(NUMBERKEY == '8') { - conformal::includeHistory = !conformal::includeHistory; + history::includeHistory = !history::includeHistory; return true; } if(NUMBERKEY == '9') { @@ -588,8 +588,8 @@ slide default_slides[] = { if(mode == 1) pmodel = mdHalfplane, smart = vid.use_smart_range, vid.use_smart_range = 2; if(mode == 2) - conformal::rotation = cwt.at->land == laDungeon ? 0 : 2; - if(mode == 3) pmodel = mdDisk, conformal::rotation = 0, vid.use_smart_range = smart; + models::rotation = cwt.at->land == laDungeon ? 0 : 2; + if(mode == 3) pmodel = mdDisk, models::rotation = 0, vid.use_smart_range = smart; } }, {"Curvature", 29, LEGAL_ANY, @@ -737,21 +737,21 @@ slide default_slides[] = { "memory.", [] (presmode mode) { static int smart; - if(mode == 1) pmodel = mdBand, conformal::create_playerpath(), conformal::rotation = 0, + if(mode == 1) pmodel = mdBand, history::create_playerpath(), models::rotation = 0, smart = vid.use_smart_range, vid.use_smart_range = 2; if(mode == 3) { - conformal::clear(), pmodel = mdDisk; + history::clear(), pmodel = mdDisk; resetview(); drawthemap(); centerpc(INF); - conformal::includeHistory = false; + history::includeHistory = false; vid.use_smart_range = smart; } #if CAP_SDL slidecommand = "render spiral"; - if(mode == 4) conformal::createImage(true); - if(mode == 11) conformal::create_playerpath(); - if(mode == 13) conformal::clear(); + if(mode == 4) history::createImage(true); + if(mode == 11) history::create_playerpath(); + if(mode == 13) history::clear(); #endif } },