diff --git a/drawing.cpp b/drawing.cpp index f1d55f0d..0a48a6ea 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -1566,21 +1566,21 @@ EX namespace ods { dqi_poly npoly = *p; npoly.offset = 0; npoly.tab = &glcoords; - npoly.V = Id; + npoly.V = shiftless(Id); npoly.tinf = p->tinf ? &stinf : NULL; if(npoly.tinf) { npoly.offset_texture = 0; stinf.texture_id = p->tinf->texture_id; stinf.tvertices.clear(); } - npoly.V = Id; + npoly.V = shiftless(Id); glcoords.clear(); array h; if(0) for(int i=0; icnt; i+=3) { for(int j=0; j<3; j++) - h[j] = p->V * glhr::gltopoint((*p->tab)[p->offset+i+j]); + h[j] = unshift(p->V) * glhr::gltopoint((*p->tab)[p->offset+i+j]); for(int j=0; j<3; j++) { glcoords.push_back(glhr::makevertex(h[j][0], h[j][1], h[j][2])); @@ -1591,15 +1591,15 @@ EX namespace ods { if(1) for(int i=0; icnt; i+=3) { for(int j=0; j<3; j++) { - hyperpoint o = p->V * glhr::gltopoint((*p->tab)[p->offset+i+j]); + shiftpoint o = p->V * glhr::gltopoint((*p->tab)[p->offset+i+j]); if(nonisotropic || gproduct) { - o = lp_apply(inverse_exp(o, iTable, false)); - o[3] = 1; + auto o1 = lp_apply(inverse_exp(o, pNORMAL)); + o1[3] = 1; dynamicval g(geometry, gEuclid); - if(!project(o, h[j], h[j+3], global_projection == -1)) + if(!project(o1, h[j], h[j+3], global_projection == -1)) goto next_i; } - else if(!project(o, h[j], h[j+3], global_projection == -1)) + else if(!project(unshift(o), h[j], h[j+3], global_projection == -1)) goto next_i; } diff --git a/mapeditor.cpp b/mapeditor.cpp index 1db016b1..dd1e8761 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -184,10 +184,14 @@ EX namespace mapeditor { if(drawing_tool && (cmode & sm::DRAW)) { shiftpoint moh = full_mouseh(); dynamicval lw(vid.linewidth, vid.linewidth * dtwidth * 100); - if(holdmouse && mousekey == 'c') + if(holdmouse && mousekey == 'c') { + torus_rug_jump(moh, lstart); queue_hcircle(rgpushxto0(lstart), hdist(lstart, moh)); - else if(holdmouse && mousekey == 'l') + } + else if(holdmouse && mousekey == 'l') { + torus_rug_jump(moh, lstart); queueline(lstart, moh, dtcolor, 4 + vid.linequality, PPR::LINE); + } else if(!holdmouse) { shiftmatrix T = rgpushxto0(moh); queueline(T * xpush0(-.1), T * xpush0(.1), dtcolor); @@ -208,6 +212,9 @@ EX namespace mapeditor { } EX void dt_add_line(shiftpoint h1, shiftpoint h2, int maxl) { + + torus_rug_jump(h2, h1); + if(hdist(h1, h2) > 1 && maxl > 0) { shiftpoint h3 = mid(h1, h2); dt_add_line(h1, h3, maxl-1); @@ -230,6 +237,7 @@ EX namespace mapeditor { EX void dt_add_circle(shiftpoint h1, shiftpoint h2) { cell *b = centerover; + torus_rug_jump(h2, h1); auto d = hdist(h1, h2); auto xh1 = inverse_shift(ggmatrix(b), h1); @@ -279,9 +287,25 @@ EX namespace mapeditor { cfree = nullptr; cfree_at = nullptr; } - + + EX void torus_rug_jump(shiftpoint& h, shiftpoint last) { + if(!rug::rugged) return; + again: + + auto C = ggmatrix(centerover); + auto T1 = inverse_shift(C, rgpushxto0(h)); + + for(int a=0; a<2; a++) for(int s: {-1, 1}) { + transmatrix T = eumove(s * euc::eu.optimal_axes[a]); + shiftpoint h1 = C * T * tC0(T1); + if(hdist(h1, last) < hdist(h, last) - 1e-6) { h = h1; goto again; } + } + } + EX void dt_add_free(shiftpoint h) { + if(cfree) torus_rug_jump(h, cfree_old * cfree->lh.back()); + cell *b = centerover; shiftmatrix T = rgpushxto0(h); auto T1 = inverse_shift(ggmatrix(b), T);