mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 05:52:59 +00:00 
			
		
		
		
	asonov:: works even with small periods
This commit is contained in:
		
							
								
								
									
										27
									
								
								asonov.cpp
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								asonov.cpp
									
									
									
									
									
								
							| @@ -18,6 +18,7 @@ EX namespace asonov { | |||||||
| EX bool in() { return geometry == gArnoldCat; } | EX bool in() { return geometry == gArnoldCat; } | ||||||
|  |  | ||||||
| EX hyperpoint tx, ty, tz; | EX hyperpoint tx, ty, tz; | ||||||
|  | EX transmatrix straighten; | ||||||
|  |  | ||||||
| EX int period_xy = 8; | EX int period_xy = 8; | ||||||
| EX int period_z = 8; | EX int period_z = 8; | ||||||
| @@ -108,8 +109,23 @@ EX void prepare() { | |||||||
|     auto test1 = test.addmove(a).addmove(b); |     auto test1 = test.addmove(a).addmove(b); | ||||||
|     println(hlog, test == test1 ? "OK" : "BAD", " : ", test, " vs ", test1, " ## ", test.addmove(a)); |     println(hlog, test == test1 ? "OK" : "BAD", " : ", test, " vs ", test1, " ## ", test.addmove(a)); | ||||||
|     } |     } | ||||||
|  |    | ||||||
|  |   straighten = inverse(build_matrix(asonov::tx/2, asonov::ty/2, asonov::tz/2, C0)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | EX transmatrix adjmatrix(int i) { | ||||||
|  |   dynamicval<int> pxy(period_xy, 64); | ||||||
|  |   dynamicval<int> pz(period_z, 64); | ||||||
|  |   coord c = coord(0,0,0).addmove(i); | ||||||
|  |   if(c[0] > period_xy/2) c[0] -= period_xy; | ||||||
|  |   if(c[1] > period_xy/2) c[1] -= period_xy; | ||||||
|  |   if(c[2] > period_z/2) c[2] -= period_z; | ||||||
|  |   transmatrix T = eupush(tz * c[2]) * eupush(tx * c[0] + ty * c[1]);; | ||||||
|  |   if(i < 4) return T * eupush(ty/2); | ||||||
|  |   if(i >= 6 && i < 10) return eupush(-ty/2) * T; | ||||||
|  |   return T; | ||||||
|  |   } | ||||||
|  |    | ||||||
| struct hrmap_asonov : hrmap { | struct hrmap_asonov : hrmap { | ||||||
|   unordered_map<coord, heptagon*> at; |   unordered_map<coord, heptagon*> at; | ||||||
|     unordered_map<heptagon*, coord> coords; |     unordered_map<heptagon*, coord> coords; | ||||||
| @@ -145,17 +161,6 @@ struct hrmap_asonov : hrmap { | |||||||
|     return child; |     return child; | ||||||
|     } |     } | ||||||
|    |    | ||||||
|   transmatrix adjmatrix(int i) { |  | ||||||
|     coord c = coord(0,0,0).addmove(i); |  | ||||||
|     if(c[0] > period_xy/2) c[0] -= period_xy; |  | ||||||
|     if(c[1] > period_xy/2) c[1] -= period_xy; |  | ||||||
|     if(c[2] > period_z/2) c[2] -= period_z; |  | ||||||
|     transmatrix T = eupush(tz * c[2]) * eupush(tx * c[0] + ty * c[1]);; |  | ||||||
|     if(i < 4) return T * eupush(ty/2); |  | ||||||
|     if(i >= 6 && i < 10) return eupush(-ty/2) * T; |  | ||||||
|     return T; |  | ||||||
|     } |  | ||||||
|      |  | ||||||
|   virtual transmatrix relative_matrix(heptagon *h2, heptagon *h1) override {  |   virtual transmatrix relative_matrix(heptagon *h2, heptagon *h1) override {  | ||||||
|     for(int a=0; a<S7; a++) if(h2 == h1->move(a)) return adjmatrix(a); |     for(int a=0; a<S7; a++) if(h2 == h1->move(a)) return adjmatrix(a); | ||||||
|     return Id; |     return Id; | ||||||
|   | |||||||
| @@ -218,6 +218,7 @@ struct horo_distance { | |||||||
| void horo_distance::become(hyperpoint h1) { | void horo_distance::become(hyperpoint h1) { | ||||||
|   if(solnih) { |   if(solnih) { | ||||||
|     a = abs(h1[2]); |     a = abs(h1[2]); | ||||||
|  |     if(asonov::in()) h1 = asonov::straighten * h1; | ||||||
|     b = hypot_d(2, h1); |     b = hypot_d(2, h1); | ||||||
|     } |     } | ||||||
|   #if CAP_BT |   #if CAP_BT | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								hypgraph.cpp
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								hypgraph.cpp
									
									
									
									
									
								
							| @@ -1482,16 +1482,24 @@ EX void optimizeview() { | |||||||
|   #if CAP_BT || CAP_ARCM || MAXMDIM == 4 |   #if CAP_BT || CAP_ARCM || MAXMDIM == 4 | ||||||
|   else if(binarytiling || archimedean || penrose || WDIM == 3) { |   else if(binarytiling || archimedean || penrose || WDIM == 3) { | ||||||
|     turn = -1, best = hdist0(tC0(View)); |     turn = -1, best = hdist0(tC0(View)); | ||||||
|  |     if(asonov::in()) { | ||||||
|  |       hyperpoint h = asonov::straighten * tC0(View); | ||||||
|  |       best = abs(h[2] > 1) ? 999 : hdist0(h); | ||||||
|  |       } | ||||||
|     for(int i=0; i<viewctr.at->type; i++) { |     for(int i=0; i<viewctr.at->type; i++) { | ||||||
|       if(penrose && euclid && (i < 4 || i >= 8)) continue; |       if(penrose && euclid && (i < 4 || i >= 8)) continue; | ||||||
|       int i1 = i * DUALMUL; |       int i1 = i * DUALMUL; | ||||||
|       heptagon *h2 = createStep(viewctr.at, i1); |       heptagon *h2 = createStep(viewctr.at, i1); | ||||||
|       transmatrix T = currentmap->relative_matrix(h2, viewctr.at); |       transmatrix T = asonov::in() ? asonov::adjmatrix(i) : currentmap->relative_matrix(h2, viewctr.at); | ||||||
|       #if MAXMDIM >= 4 |       #if MAXMDIM >= 4 | ||||||
|       if(euclid && WDIM == 3) |       if(euclid && WDIM == 3) | ||||||
|         T = euclid3::move_matrix(viewctr.at->c7, i); |         T = euclid3::move_matrix(viewctr.at->c7, i); | ||||||
|       #endif |       #endif | ||||||
|       hyperpoint H = View * tC0(T); |       hyperpoint H = View * tC0(T); | ||||||
|  |       if(asonov::in()) { | ||||||
|  |         H = asonov::straighten * H; | ||||||
|  |         if(abs(H[2]) > 1) continue; | ||||||
|  |         } | ||||||
|       ld quality = hdist0(H); |       ld quality = hdist0(H); | ||||||
|       if(quality < best) best = quality, turn = i1, TB = T; |       if(quality < best) best = quality, turn = i1, TB = T; | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -838,7 +838,9 @@ EX void cast() { | |||||||
|   GLERR("uniform IPD"); |   GLERR("uniform IPD"); | ||||||
|    |    | ||||||
|   vector<transmatrix> ms; |   vector<transmatrix> ms; | ||||||
|   for(int j=0; j<S7; j++) ms.push_back(prod ? currentmap->relative_matrix(cwt.at, cwt.at->cmove(j), Hypc) : currentmap->relative_matrix(cwt.at->master, cwt.at->cmove(j)->master)); |   for(int j=0; j<S7; j++) ms.push_back( | ||||||
|  |     asonov::in() ? asonov::adjmatrix((j+S7/2)%S7) : | ||||||
|  |     prod ? currentmap->relative_matrix(cwt.at, cwt.at->cmove(j), Hypc) : currentmap->relative_matrix(cwt.at->master, cwt.at->cmove(j)->master)); | ||||||
|   if(prod) ms.push_back(Id); |   if(prod) ms.push_back(Id); | ||||||
|   if(prod) ms.push_back(Id); |   if(prod) ms.push_back(Id); | ||||||
|    |    | ||||||
| @@ -902,7 +904,7 @@ EX void cast() { | |||||||
|         connections[u][2] = (S7+.5) / 1024.; |         connections[u][2] = (S7+.5) / 1024.; | ||||||
|         continue; |         continue; | ||||||
|         } |         } | ||||||
|       transmatrix T = (prod ? currentmap->relative_matrix(c, c1, C0) : currentmap->relative_matrix(c->master, c1->master)) * inverse(ms[i]); |       transmatrix T = asonov::in() ? Id : (prod ? currentmap->relative_matrix(c, c1, C0) : currentmap->relative_matrix(c->master, c1->master)) * inverse(ms[i]); | ||||||
|       for(int k=0; k<=isize(ms); k++) { |       for(int k=0; k<=isize(ms); k++) { | ||||||
|         if(k < isize(ms) && !eqmatrix(ms[k], T)) continue; |         if(k < isize(ms) && !eqmatrix(ms[k], T)) continue; | ||||||
|         if(k == isize(ms)) ms.push_back(T); |         if(k == isize(ms)) ms.push_back(T); | ||||||
| @@ -930,8 +932,7 @@ EX void cast() { | |||||||
|   if(o->uBinaryWidth != -1) |   if(o->uBinaryWidth != -1) | ||||||
|     glUniform1f(o->uBinaryWidth, vid.binary_width/2 * (nih?1:log(2))); |     glUniform1f(o->uBinaryWidth, vid.binary_width/2 * (nih?1:log(2))); | ||||||
|   if(o->uStraighten != -1) { |   if(o->uStraighten != -1) { | ||||||
|     transmatrix T = build_matrix(asonov::tx/2, asonov::ty/2, asonov::tz/2, C0); |     glUniformMatrix4fv(o->uStraighten, 1, 0, glhr::tmtogl_transpose(asonov::straighten).as_array()); | ||||||
|     glUniformMatrix4fv(o->uStraighten, 1, 0, glhr::tmtogl_transpose(inverse(T)).as_array()); |  | ||||||
|     } |     } | ||||||
|   if(o->uPLevel != -1) |   if(o->uPLevel != -1) | ||||||
|     glUniform1f(o->uPLevel, cgi.plevel / 2); |     glUniform1f(o->uPLevel, cgi.plevel / 2); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue