mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 14:02:59 +00:00 
			
		
		
		
	bandfixer (for normal geometries)
This commit is contained in:
		| @@ -400,6 +400,8 @@ namespace conformal { | |||||||
|     osin = sin(model_orientation * degree); |     osin = sin(model_orientation * degree); | ||||||
|     model_straight = (ocos > 1 - 1e-9); |     model_straight = (ocos > 1 - 1e-9); | ||||||
|     if(conformal::on) conformal::apply(); |     if(conformal::on) conformal::apply(); | ||||||
|  |      | ||||||
|  |     band_shift = 0; | ||||||
|     } |     } | ||||||
|    |    | ||||||
|   ld measureLength() { |   ld measureLength() { | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								hyper.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								hyper.h
									
									
									
									
									
								
							| @@ -2625,6 +2625,7 @@ struct drawqueueitem { | |||||||
|   }; |   }; | ||||||
|  |  | ||||||
| struct dqi_poly : drawqueueitem { | struct dqi_poly : drawqueueitem { | ||||||
|  |   ld band_shift; | ||||||
|   transmatrix V; |   transmatrix V; | ||||||
|   const vector<glvertex> *tab; |   const vector<glvertex> *tab; | ||||||
|   int offset, cnt; |   int offset, cnt; | ||||||
| @@ -2640,6 +2641,7 @@ struct dqi_poly : drawqueueitem { | |||||||
|   }; |   }; | ||||||
|  |  | ||||||
| struct dqi_line : drawqueueitem { | struct dqi_line : drawqueueitem { | ||||||
|  |   ld band_shift; | ||||||
|   hyperpoint H1, H2; |   hyperpoint H1, H2; | ||||||
|   int prf; |   int prf; | ||||||
|   double width; |   double width; | ||||||
| @@ -4328,5 +4330,15 @@ string parser_help(); | |||||||
| static const ld degree = M_PI / 180; | static const ld degree = M_PI / 180; | ||||||
|  |  | ||||||
| void show_color_dialog(); | void show_color_dialog(); | ||||||
|  |  | ||||||
|  | extern ld band_shift; | ||||||
|  |  | ||||||
|  | void fix_the_band(transmatrix& T); | ||||||
|  |  | ||||||
|  | struct bandfixer { | ||||||
|  |   dynamicval<ld> bw; | ||||||
|  |   bandfixer(transmatrix& T) : bw(band_shift, band_shift) { fix_the_band(T); } | ||||||
|  |   }; | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										25
									
								
								hypgraph.cpp
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								hypgraph.cpp
									
									
									
									
									
								
							| @@ -163,7 +163,7 @@ template<class T> void makeband(hyperpoint H, hyperpoint& ret, const T& f) { | |||||||
|    |    | ||||||
|   ld x, y, yf, zf=0; |   ld x, y, yf, zf=0; | ||||||
|   y = asin_auto(H[1]); |   y = asin_auto(H[1]); | ||||||
|   x = asin_auto_clamp(H[0] / cos_auto(y)); |   x = asin_auto_clamp(H[0] / cos_auto(y)) + band_shift; | ||||||
|   if(sphere) { |   if(sphere) { | ||||||
|     if(H[2] < 0 && x > 0) x = M_PI - x; |     if(H[2] < 0 && x > 0) x = M_PI - x; | ||||||
|     else if(H[2] < 0 && x <= 0) x = -M_PI - x; |     else if(H[2] < 0 && x <= 0) x = -M_PI - x; | ||||||
| @@ -774,7 +774,7 @@ void drawrec(const heptspin& hs, hstate s, const transmatrix& V, int reclev) { | |||||||
|    |    | ||||||
|   bool draw = c->pathdist < PINFD; |   bool draw = c->pathdist < PINFD; | ||||||
|    |    | ||||||
|   if(cells_drawn > vid.cells_drawn_limit || reclev >= 100 || std::isinf(V[2][2]) || std::isnan(V[2][2])) |   if(cells_drawn > vid.cells_drawn_limit || reclev >= 10000 || std::isinf(V[2][2]) || std::isnan(V[2][2]) || V[2][2] > 1e8) | ||||||
|     draw = false; |     draw = false; | ||||||
|   else if(vid.use_smart_range) { |   else if(vid.use_smart_range) { | ||||||
|     draw = reclev < 2 ? true : in_smart_range(V); |     draw = reclev < 2 ? true : in_smart_range(V); | ||||||
| @@ -817,7 +817,9 @@ void drawrec(const heptspin& hs, hstate s, const transmatrix& V, int reclev) { | |||||||
|     hstate s2 = transition(s, d); |     hstate s2 = transition(s, d); | ||||||
|     if(s2 == hsError) continue; |     if(s2 == hsError) continue; | ||||||
|     heptspin hs2 = hs + d + wstep; |     heptspin hs2 = hs + d + wstep; | ||||||
|     drawrec(hs2, s2, V * heptmove[d], reclev+1); |     transmatrix Vd = V * heptmove[d]; | ||||||
|  |     bandfixer bf(Vd); | ||||||
|  |     drawrec(hs2, s2, Vd, reclev+1); | ||||||
|     } |     } | ||||||
|    |    | ||||||
|   } |   } | ||||||
| @@ -1345,4 +1347,21 @@ void draw_boundary(int w) { | |||||||
|   */ |   */ | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | ld band_shift = 0; | ||||||
|  | void fix_the_band(transmatrix& T) { | ||||||
|  |   if((models[pmodel].flags & mf::quasiband) && T[2][2] > 1e6) { | ||||||
|  |     hyperpoint H = tC0(T); | ||||||
|  |     find_zlev(H); | ||||||
|  |     conformal::apply_orientation(H[0], H[1]); | ||||||
|  |      | ||||||
|  |     ld y = asin_auto(H[1]); | ||||||
|  |     ld x = asin_auto_clamp(H[0] / cos_auto(y)); | ||||||
|  |     band_shift += x; | ||||||
|  |     // printf("fixing with shift = %lf\n", x); | ||||||
|  |     T = xpush(-x) * T; | ||||||
|  |     fixmatrix(T); | ||||||
|  |     // todo orientation | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -834,6 +834,7 @@ ld get_width(dqi_poly* p) { | |||||||
|  |  | ||||||
| void dqi_poly::draw() { | void dqi_poly::draw() { | ||||||
|  |  | ||||||
|  |   dynamicval<ld> bs(hr::band_shift, band_shift); | ||||||
|   if(!hyperbolic && among(pmodel, mdPolygonal, mdPolynomial)) { |   if(!hyperbolic && among(pmodel, mdPolygonal, mdPolynomial)) { | ||||||
|     bool any = false; |     bool any = false; | ||||||
|     for(int i=0; i<cnt; i++) { |     for(int i=0; i<cnt; i++) { | ||||||
| @@ -1173,6 +1174,7 @@ void prettyline(hyperpoint h1, hyperpoint h2, color_t col, int lev, int flags) { | |||||||
|   prettylinesub(h1, h2, lev); |   prettylinesub(h1, h2, lev); | ||||||
|   dqi_poly ptd; |   dqi_poly ptd; | ||||||
|   ptd.V = Id; |   ptd.V = Id; | ||||||
|  |   ptd.band_shift = band_shift; | ||||||
|   ptd.tab = &prettylinepoints; |   ptd.tab = &prettylinepoints; | ||||||
|   ptd.offset = 0; |   ptd.offset = 0; | ||||||
|   ptd.cnt = isize(prettylinepoints); |   ptd.cnt = isize(prettylinepoints); | ||||||
| @@ -1192,6 +1194,7 @@ void prettypoly(const vector<hyperpoint>& t, color_t fillcol, color_t linecol, i | |||||||
|     prettylinesub(t[i], t[(i+1)%3], lev); |     prettylinesub(t[i], t[(i+1)%3], lev); | ||||||
|   dqi_poly ptd; |   dqi_poly ptd; | ||||||
|   ptd.V = Id; |   ptd.V = Id; | ||||||
|  |   ptd.band_shift = band_shift; | ||||||
|   ptd.tab = &prettylinepoints; |   ptd.tab = &prettylinepoints; | ||||||
|   ptd.offset = 0; |   ptd.offset = 0; | ||||||
|   ptd.cnt = isize(prettylinepoints); |   ptd.cnt = isize(prettylinepoints); | ||||||
| @@ -1214,6 +1217,7 @@ void queuereset(eModel m, PPR prio) { | |||||||
|  |  | ||||||
| void dqi_line::draw() { | void dqi_line::draw() { | ||||||
|   dynamicval<ld> d(vid.linewidth, width);  |   dynamicval<ld> d(vid.linewidth, width);  | ||||||
|  |   dynamicval<ld> bs(hr::band_shift, band_shift); | ||||||
|   prettyline(H1, H2, color, prf, 0); |   prettyline(H1, H2, color, prf, 0); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -2639,6 +2643,7 @@ dqi_poly& queuepolyat(const transmatrix& V, const hpcshape& h, color_t col, PPR | |||||||
|   auto& ptd = queuea<dqi_poly> (prio); |   auto& ptd = queuea<dqi_poly> (prio); | ||||||
|  |  | ||||||
|   ptd.V = V; |   ptd.V = V; | ||||||
|  |   ptd.band_shift = band_shift; | ||||||
|   ptd.offset = h.s; |   ptd.offset = h.s; | ||||||
|   ptd.cnt = h.e-h.s; |   ptd.cnt = h.e-h.s; | ||||||
|   ptd.tab = &ourshape; |   ptd.tab = &ourshape; | ||||||
| @@ -2674,6 +2679,7 @@ dqi_poly& queuetable(const transmatrix& V, const vector<glvertex>& f, int cnt, c | |||||||
|   auto& ptd = queuea<dqi_poly> (prio); |   auto& ptd = queuea<dqi_poly> (prio); | ||||||
|  |  | ||||||
|   ptd.V = V; |   ptd.V = V; | ||||||
|  |   ptd.band_shift = band_shift; | ||||||
|   ptd.tab = &f; |   ptd.tab = &f; | ||||||
|   ptd.offset = 0; |   ptd.offset = 0; | ||||||
|   ptd.cnt = cnt; |   ptd.cnt = cnt; | ||||||
| @@ -2714,6 +2720,7 @@ dqi_line& queueline(const hyperpoint& H1, const hyperpoint& H2, color_t col, int | |||||||
|  |  | ||||||
|   ptd.H1 = H1; |   ptd.H1 = H1; | ||||||
|   ptd.H2 = H2; |   ptd.H2 = H2; | ||||||
|  |   ptd.band_shift = band_shift; | ||||||
|   ptd.prf = prf; |   ptd.prf = prf; | ||||||
|   ptd.width = vid.linewidth; |   ptd.width = vid.linewidth; | ||||||
|   ptd.color = (darkened(col >> 8) << 8) + (col & 0xFF); |   ptd.color = (darkened(col >> 8) << 8) + (col & 0xFF); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue