From 7e1344a863b57a50358cbd5e664c30ac8ed9d1ce Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 2 Aug 2018 22:26:07 +0200 Subject: [PATCH] singletype patterns now can be remapped to irregular grids --- goldberg.cpp | 7 ++++++- irregular.cpp | 7 +++++++ pattern2.cpp | 11 ++++++++--- textures.cpp | 17 +++++++++++++++-- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/goldberg.cpp b/goldberg.cpp index 002e2680..8e4ffb8b 100644 --- a/goldberg.cpp +++ b/goldberg.cpp @@ -703,6 +703,11 @@ namespace hr { namespace gp { bool show_nonthree = !(texture_remap && (S7&1)); bool show_bitrunc = !(texture_remap && !(S7&1)); + bool show_irregular = !texture_remap; + if(texture_remap) { + if(patterns::cgroup == cpSingle) + show_nonthree = true, show_bitrunc = false, show_irregular = true; + } if(show_nonthree) { dialog::addBoolItem(XLAT("OFF"), param == loc(1,0) && !irr::on, 'a'); @@ -742,7 +747,7 @@ namespace hr { namespace gp { else dialog::addBoolItem(XLAT("select"), param == internal_representation(config) && !irr::on, 'f'); - if(!texture_remap && irr::supports(geometry)) { + if(show_irregular && irr::supports(geometry)) { dialog::addBoolItem(XLAT("irregular"), irr::on, 'i'); dialog::add_action([] () { if(!irr::on) irr::visual_creator(); }); } diff --git a/irregular.cpp b/irregular.cpp index 6c0924cf..286fc0a2 100644 --- a/irregular.cpp +++ b/irregular.cpp @@ -672,6 +672,10 @@ int celldist(cell *c, bool alts) { eGeometry orig_geometry; void start_game_on_created_map() { +#if CAP_TEXTURE + auto old_tstate = texture::config.tstate; + auto old_tstate_max = texture::config.tstate_max; +#endif popScreen(); for(hrmap *& hm : allmaps) if(hm == base) hm = NULL; stop_game(); @@ -682,6 +686,9 @@ void start_game_on_created_map() { need_reset_geometry = true; gridmaking = false; start_game(); +#if CAP_TEXTURE + texture::config.remap(old_tstate, old_tstate_max); +#endif } bool save_map(const string& fname) { diff --git a/pattern2.cpp b/pattern2.cpp index 0df4e373..af0b1446 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -1724,18 +1724,23 @@ namespace patterns { } dialog::addBoolItem(s, geometry == g.geo && nonbitrunc == g.nonbitru && whichPattern == g.whichPattern && subpattern_flags == g.subpattern_flags, 'a'+j); } - bool have_goldberg = S3 == 3 && among(cgroup, cpFootball, cpThree) && !euclid; + bool have_goldberg = (S3 == 3 && among(cgroup, cpFootball, cpThree) && !euclid); + bool have_variations = (among(cgroup, cpSingle, cpSingleSym) && !euclid); if(!(S7&1) && !nonbitrunc) have_goldberg = false; // always start from non-bitruncated if(have_goldberg) { dialog::addBoolItem(XLAT("Goldberg"), gp::on, 'G'); dialog::lastItem().value = gp::operation_name(); } + if(have_variations) { + dialog::addBoolItem(XLAT("variations"), gp::on, 'G'); + dialog::lastItem().value = gp::operation_name(); + } else dialog::addBreak(100); dialog::addItem(XLAT("more tuning"), 'r'); dialog::addBack(); dialog::display(); - keyhandler = [have_goldberg] (int sym, int uni) { + keyhandler = [have_goldberg, have_variations] (int sym, int uni) { if(uni == 'r') pushScreen(showPattern); else if(uni >= '0' && uni < '0' + isize(cpatterns)) @@ -1756,7 +1761,7 @@ namespace patterns { texture::config.remap(old_tstate, old_tstate_max); #endif } - else if(uni == 'G' && have_goldberg) + else if(uni == 'G' && (have_goldberg || have_variations)) gp::configure(true); else if(doexiton(sym, uni)) popScreen(); diff --git a/textures.cpp b/textures.cpp index d8bcf1dd..4ab9f662 100644 --- a/textures.cpp +++ b/textures.cpp @@ -277,7 +277,9 @@ int getTriangleID(cell *c, patterns::patterninfo& si, hyperpoint h) { } int goldbergcode(cell *c, const patterns::patterninfo& si) { - if(!gp::on) return 0; + if(irr::on) + return irr::cellindex[c] << 8; + else if(!gp::on) return 0; else if(c == c->master->c7) return (fixdir(si.dir, c) << 8); else return (get_code(gp::get_local_info(c)) << 16) | (fixdir(si.dir, c) << 8); } @@ -300,6 +302,17 @@ void mapTexture(cell *c, textureinfo& mi, patterns::patterninfo &si, const trans } } + else if(irr::on) { + mi.M = T; + mi.triangles.clear(); + auto& vs = irr::cells[irr::cellindex[c]]; + for(int i=0; itype; i++) { + hyperpoint h1 = vs.vertices[i]; + hyperpoint h2 = vs.vertices[(i+1)%c->type]; + mi.triangles.emplace_back(make_array(C0, h1, h2), make_array(mi.M*C0, mi.M*h1, mi.M*h2)); + } + } + else { mi.M = T * applyPatterndir(c, si); @@ -348,7 +361,7 @@ bool texture_config::apply(cell *c, const transmatrix &V, int col) { set_floor(shFullFloor); qfi.tinf = &mi; - qfi.spin = gp::on ? Id : applyPatterndir(c, si); + qfi.spin = (gp::on || irr::on) ? Id : applyPatterndir(c, si); if(grid_color) { draw_floorshape(c, V, shFullFloor, 0, PPR_FLOOR);