mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-30 21:42:59 +00:00 
			
		
		
		
	nicer auto sight range computation, and range(...) directive in the tes language
This commit is contained in:
		| @@ -79,6 +79,7 @@ struct arbi_tiling { | |||||||
|   vector<slider> sliders; |   vector<slider> sliders; | ||||||
|    |    | ||||||
|   ld cscale; |   ld cscale; | ||||||
|  |   int range; | ||||||
|   string filename; |   string filename; | ||||||
|  |  | ||||||
|   geometryinfo1& get_geometry(); |   geometryinfo1& get_geometry(); | ||||||
| @@ -379,6 +380,7 @@ EX void load(const string& fname, bool after_sliding IS(false)) { | |||||||
|   c.comment = ""; |   c.comment = ""; | ||||||
|   c.filename = fname; |   c.filename = fname; | ||||||
|   c.cscale = 1; |   c.cscale = 1; | ||||||
|  |   c.range = 0; | ||||||
|   exp_parser ep; |   exp_parser ep; | ||||||
|   ep.s = s; |   ep.s = s; | ||||||
|   ld angleunit = 1, distunit = 1, angleofs = 0; |   ld angleunit = 1, distunit = 1, angleofs = 0; | ||||||
| @@ -490,6 +492,10 @@ EX void load(const string& fname, bool after_sliding IS(false)) { | |||||||
|       c.cscale = ep.rparse(); |       c.cscale = ep.rparse(); | ||||||
|       ep.force_eat(")"); |       ep.force_eat(")"); | ||||||
|       } |       } | ||||||
|  |     else if(ep.eat("range(")) { | ||||||
|  |       c.range = ep.iparse(); | ||||||
|  |       ep.force_eat(")"); | ||||||
|  |       } | ||||||
|     else if(ep.eat("conway(\"")) { |     else if(ep.eat("conway(\"")) { | ||||||
|       string s = ""; |       string s = ""; | ||||||
|       while(true) { |       while(true) { | ||||||
| @@ -791,10 +797,8 @@ struct hrmap_arbi : hrmap { | |||||||
|     arbi_matrix[origin] = make_pair(alt, T); |     arbi_matrix[origin] = make_pair(alt, T); | ||||||
|     altmap[alt].emplace_back(origin, T); |     altmap[alt].emplace_back(origin, T); | ||||||
|      |      | ||||||
|     cgi.base_distlimit = 0; |     if(!current.range) | ||||||
|     celllister cl(origin->c7, 1000, 200, NULL); |       current.range = auto_compute_range(origin->c7); | ||||||
|     ginf[geometry].distlimit[0] = cgi.base_distlimit = cl.dists.back(); |  | ||||||
|     if(sphere) cgi.base_distlimit = SEE_ALL; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   ~hrmap_arbi() { |   ~hrmap_arbi() { | ||||||
| @@ -1143,6 +1147,7 @@ EX void convert() { | |||||||
|   ac.order++;  |   ac.order++;  | ||||||
|   ac.comment = ac.filename = "converted from: " + full_geometry_name(); |   ac.comment = ac.filename = "converted from: " + full_geometry_name(); | ||||||
|   ac.cscale = cgi.scalefactor; |   ac.cscale = cgi.scalefactor; | ||||||
|  |   ac.range = cgi.base_distlimit; | ||||||
|   int N = isize(old_shvids); |   int N = isize(old_shvids); | ||||||
|   ac.shapes.resize(N); |   ac.shapes.resize(N); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -578,10 +578,7 @@ struct hrmap_archimedean : hrmap { | |||||||
|       origin->move(1)->c.connect(1, origin->move(0), 2*current.N-1, false); |       origin->move(1)->c.connect(1, origin->move(0), 2*current.N-1, false); | ||||||
|       } |       } | ||||||
|      |      | ||||||
|     cgi.base_distlimit = 0; |     auto_compute_range(origin->c7); | ||||||
|     celllister cl(origin->c7, 1000, 200, NULL); |  | ||||||
|     ginf[geometry].distlimit[!BITRUNCATED] = cgi.base_distlimit = cl.dists.back(); |  | ||||||
|     if(sphere) cgi.base_distlimit = SEE_ALL; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   ~hrmap_archimedean() { |   ~hrmap_archimedean() { | ||||||
|   | |||||||
							
								
								
									
										21
									
								
								cell.cpp
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								cell.cpp
									
									
									
									
									
								
							| @@ -1425,6 +1425,27 @@ EX bool is_boundary(cell *c) { | |||||||
|   return (cgflags & qPORTALSPACE) && isWall(c->wall); |   return (cgflags & qPORTALSPACE) && isWall(c->wall); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | /** compute the distlimit for a tessellation automatically */ | ||||||
|  | EX int auto_compute_range(cell *c) {   | ||||||
|  |   if(sphere) { | ||||||
|  |     cgi.base_distlimit = SEE_ALL; | ||||||
|  |     return SEE_ALL; | ||||||
|  |     } | ||||||
|  |   cgi.base_distlimit = 0; | ||||||
|  |   const int expected_count = 400; | ||||||
|  |   celllister cl(c, 1000, expected_count, NULL); | ||||||
|  |   int z = isize(cl.dists); | ||||||
|  |   int d = cl.dists.back(); | ||||||
|  |   while(cl.dists[z-1] == d) z--; | ||||||
|  |   if(true) { // if(cgflags & DF_GEOM) { | ||||||
|  |     println(hlog, "last distance = ", cl.dists.back()); | ||||||
|  |     println(hlog, "ball size = ", isize(cl.dists)); | ||||||
|  |     println(hlog, "previous ball size = ", z); | ||||||
|  |     } | ||||||
|  |   if(isize(cl.dists) * z > expected_count * expected_count) d--; | ||||||
|  |   return ginf[geometry].distlimit[0] = cgi.base_distlimit = d; | ||||||
|  |   } | ||||||
|  |  | ||||||
| EX cell out_of_bounds; | EX cell out_of_bounds; | ||||||
| EX heptagon oob; | EX heptagon oob; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -732,6 +732,7 @@ void geometry_information::prepare_basics() { | |||||||
|     scalefactor = csc; |     scalefactor = csc; | ||||||
|     hcrossf = crossf = orbsize = hcrossf7 * csc; |     hcrossf = crossf = orbsize = hcrossf7 * csc; | ||||||
|     hexf = rhexf = hexvdist = csc * .5; |     hexf = rhexf = hexvdist = csc * .5; | ||||||
|  |     base_distlimit = arb::current.range; | ||||||
|     } |     } | ||||||
|    |    | ||||||
|   if(is_subcube_based(variation)) { |   if(is_subcube_based(variation)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue