mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 13:07:16 +00:00
gp:: replaced the magic constants 15, 16, 31, 32 with named constants derived from GOLDBERG_BITS
This commit is contained in:
parent
e567fa2033
commit
81e066d0c3
@ -837,8 +837,8 @@ EX namespace gp {
|
||||
EX void clear_plainshapes() {
|
||||
for(int m=0; m<3; m++)
|
||||
for(int sd=0; sd<8; sd++)
|
||||
for(int i=0; i<32; i++)
|
||||
for(int j=0; j<32; j++)
|
||||
for(int i=0; i<GOLDBERG_LIMIT; i++)
|
||||
for(int j=0; j<GOLDBERG_LIMIT; j++)
|
||||
for(int k=0; k<8; k++)
|
||||
cgi.gpdata->pshid[m][sd][i][j][k] = -1;
|
||||
cgi.gpdata->nextid = 0;
|
||||
@ -892,7 +892,7 @@ EX namespace gp {
|
||||
sidir = 0;
|
||||
}
|
||||
else f();
|
||||
auto& id = cgi.gpdata->pshid[siid][sidir][draw_li.relative.first&31][draw_li.relative.second&31][gmod(draw_li.total_dir, S6)];
|
||||
auto& id = cgi.gpdata->pshid[siid][sidir][draw_li.relative.first&GOLDBERG_MASK][draw_li.relative.second&GOLDBERG_MASK][gmod(draw_li.total_dir, S6)];
|
||||
if(id == -1 && sphere && isize(cgi.shFloor.b) > 0) {
|
||||
forCellEx(c1, c) if(!gmatrix0.count(c1)) return 0;
|
||||
}
|
||||
|
13
geometry.cpp
13
geometry.cpp
@ -50,6 +50,15 @@ struct hpcshape {
|
||||
#define SIDE_BSHA 12
|
||||
#define SIDEPARS 13
|
||||
|
||||
/** GOLDBERG_BITS controls the size of tables for Goldberg: 2*(x+y) should be below (1<<GOLDBERG_BITS) */
|
||||
|
||||
#ifndef GOLDBERG_BITS
|
||||
#define GOLDBERG_BITS 5
|
||||
#endif
|
||||
|
||||
static const int GOLDBERG_LIMIT = (1<<GOLDBERG_BITS);
|
||||
static const int GOLDBERG_MASK = (GOLDBERG_LIMIT-1);
|
||||
|
||||
#ifndef BADMODEL
|
||||
#define BADMODEL 0
|
||||
#endif
|
||||
@ -478,11 +487,11 @@ hpcshape
|
||||
/* Goldberg parameters */
|
||||
#if CAP_GP
|
||||
struct gpdata_t {
|
||||
vector<array<array<array<transmatrix, 6>, 32>, 32>> Tf;
|
||||
vector<array<array<array<transmatrix, 6>, GOLDBERG_LIMIT>, GOLDBERG_LIMIT>> Tf;
|
||||
transmatrix corners;
|
||||
ld alpha;
|
||||
int area;
|
||||
int pshid[3][8][32][32][8];
|
||||
int pshid[3][8][GOLDBERG_LIMIT][GOLDBERG_LIMIT][8];
|
||||
int nextid;
|
||||
};
|
||||
shared_ptr<gpdata_t> gpdata = nullptr;
|
||||
|
@ -68,7 +68,7 @@ transmatrix hrmap_standard::master_relative(cell *c, bool get_inverse) {
|
||||
}
|
||||
else {
|
||||
auto li = gp::get_local_info(c);
|
||||
transmatrix T = spin(master_to_c7_angle()) * cgi.gpdata->Tf[li.last_dir][li.relative.first&31][li.relative.second&31][gp::fixg6(li.total_dir)];
|
||||
transmatrix T = spin(master_to_c7_angle()) * cgi.gpdata->Tf[li.last_dir][li.relative.first&GOLDBERG_MASK][li.relative.second&GOLDBERG_MASK][gp::fixg6(li.total_dir)];
|
||||
if(get_inverse) T = iso_inverse(T);
|
||||
return T;
|
||||
}
|
||||
|
25
goldberg.cpp
25
goldberg.cpp
@ -101,12 +101,15 @@ EX namespace gp {
|
||||
|
||||
EX int fixg6(int x) { return gmod(x, SG6); }
|
||||
|
||||
const int GOLDBERG_LIMIT_HALF = GOLDBERG_LIMIT/2;
|
||||
const int GOLDBERG_MASK_HALF = GOLDBERG_MASK/2;
|
||||
|
||||
EX int get_code(const local_info& li) {
|
||||
return
|
||||
((li.relative.first & 15) << 0) +
|
||||
((li.relative.second & 15) << 4) +
|
||||
((fixg6(li.total_dir)) << 8) +
|
||||
((li.last_dir & 15) << 12);
|
||||
((li.relative.first & GOLDBERG_MASK_HALF) << 0) +
|
||||
((li.relative.second & GOLDBERG_MASK_HALF) << (GOLDBERG_BITS-1)) +
|
||||
((fixg6(li.total_dir)) << (2*GOLDBERG_BITS-2)) +
|
||||
((li.last_dir & 15) << (2*GOLDBERG_BITS+2));
|
||||
}
|
||||
|
||||
EX local_info get_local_info(cell *c) {
|
||||
@ -162,9 +165,9 @@ EX namespace gp {
|
||||
// goldberg_map[y][x].cw is the cellwalker in this triangle at position (x,y)
|
||||
// facing local direction 0
|
||||
|
||||
goldberg_mapping_t goldberg_map[32][32];
|
||||
goldberg_mapping_t goldberg_map[GOLDBERG_LIMIT][GOLDBERG_LIMIT];
|
||||
void clear_mapping() {
|
||||
for(int y=0; y<32; y++) for(int x=0; x<32; x++) {
|
||||
for(int y=0; y<GOLDBERG_LIMIT; y++) for(int x=0; x<GOLDBERG_LIMIT; x++) {
|
||||
goldberg_map[y][x].cw.at = NULL;
|
||||
goldberg_map[y][x].rdir = -1;
|
||||
goldberg_map[y][x].mindir = 0;
|
||||
@ -172,7 +175,7 @@ EX namespace gp {
|
||||
}
|
||||
|
||||
goldberg_mapping_t& get_mapping(loc c) {
|
||||
return goldberg_map[c.second&31][c.first&31];
|
||||
return goldberg_map[c.second&GOLDBERG_MASK][c.first&GOLDBERG_MASK];
|
||||
}
|
||||
|
||||
int spawn;
|
||||
@ -599,14 +602,14 @@ EX namespace gp {
|
||||
cgi.gpdata->Tf.resize(S7);
|
||||
for(int i=0; i<S7; i++) {
|
||||
transmatrix T = dir_matrix(i);
|
||||
for(int x=-16; x<16; x++)
|
||||
for(int y=-16; y<16; y++)
|
||||
for(int x=-GOLDBERG_LIMIT_HALF; x<GOLDBERG_LIMIT_HALF; x++)
|
||||
for(int y=-GOLDBERG_LIMIT_HALF; y<GOLDBERG_LIMIT_HALF; y++)
|
||||
for(int d=0; d<(S3==3?6:4); d++) {
|
||||
loc at = loc(x, y);
|
||||
|
||||
hyperpoint h = atz(T, cgi.gpdata->corners, at, 6);
|
||||
hyperpoint hl = atz(T, cgi.gpdata->corners, at + eudir(d), 6);
|
||||
cgi.gpdata->Tf[i][x&31][y&31][d] = rgpushxto0(h) * rspintox(gpushxto0(h) * hl) * spin(M_PI);
|
||||
cgi.gpdata->Tf[i][x&GOLDBERG_MASK][y&GOLDBERG_MASK][d] = rgpushxto0(h) * rspintox(gpushxto0(h) * hl) * spin(M_PI);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -616,7 +619,7 @@ EX namespace gp {
|
||||
if(i == -1)
|
||||
return atz(dir_matrix(cid), cgi.gpdata->corners, li.relative, 0, cf);
|
||||
else {
|
||||
auto& cellmatrix = cgi.gpdata->Tf[i][li.relative.first&31][li.relative.second&31][fixg6(li.total_dir)];
|
||||
auto& cellmatrix = cgi.gpdata->Tf[i][li.relative.first&GOLDBERG_MASK][li.relative.second&GOLDBERG_MASK][fixg6(li.total_dir)];
|
||||
return inverse(cellmatrix) * atz(dir_matrix(i), cgi.gpdata->corners, li.relative, fixg6(cid + li.total_dir), cf);
|
||||
}
|
||||
}
|
||||
|
@ -1588,7 +1588,7 @@ void drawrec(cell *c, const transmatrix& V) {
|
||||
|
||||
bool drawrec(cell *c, const shiftmatrix& V, gp::loc at, int dir, int maindir) {
|
||||
bool res = false;
|
||||
shiftmatrix V1 = V * cgi.gpdata->Tf[draw_li.last_dir][at.first&31][at.second&31][fixg6(dir)];
|
||||
shiftmatrix V1 = V * cgi.gpdata->Tf[draw_li.last_dir][at.first&GOLDBERG_MASK][at.second&GOLDBERG_MASK][fixg6(dir)];
|
||||
if(do_draw(c, V1)) {
|
||||
/* auto li = get_local_info(c);
|
||||
if((dir - li.total_dir) % S6) printf("totaldir %d/%d\n", dir, li.total_dir);
|
||||
|
Loading…
Reference in New Issue
Block a user