irr:: Euclidean guarding

This commit is contained in:
Zeno Rogue 2019-11-30 16:00:23 +01:00
parent b8cf027b7a
commit f69ea5ec8d
3 changed files with 27 additions and 1 deletions

View File

@ -33,6 +33,7 @@ EX namespace euclid3 {
#endif
EX coord euzero = coord(0,0,0);
EX intmatrix euzeroall = make_array<coord>(euzero, euzero, euzero);
static const intmatrix main_axes = make_array<coord>(coord(1,0,0), coord(0,1,0), coord(0,0,1));
@ -445,7 +446,7 @@ EX namespace euclid3 {
}
EX intmatrix make_quarter_turn(int a, int b, int c) {
intmatrix T0 = make_array<coord> (euzero, euzero, euzero);
intmatrix T0 = euzeroall;
T0[0][0] = a;
T0[0][1] = b;
T0[2][0] = c;
@ -456,6 +457,8 @@ EX namespace euclid3 {
int dim = ginf[g].g.gameplay_dimension;
if(IRREGULAR) T0 = irr::base_periods, twisted0 = irr::base_twisted;
user_axes = T0;
if(dim == 2) user_axes[2] = euzero;
@ -828,6 +831,10 @@ EX namespace euclid3 {
torus_config_option(XLAT("Möbius band"), 'E', rectangular_torus(6, 0, true));
if(S3 == 3) torus_config_option(XLAT("seven-colorable torus"), 'F', regular_torus({1,2}));
if(S3 == 3) torus_config_option(XLAT("HyperRogue classic torus"), 'G', single_row_torus(381, -22));
torus_config_option(XLAT("no quotient"), 'H', rectangular_torus(0, 0, false));
if(IRREGULAR)
dialog::addInfo("period cannot be changed in irregular");
}
dialog::addBreak(50);

View File

@ -749,6 +749,10 @@ EX namespace gp {
dialog::addBoolItem(XLAT("irregular"), IRREGULAR, 'i');
dialog::add_action(dialog::add_confirmation([=] () {
if(min_quality && !irr::bitruncations_requested) irr::bitruncations_requested++;
if(euclid && !bounded) {
println(hlog, XLAT("To create Euclidean irregular tesselations, first enable a torus"));
return;
}
if(!IRREGULAR) irr::visual_creator();
}));
}

View File

@ -121,6 +121,9 @@ string status[5];
EX hrmap *base;
EX euclid3::intmatrix base_periods;
EX int base_twisted;
bool gridmaking;
int rearrange_index;
@ -916,6 +919,14 @@ string irrhelp =
"with too large periodic base geometry. "
"For technical reasons, the density cannot be too small.";
bool too_small_euclidean() {
for(cell *c: base->allcells())
forCellIdEx(c1, i1, c)
forCellIdEx(c2, i2, c)
if(i1 != i2 && c1 == c2) return true;
return false;
}
void show_gridmaker() {
cmode = sm::SIDE | sm::MAYDARK;
gamescreen(0);
@ -986,6 +997,8 @@ void show_gridmaker() {
if(bitruncations_requested < bitruncations_performed) runlevel = 0;
};
});
if(too_small_euclidean())
dialog::addInfo(XLAT("too small period -- irregular tiling generation fails"));
dialog::addItem(XLAT("reset"), 'r');
dialog::add_action([] () { runlevel = 0; });
dialog::addHelp();
@ -1018,6 +1031,8 @@ EX void visual_creator() {
start_game();
if(base) delete base;
base = currentmap;
base_periods = euclid3::T0;
base_twisted = euclid3::twisted0;
drawthemap();
cellcount = int(isize(base->allcells()) * density + .5);
pushScreen(show_gridmaker);