diff --git a/floorshapes.cpp b/floorshapes.cpp index daf0ef24..69bbb8cc 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -493,19 +493,21 @@ namespace irr { void generate_floorshapes() { if(irr::cells.empty()) return; + + int cc = isize(irr::cells); for(auto pfsh: all_escher_floorshapes) { auto& fsh = *pfsh; generate_matrices_scale(1, fsh.noftype); - auto& m = hept_matrices; /* if(siid == 0) for(auto& ma: m.v) ma.first = ma.first * pispin; */ - fsh.b.resize(irr::cellcount); + fsh.b.resize(cc); - for(int id=0; id cornerlist; int cor = isize(vs.vertices); - for(int j=0; j 0; if(!nonbitrunc) return true; if((S7 & 1) == 0) return true; if(!gp::on) return false; diff --git a/hyper.h b/hyper.h index ecfc23ea..2e8d95bb 100644 --- a/hyper.h +++ b/hyper.h @@ -2602,6 +2602,7 @@ namespace irr { void visual_creator(); unsigned char density_code(); int celldist(cell *c, bool alts); + extern int bitruncations_requested, bitruncations_performed; } extern hrmap *currentmap; diff --git a/hyperpoint.cpp b/hyperpoint.cpp index 02eb39b1..b46c4c9b 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -615,4 +615,9 @@ hyperpoint mid_at(hyperpoint h1, hyperpoint h2, ld v) { return mid(h, h); } +hyperpoint mid_at_actual(hyperpoint h, ld v) { + using namespace hyperpoint_vec; + return rspintox(h) * xpush(hdist0(h) * v) * C0; + } + } diff --git a/irregular.cpp b/irregular.cpp index 286fc0a2..e5a893ff 100644 --- a/irregular.cpp +++ b/irregular.cpp @@ -97,6 +97,130 @@ bool gridmaking; int rearrange_index; +bool cell_sorting; + +int bitruncations_requested = 1, bitruncations_performed = 0; + +int black_adjacent, white_three; + +void set_relmatrices(cellinfo& ci) { + auto& all = base->allcells(); + ci.relmatrices.clear(); + for(auto c0: all) ci.relmatrices[c0] = shmup::calc_relative_matrix(c0, ci.owner, ci.p); + } + +void rebase(cellinfo& ci) { + cell *cx = ci.owner; + shmup::virtualRebase(ci.owner, ci.p, false); + if(ci.owner != cx) { + printf("rebased %p to %p\n", cx, ci.owner); + set_relmatrices(ci); + } + } + +void compute_jpoints() { + for(int i=0; i, int> bitruncated_id; + for(int i=0; i newnei; + for(int j=0; j= rearrange_max_attempts) { runlevel = 0; break; } - int tooshort = 0; - for(int i=0; iallcells(); - fprintf(f, "%d %d %d\n", geometry, isize(all), cellcount); + fprintf(f, "%d %d %d\n", geometry, isize(all), isize(cells)); for(auto h: all) { fprintf(f, "%d\n", isize(cells_of_heptagon[h->master])); @@ -752,13 +882,20 @@ void cancel_map_creation() { string irrmapfile = "irregularmap.txt"; +string irrhelp = + "This option creates irregular grids to play the game on. " + "Currently rather slow algorithms are used, " + "so not recommended with too high density or " + "with too large periodic base geometry. " + "For technical reasons, the density cannot be too small."; + void show_gridmaker() { cmode = sm::SIDE; gamescreen(0); dialog::init(XLAT("irregular grid")); dialog::addSelItem(XLAT("density"), fts(density), 'd'); dialog::add_action([] { - dialog::editNumber(density, 1, 10, .1, 4, "density", ""); + dialog::editNumber(density, 1, 10, .1, 4, XLAT("density"), XLAT(irrhelp)); dialog::reaction = [] () { int s = cellcount; if(density < 1) density = 1; @@ -770,7 +907,10 @@ void show_gridmaker() { }); dialog::addSelItem(XLAT("min edge to median"), fts(quality), 'q'); dialog::add_action([] { - dialog::editNumber(quality, 0, 1, .1, 4, XLAT("quality"), ""); + dialog::editNumber(quality, 0, 1, .05, .2, XLAT("quality"), XLAT( + "The smallest allowed ratio of edge length to median edge length. " + "Tilings with low values are easier to generate, but tend to be more ugly." + )); dialog::reaction = [] () { printf("quality = %lf\n", double(density)); if(runlevel > 4) runlevel = 4; @@ -810,18 +950,22 @@ void show_gridmaker() { } }); }); + dialog::addSelItem(XLAT("bitruncation count"), its(bitruncations_requested), 'b'); + dialog::add_action([] () { + dialog::editNumber(bitruncations_requested, 0, 5, 1, 1, XLAT("bitruncation const"), + XLAT("Bitruncation introduces some regularity, allowing more sophisiticated floor tilings and textures.")); + dialog::reaction = [] () { + if(bitruncations_requested > bitruncations_performed && runlevel > 5) runlevel = 5; + if(bitruncations_requested < bitruncations_performed) runlevel = 0; + }; + }); dialog::addItem(XLAT("reset"), 'r'); dialog::add_action([] () { runlevel = 0; }); dialog::addHelp(); dialog::display(); keyhandler = [] (int sym, int uni) { - if(uni == 'h' || sym == SDLK_F1) gotoHelp(XLAT( - "This option creates irregular grids to play the game on. " - "Currently rather slow algorithms are used, " - "so not recommended with too high density or " - "with too large periodic base geometry. " - "For technical reasons, the density cannot be too small." - )); + handlePanning(sym, uni); + if(uni == 'h' || sym == SDLK_F1) gotoHelp(XLAT(irrhelp)); dialog::handleNavigation(sym, uni); // no exit }; @@ -859,6 +1003,7 @@ void visual_creator() { void auto_creator() { irr::on = false; int cc = cellcount; + bitruncations_requested = bitruncations_performed; visual_creator(); cellcount = cc; density = cc * 1. / isize(base->allcells()); printf("Creating the irregular map automatically...\n"); @@ -877,6 +1022,10 @@ int readArgs() { visual_creator(); showstartmenu = false; } + else if(argis("-irrdens")) { + PHASE(2); + shift(); density = argf(); + } else if(argis("-irrload")) { PHASE(3); restart_game(); @@ -893,9 +1042,9 @@ int readArgs() { #endif unsigned char density_code() { - if(cellcount < 128) return cellcount; + if(isize(cells) < 128) return isize(cells); else { - int t = 127, a = cellcount; + int t = 127, a = isize(cells); while(a > 127) a = a * 9/10, t++; return t; } diff --git a/landlock.cpp b/landlock.cpp index 105c4afb..db07e246 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -1159,7 +1159,7 @@ land_validity_t& land_validity(eLand l) { if(isWarped(l) && a4 && gp::on) return dont_work; - if((isWarped(l) || l == laDual) && irr::on) + if((isWarped(l) || l == laDual) && irr::on && !irr::bitruncations_performed) return dont_work; if(irr::on && among(l, laPrairie, laBlizzard, laVolcano, laMirror, laMirrorOld)) diff --git a/pattern2.cpp b/pattern2.cpp index af0b1446..030755f3 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -1042,7 +1042,7 @@ int geosupport_threecolor() { int geosupport_graveyard() { // always works in bitrunc geometries if(!nonbitrunc) return 2; - if(irr::on) return 0; + if(irr::on) return irr::bitruncations_performed ? 2 : 1; // always works in patterns supporting three-color int tc = max(geosupport_threecolor(), gp_threecolor()); @@ -1182,7 +1182,7 @@ bool warptype(cell *c) { else return c->master->distance & 1; } - else if(gp::on) + else if(gp::on || irr::on) return pseudohept(c); else return pattern_threecolor(c) == 0; diff --git a/system.cpp b/system.cpp index d63e6679..f19dab09 100644 --- a/system.cpp +++ b/system.cpp @@ -300,7 +300,7 @@ bool havesave = true; #if CAP_SAVE #define MAXBOX 500 -#define POSSCORE 354 // update this when new boxes are added! +#define POSSCORE 355 // update this when new boxes are added! struct score { string ver; @@ -699,6 +699,8 @@ void applyBoxes() { list_invorb(); + applyBox(irr::bitruncations_performed); + if(POSSCORE != boxid) printf("ERROR: %d boxes\n", boxid); }