mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-02 20:29:17 +00:00
nicer auto sight range computation, and range(...) directive in the tes language
This commit is contained in:
parent
c8cbe55e1f
commit
d0e7541b45
@ -79,6 +79,7 @@ struct arbi_tiling {
|
||||
vector<slider> sliders;
|
||||
|
||||
ld cscale;
|
||||
int range;
|
||||
string filename;
|
||||
|
||||
geometryinfo1& get_geometry();
|
||||
@ -379,6 +380,7 @@ EX void load(const string& fname, bool after_sliding IS(false)) {
|
||||
c.comment = "";
|
||||
c.filename = fname;
|
||||
c.cscale = 1;
|
||||
c.range = 0;
|
||||
exp_parser ep;
|
||||
ep.s = s;
|
||||
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();
|
||||
ep.force_eat(")");
|
||||
}
|
||||
else if(ep.eat("range(")) {
|
||||
c.range = ep.iparse();
|
||||
ep.force_eat(")");
|
||||
}
|
||||
else if(ep.eat("conway(\"")) {
|
||||
string s = "";
|
||||
while(true) {
|
||||
@ -790,11 +796,9 @@ struct hrmap_arbi : hrmap {
|
||||
transmatrix T = xpush(.01241) * spin(1.4117) * xpush(0.1241) * Id;
|
||||
arbi_matrix[origin] = make_pair(alt, T);
|
||||
altmap[alt].emplace_back(origin, T);
|
||||
|
||||
cgi.base_distlimit = 0;
|
||||
celllister cl(origin->c7, 1000, 200, NULL);
|
||||
ginf[geometry].distlimit[0] = cgi.base_distlimit = cl.dists.back();
|
||||
if(sphere) cgi.base_distlimit = SEE_ALL;
|
||||
|
||||
if(!current.range)
|
||||
current.range = auto_compute_range(origin->c7);
|
||||
}
|
||||
|
||||
~hrmap_arbi() {
|
||||
@ -1143,6 +1147,7 @@ EX void convert() {
|
||||
ac.order++;
|
||||
ac.comment = ac.filename = "converted from: " + full_geometry_name();
|
||||
ac.cscale = cgi.scalefactor;
|
||||
ac.range = cgi.base_distlimit;
|
||||
int N = isize(old_shvids);
|
||||
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);
|
||||
}
|
||||
|
||||
cgi.base_distlimit = 0;
|
||||
celllister cl(origin->c7, 1000, 200, NULL);
|
||||
ginf[geometry].distlimit[!BITRUNCATED] = cgi.base_distlimit = cl.dists.back();
|
||||
if(sphere) cgi.base_distlimit = SEE_ALL;
|
||||
auto_compute_range(origin->c7);
|
||||
}
|
||||
|
||||
~hrmap_archimedean() {
|
||||
|
21
cell.cpp
21
cell.cpp
@ -1425,6 +1425,27 @@ EX bool is_boundary(cell *c) {
|
||||
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 heptagon oob;
|
||||
|
||||
|
@ -732,6 +732,7 @@ void geometry_information::prepare_basics() {
|
||||
scalefactor = csc;
|
||||
hcrossf = crossf = orbsize = hcrossf7 * csc;
|
||||
hexf = rhexf = hexvdist = csc * .5;
|
||||
base_distlimit = arb::current.range;
|
||||
}
|
||||
|
||||
if(is_subcube_based(variation)) {
|
||||
|
Loading…
Reference in New Issue
Block a user