mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-07 14:40:13 +00:00
standard draw algorithm no longer recursive; prettier gp::drawrec
This commit is contained in:
parent
62a5c0abac
commit
b4671e4d50
@ -61,7 +61,7 @@ transmatrix calc_relative_matrix(cell *c2, cell *c1, const hyperpoint& point_hin
|
|||||||
auto bak = gp::draw_li;
|
auto bak = gp::draw_li;
|
||||||
swap(gmatrix, gmatrix0);
|
swap(gmatrix, gmatrix0);
|
||||||
just_gmatrix = true;
|
just_gmatrix = true;
|
||||||
drawrec(viewctr, hsOrigin, Id);
|
drawStandard();
|
||||||
just_gmatrix = false;
|
just_gmatrix = false;
|
||||||
swap(gmatrix, gmatrix0);
|
swap(gmatrix, gmatrix0);
|
||||||
gp::draw_li = bak;
|
gp::draw_li = bak;
|
||||||
|
2
hyper.h
2
hyper.h
@ -3858,7 +3858,7 @@ void queuestr(const hyperpoint& h, int size, const string& chr, color_t col, int
|
|||||||
void queuechr(const transmatrix& V, double size, char chr, color_t col, int frame = 0);
|
void queuechr(const transmatrix& V, double size, char chr, color_t col, int frame = 0);
|
||||||
|
|
||||||
extern bool just_gmatrix;
|
extern bool just_gmatrix;
|
||||||
void drawrec(const heptspin& hs, hstate s, const transmatrix& V, int reclev = 0);
|
void drawStandard();
|
||||||
|
|
||||||
bool haveLeaderboard(int id);
|
bool haveLeaderboard(int id);
|
||||||
int get_currentscore(int id);
|
int get_currentscore(int id);
|
||||||
|
111
hypgraph.cpp
111
hypgraph.cpp
@ -735,14 +735,14 @@ void drawrec(cell *c, const transmatrix& V) {
|
|||||||
|
|
||||||
bool drawrec(cell *c, const transmatrix& V, gp::loc at, int dir, int maindir) {
|
bool drawrec(cell *c, const transmatrix& V, gp::loc at, int dir, int maindir) {
|
||||||
bool res = false;
|
bool res = false;
|
||||||
if(do_draw(c, V)) {
|
transmatrix V1 = V * Tf[draw_li.last_dir][at.first&31][at.second&31][fixg6(dir)];
|
||||||
|
if(do_draw(c, V1)) {
|
||||||
/* auto li = get_local_info(c);
|
/* auto li = get_local_info(c);
|
||||||
if(fix6(dir) != fix6(li.total_dir)) printf("totaldir %d/%d\n", dir, li.total_dir);
|
if(fix6(dir) != fix6(li.total_dir)) printf("totaldir %d/%d\n", dir, li.total_dir);
|
||||||
if(at != li.relative) printf("at %s/%s\n", disp(at), disp(li.relative));
|
if(at != li.relative) printf("at %s/%s\n", disp(at), disp(li.relative));
|
||||||
if(maindir != li.last_dir) printf("ld %d/%d\n", maindir, li.last_dir); */
|
if(maindir != li.last_dir) printf("ld %d/%d\n", maindir, li.last_dir); */
|
||||||
draw_li.relative = at;
|
draw_li.relative = at;
|
||||||
draw_li.total_dir = fixg6(dir);
|
draw_li.total_dir = fixg6(dir);
|
||||||
transmatrix V1 = V * Tf[draw_li.last_dir][at.first&31][at.second&31][fixg6(dir)];
|
|
||||||
drawcell(c, V1, 0, false);
|
drawcell(c, V1, 0, false);
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
@ -775,61 +775,70 @@ void drawrec(cell *c, const transmatrix& V) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawrec(const heptspin& hs, hstate s, const transmatrix& V, int reclev) {
|
vector<tuple<heptspin, hstate, transmatrix, ld> > drawn_cells;
|
||||||
|
|
||||||
// calc_relative_matrix(cwt.c, hs.at);
|
void drawStandard() {
|
||||||
cell *c = hs.at->c7;
|
drawn_cells.clear();
|
||||||
|
drawn_cells.emplace_back(viewctr, hsOrigin, cview(), band_shift);
|
||||||
transmatrix V10;
|
for(int i=0; i<isize(drawn_cells); i++) {
|
||||||
const transmatrix& V1 = hs.mirrored ? (V10 = V * Mirror) : V;
|
const auto& dc = drawn_cells[i];
|
||||||
|
auto& hs = get<0>(dc);
|
||||||
bool draw = false;
|
auto& s = get<1>(dc);
|
||||||
|
auto& V = get<2>(dc);
|
||||||
if(GOLDBERG) {
|
dynamicval<ld> bs(band_shift, get<3>(dc));
|
||||||
draw = gp::drawrec(c, actualV(hs, V1));
|
|
||||||
}
|
|
||||||
|
|
||||||
else if(IRREGULAR) {
|
|
||||||
auto& hi = irr::periodmap[hs.at];
|
|
||||||
transmatrix V0 = actualV(hs, V1);
|
|
||||||
auto& vc = irr::cells_of_heptagon[hi.base.at];
|
|
||||||
for(int i=0; i<isize(vc); i++) {
|
|
||||||
cell *c = hi.subcells[i];
|
|
||||||
transmatrix V1 = V0 * irr::cells[vc[i]].pusher;
|
|
||||||
if(do_draw(c, V1))
|
|
||||||
draw = true,
|
|
||||||
drawcell(hi.subcells[i], V0 * irr::cells[vc[i]].pusher, 0, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
if(do_draw(c, V1)) {
|
|
||||||
transmatrix V2 = actualV(hs, V1);
|
|
||||||
drawcell(c, V2, 0, hs.mirrored);
|
|
||||||
draw = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(BITRUNCATED) for(int d=0; d<S7; d++) {
|
cell *c = hs.at->c7;
|
||||||
int ds = hs.at->c.fix(hs.spin + d);
|
|
||||||
// createMov(c, ds);
|
transmatrix V10;
|
||||||
if(c->move(ds) && c->c.spin(ds) == 0) {
|
const transmatrix& V1 = hs.mirrored ? (V10 = V * Mirror) : V;
|
||||||
transmatrix V2 = V1 * hexmove[d];
|
|
||||||
if(do_draw(c->move(ds), V2))
|
bool draw = false;
|
||||||
|
|
||||||
|
if(GOLDBERG) {
|
||||||
|
draw = gp::drawrec(c, actualV(hs, V1));
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(IRREGULAR) {
|
||||||
|
auto& hi = irr::periodmap[hs.at];
|
||||||
|
transmatrix V0 = actualV(hs, V1);
|
||||||
|
auto& vc = irr::cells_of_heptagon[hi.base.at];
|
||||||
|
for(int i=0; i<isize(vc); i++) {
|
||||||
|
cell *c = hi.subcells[i];
|
||||||
|
transmatrix V1 = V0 * irr::cells[vc[i]].pusher;
|
||||||
|
if(do_draw(c, V1))
|
||||||
draw = true,
|
draw = true,
|
||||||
drawcell(c->move(ds), V2, 0, hs.mirrored ^ c->c.mirror(ds));
|
drawcell(hi.subcells[i], V0 * irr::cells[vc[i]].pusher, 0, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
else {
|
||||||
if(draw) for(int d=0; d<S7; d++) {
|
if(do_draw(c, V1)) {
|
||||||
hstate s2 = transition(s, d);
|
transmatrix V2 = actualV(hs, V1);
|
||||||
if(s2 == hsError) continue;
|
drawcell(c, V2, 0, hs.mirrored);
|
||||||
heptspin hs2 = hs + d + wstep;
|
draw = true;
|
||||||
transmatrix Vd = V * heptmove[d];
|
}
|
||||||
bandfixer bf(Vd);
|
|
||||||
drawrec(hs2, s2, Vd, reclev+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(BITRUNCATED) for(int d=0; d<S7; d++) {
|
||||||
|
int ds = hs.at->c.fix(hs.spin + d);
|
||||||
|
// createMov(c, ds);
|
||||||
|
if(c->move(ds) && c->c.spin(ds) == 0) {
|
||||||
|
transmatrix V2 = V1 * hexmove[d];
|
||||||
|
if(do_draw(c->move(ds), V2))
|
||||||
|
draw = true,
|
||||||
|
drawcell(c->move(ds), V2, 0, hs.mirrored ^ c->c.mirror(ds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(draw) for(int d=0; d<S7; d++) {
|
||||||
|
hstate s2 = transition(s, d);
|
||||||
|
if(s2 == hsError) continue;
|
||||||
|
heptspin hs2 = hs + d + wstep;
|
||||||
|
transmatrix Vd = V * heptmove[d];
|
||||||
|
bandfixer bf(Vd);
|
||||||
|
drawn_cells.emplace_back(hs2, s2, Vd, band_shift);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int mindx=-7, mindy=-7, maxdx=7, maxdy=7;
|
int mindx=-7, mindy=-7, maxdx=7, maxdy=7;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user