1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

simplified the scaling scode

This commit is contained in:
Zeno Rogue 2018-08-28 19:05:57 +02:00
parent 6d5d8d8134
commit 015e69cf30
6 changed files with 386 additions and 431 deletions

View File

@ -34,6 +34,8 @@ ld hexshift;
ld hcrossf7 = 0.620672; ld hcrossf7 = 0.620672;
ld hexf7 = 0.378077; ld hexf7 = 0.378077;
ld scalefactor, orbsize, floorrad0, floorrad1, zhexf;
// the distance between two hexagon centers // the distance between two hexagon centers
void precalc() { void precalc() {
@ -161,10 +163,32 @@ void precalc() {
hexhexdist, hexvdist); hexhexdist, hexvdist);
base_distlimit = ginf[geometry].distlimit[!BITRUNCATED]; base_distlimit = ginf[geometry].distlimit[!BITRUNCATED];
gp::compute_geometry(); gp::compute_geometry();
irr::compute_geometry(); irr::compute_geometry();
if(archimedean) arcm::current.compute_geometry(); if(archimedean) {
arcm::current.compute_geometry();
crossf = hcrossf7 * arcm::current.scale();
hexvdist = arcm::current.scale() * .5;
rhexf = arcm::current.scale() * .5;
}
if(binarytiling) hexvdist = rhexf = 1, tessf = 1, scalefactor = 1, crossf = hcrossf7;
scalefactor = crossf / hcrossf7;
orbsize = crossf;
zhexf = BITRUNCATED ? hexf : crossf* .55;
floorrad0 = hexvdist* 0.92;
floorrad1 = rhexf * 0.94;
if(euclid4) {
if(!BITRUNCATED)
floorrad0 = floorrad1 = rhexf * .94;
else
floorrad0 = hexvdist * .9,
floorrad1 = rhexf * .8;
}
} }
transmatrix xspinpush(ld dir, ld dist) { transmatrix xspinpush(ld dir, ld dist) {
@ -243,7 +267,7 @@ namespace geom3 {
ld actual_wall_height() { ld actual_wall_height() {
if(GOLDBERG && gp_autoscale_heights) if(GOLDBERG && gp_autoscale_heights)
return wall_height * min<ld>(4 * gp::scale, 1); return wall_height * min<ld>(4 / hypot2(gp::next), 1);
return wall_height; return wall_height;
} }

View File

@ -2,7 +2,6 @@ namespace hr { namespace gp {
loc param(1, 0); loc param(1, 0);
hyperpoint next; hyperpoint next;
ld scale;
ld alpha; ld alpha;
int area; int area;
@ -582,9 +581,11 @@ namespace hr { namespace gp {
int y = param.second; int y = param.second;
area = ((2*x+y) * (2*x+y) + y*y*3) / 4; area = ((2*x+y) * (2*x+y) + y*y*3) / 4;
next = hpxyz(x+y/2., -y * sqrt(3) / 2, 0); next = hpxyz(x+y/2., -y * sqrt(3) / 2, 0);
scale = 1 / hypot2(next); ld scale = 1 / hypot2(next);
crossf *= scale; crossf *= scale;
hepvdist *= scale; hepvdist *= scale;
hexhexdist *= scale;
hexvdist *= scale;
rhexf *= scale; rhexf *= scale;
// spin = spintox(next); // spin = spintox(next);
// ispin = rspintox(next); // ispin = rspintox(next);
@ -600,7 +601,6 @@ namespace hr { namespace gp {
Xprintf("scale = " LDF "\n", scale); Xprintf("scale = " LDF "\n", scale);
} }
else { else {
scale = 1;
alpha = 0; alpha = 0;
} }
} }

View File

@ -4734,7 +4734,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if(vid.grid) { if(vid.grid) {
dynamicval<ld> lw(vid.linewidth, vid.linewidth); dynamicval<ld> lw(vid.linewidth, vid.linewidth);
if(GOLDBERG) vid.linewidth *= gp::scale * 2; vid.linewidth *= scalefactor;
// sphere: 0.3948 // sphere: 0.3948
// sphere heptagonal: 0.5739 // sphere heptagonal: 0.5739
@ -5082,8 +5082,7 @@ void drawFlashes() {
kill = tim > 300; kill = tim > 300;
int partcol = darkena(f.color, 0, max(255 - tim*255/300, 0)); int partcol = darkena(f.color, 0, max(255 - tim*255/300, 0));
poly_outline = OUTLINE_DEFAULT; poly_outline = OUTLINE_DEFAULT;
ld gps = GOLDBERG ? gp::scale * 1.6 : 1; queuepoly(V * spin(f.angle) * xpush(f.spd * tim * scalefactor / 50000.), shParticle[f.size], partcol);
queuepoly(V * spin(f.angle) * xpush(f.spd * tim * gps / 50000.), shParticle[f.size], partcol);
} }
else if(f.size == 1000) { else if(f.size == 1000) {

View File

@ -2745,7 +2745,6 @@ namespace irr {
extern ld density; extern ld density;
extern ld quality; extern ld quality;
extern int cellcount; extern int cellcount;
extern ld scale;
extern int place_attempts; extern int place_attempts;
extern int rearrange_max_attempts; extern int rearrange_max_attempts;
extern int rearrange_less; extern int rearrange_less;
@ -3073,6 +3072,9 @@ void queueline(const hyperpoint& H1, const hyperpoint& H2, int col, int prf = 0,
void queuelink(const string *link, PPR prio); void queuelink(const string *link, PPR prio);
extern ld tessf, crossf, hexf, hcrossf, hexhexdist, hexvdist, hepvdist, rhexf; extern ld tessf, crossf, hexf, hcrossf, hexhexdist, hexvdist, hepvdist, rhexf;
extern ld scalefactor, orbsize, floorrad0, floorrad1, zhexf;
unsigned char& part(int& col, int i); unsigned char& part(int& col, int i);
unsigned char& part(unsigned& col, int i); unsigned char& part(unsigned& col, int i);
@ -3331,7 +3333,6 @@ namespace gp {
typedef pair<int, int> loc; typedef pair<int, int> loc;
void compute_geometry(); void compute_geometry();
void extend_map(cell *c, int d); void extend_map(cell *c, int d);
extern ld scale;
extern loc param; extern loc param;
extern loc eudir(int dir); extern loc eudir(int dir);
extern int area; extern int area;

View File

@ -506,18 +506,17 @@ bool step(int delta) {
return false; return false;
} }
ld scale;
void compute_geometry() { void compute_geometry() {
if(IRREGULAR) { if(IRREGULAR) {
scale = sqrt(isize(cells_of_heptagon) * 1. / isize(cells)); ld scale = sqrt(isize(cells_of_heptagon) * 1. / isize(cells));
crossf *= scale; crossf *= scale;
hepvdist *= scale; hepvdist *= scale;
rhexf *= scale; rhexf *= scale;
hexhexdist *= scale;
hexvdist *= scale;
base_distlimit = (base_distlimit + log(scale) / log(2.618)) / scale; base_distlimit = (base_distlimit + log(scale) / log(2.618)) / scale;
if(base_distlimit > 25) base_distlimit = 25; if(base_distlimit > 25) base_distlimit = 25;
} }
else scale = 1;
} }
bool draw_cell_schematics(cell *c, transmatrix V) { bool draw_cell_schematics(cell *c, transmatrix V) {

File diff suppressed because it is too large Load Diff