drawcell parameter is now cell, not cellwalker (need to check half-elliptic)

This commit is contained in:
Zeno Rogue 2019-11-25 20:05:52 +01:00
parent 3f76943453
commit 622b683e33
9 changed files with 56 additions and 68 deletions

View File

@ -5,7 +5,7 @@ namespace hr {
int coastvalEdge(cell *c);
struct celldrawer {
cellwalker cw;
cell *c;
transmatrix V;
color_t fcol;
@ -64,16 +64,14 @@ struct celldrawer {
void do_viewdist();
};
inline void drawcell(const cellwalker& cw, const transmatrix& V) {
inline void drawcell(cell *c, const transmatrix& V) {
celldrawer dd;
dd.cw = cw;
dd.c = c;
dd.V = V;
dd.draw();
}
#endif
#define c (cw.at)
static const int trapcol[4] = {0x904040, 0xA02020, 0xD00000, 0x303030};
static const int terracol[8] = {0xD000, 0xE25050, 0xD0D0D0, 0x606060, 0x303030, 0x181818, 0x0080, 0x8080};
@ -1706,7 +1704,7 @@ void celldrawer::bookkeeping() {
if(playerpos(i) == c) {
playerV = V * ddspin(c, multi::player[i].spin, 0);
if(multi::player[i].mirrored) playerV = playerV * Mirror;
if(multi::player[i].mirrored == cw.mirrored)
if(orig)
multi::whereis[i] = playerV;
}
}
@ -2184,7 +2182,7 @@ void celldrawer::draw_monster_full() {
#if CAP_SHAPES
int q = isize(ptds);
#endif
bool m = drawMonster(V, c->type, c, moncol, cw.mirrored, asciicol);
bool m = drawMonster(V, c->type, c, moncol, asciicol);
if(m) error = true;
if(m || c->monst) onradar = false;
#if CAP_SHAPES
@ -2362,7 +2360,8 @@ void celldrawer::draw_gravity_particles() {
}
void celldrawer::draw() {
if(hybrid::pmap) { product::drawcell_stack(cw, V); return; }
if(hybrid::pmap) { product::drawcell_stack(c, V); return; }
cells_drawn++;
@ -2396,16 +2395,15 @@ void celldrawer::draw() {
if(inmirror(c)) {
if(inmirrorcount >= 10) return;
cellwalker cw2 = cw;
cw2.spin = 0;
cw2 = mirror::reflect(cw);
cellwalker cw(c);
cellwalker cw2 = mirror::reflect(cw);
int cmc = (cw2.mirrored == cw.mirrored) ? 2 : 1;
inmirrorcount += cmc;
draw_grid();
if(cw2.mirrored != cw.mirrored) V = V * Mirror;
if(cw2.spin) V = V * spin(2*M_PI*cw2.spin/cw2.at->type);
cw2.spin = 0;
drawcell(cw2, V);
drawcell(cw2.at, V);
inmirrorcount -= cmc;
return;
}

View File

@ -643,8 +643,6 @@ color_t distribute_color(int id) {
void celldrawer::do_viewdist() {
if(behindsphere(V)) return;
cell *c = cw.at;
int cd = (use_color_codes || number_coding == ncDistance || number_coding == ncDebug) ? curr_dist(c) : 0;
if(use_color_codes) {

View File

@ -2321,7 +2321,7 @@ void drawWormSegments() {
EX bool dont_face_pc = false;
EX bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col, bool mirrored, color_t asciicol) {
EX bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col, color_t asciicol) {
#if CAP_SHAPES
bool darkhistory = history::includeHistory && history::inkillhistory.count(c);
@ -2342,6 +2342,7 @@ EX bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col, boo
eMonster m = c->monst;
bool half_elliptic = elliptic && GDIM == 3 && WDIM == 2;
bool mirrored = det(Vparam) > 0;
if(!m) ;
@ -3805,7 +3806,6 @@ EX void fallingMonsterAnimation(cell *c, eMonster m, int id IS(multi::cpid)) {
}
void celldrawer::draw_fallanims() {
cell*& c = cw.at;
poly_outline = OUTLINE_NONE;
if(fallanims.count(c)) {
int q = isize(ptds);
@ -3825,7 +3825,7 @@ void celldrawer::draw_fallanims() {
celldrawer ddalt;
eWall w = c->wall; int p = c->wparam;
c->wall = fa.walltype; c->wparam = fa.m;
ddalt.cw.at = c;
ddalt.c = c;
ddalt.setcolors();
int starcol = c->wall == waVinePlant ? 0x60C000 : ddalt.wcol;
c->wall = w; c->wparam = p;

View File

@ -1138,6 +1138,46 @@ vector<tuple<heptspin, hstate, transmatrix, ld> > drawn_cells;
bool in_multi = false;
bool drawcell_subs(cell *c, transmatrix V) {
#if CAP_GP
if(GOLDBERG) {
return gp::drawrec(c, V);
}
#endif
bool draw = false;
#if CAP_IRR
if(IRREGULAR) {
auto& hi = irr::periodmap[c->master];
auto& vc = irr::cells_of_heptagon[hi.base.at];
for(int i=0; i<isize(vc); i++) {
cell *c = hi.subcells[i];
transmatrix V1 = V * irr::cells[vc[i]].pusher;
if(do_draw(c, V1))
draw = true,
drawcell(hi.subcells[i], V * irr::cells[vc[i]].pusher);
}
return draw;
}
#endif
if(do_draw(c, V))
drawcell(c, V);
if(BITRUNCATED) forCellIdEx(c1, d, c) {
if(c->c.spin(d) == 0) {
transmatrix V2 = V * currentmap->adj(c, d);
if(do_draw(c1, V2))
draw = true,
drawcell(c1, V2);
}
}
return draw;
}
void hrmap_standard::draw() {
if(sphere && pmodel == mdSpiral && !in_multi) {
in_multi = true;
@ -1181,49 +1221,7 @@ void hrmap_standard::draw() {
transmatrix V10;
const transmatrix& V1 = hs.mirrored ? (V10 = V * Mirror) : V;
bool draw = false;
if(0) ;
#if CAP_GP
else if(GOLDBERG) {
draw = gp::drawrec(c, actualV(hs, V1));
}
#endif
#if CAP_IRR
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);
}
}
#endif
else {
if(do_draw(c, V1)) {
transmatrix V2 = actualV(hs, V1);
drawcell(cellwalker(c, 0, hs.mirrored), V2);
draw = true;
}
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 * cgi.hexmove[d];
if(do_draw(c->move(ds), V2))
draw = true,
drawcell(cellwalker(c->move(ds), 0, hs.mirrored ^ c->c.mirror(ds)), V2);
}
}
}
bool draw = drawcell_subs(c, actualV(hs, V1));
if(sphere) draw = true;

View File

@ -1245,8 +1245,7 @@ EX namespace product {
if(z == 1) cwall_mask ^= (1<<c->type);
cell *c1 = hybrid::get_at(c, actual_view_level+z);
setdist(c1, 7, NULL);
cw.at = c1;
drawcell(cw, V * mscale(Id, cgi.plevel * (z+actual_view_level - z0)));
drawcell(c1, V * mscale(Id, cgi.plevel * (z+actual_view_level - z0)));
}
});
}

View File

@ -67,7 +67,6 @@ EX void addradar(const hyperpoint h1, const hyperpoint h2, color_t col) {
}
void celldrawer::drawcell_in_radar() {
cell *c = cw.at;
#if CAP_SHMUP
if(shmup::on) {
pair<shmup::mit, shmup::mit> p =
@ -85,7 +84,6 @@ void celldrawer::drawcell_in_radar() {
}
void celldrawer::radar_grid() {
cell *c = cw.at;
for(int t=0; t<c->type; t++)
if(c->move(t) && c->move(t) < c)
addradar(V*get_corner_position(c, t%c->type), V*get_corner_position(c, (t+1)%c->type), gridcolor(c, c->move(t)));

View File

@ -906,7 +906,7 @@ EX void cast() {
connections[u][1] = code[1];
if(isWall3(c1)) {
celldrawer dd;
dd.cw.at = c1;
dd.c = c1;
dd.setcolors();
transmatrix Vf;
dd.set_land_floor(Vf);

View File

@ -2875,7 +2875,6 @@ auto hooksw = addHook(hooks_swapdim, 100, [] {
bool celldrawer::draw_shmup_monster() {
using namespace shmup;
auto& c = cw.at;
#if CAP_SHAPES
pair<mit, mit> p =

View File

@ -133,8 +133,6 @@ void celldrawer::draw_ceiling() {
if(pmodel != mdPerspective || sphere) return;
cell *c = cw.at;
switch(ceiling_category(c)) {
/* ceilingless levels */
case 1: {