diff --git a/floorshapes.cpp b/floorshapes.cpp index 4a58a552..3ba17b1f 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -131,7 +131,7 @@ void generate_matrices_scale(ld scale, int noft) { } } -void bshape2(hpcshape& sh, int p, int shapeid, matrixlist& m) { +void bshape2(hpcshape& sh, PPR prio, int shapeid, matrixlist& m) { auto& matrices = m.v; int osym = m.o.sym; int nsym = m.n.sym; @@ -175,7 +175,7 @@ void bshape2(hpcshape& sh, int p, int shapeid, matrixlist& m) { rots /= rep; } - bshape(sh, p); + bshape(sh, prio); for(int r=0; r &shv, int col, int prio = -1) { +void draw_shapevec(cell *c, const transmatrix& V, const vector &shv, int col, PPR prio = PPR_DEFAULT) { if(!c) queuepolyat(V, shv[0], col, prio); else if(gp::on) { int id = gp::get_plainshape_id(c); @@ -636,11 +636,11 @@ void draw_shapevec(cell *c, const transmatrix& V, const vector &shv, i queuepolyat(V, shv[ctof(c)], col, prio); } -void draw_floorshape(cell *c, const transmatrix& V, const floorshape &fsh, int col, int prio = -1) { +void draw_floorshape(cell *c, const transmatrix& V, const floorshape &fsh, int col, PPR prio = PPR_DEFAULT) { draw_shapevec(c, V, fsh.b, col, prio); } -void draw_qfi(cell *c, const transmatrix& V, int col, int prio = -1, vector floorshape::* tab = &floorshape::b) { +void draw_qfi(cell *c, const transmatrix& V, int col, PPR prio = PPR_DEFAULT, vector floorshape::* tab = &floorshape::b) { if(qfi.shape) queuepolyat(V * qfi.spin, *qfi.shape, col, prio); else if(qfi.usershape >= 0) { @@ -649,7 +649,7 @@ void draw_qfi(cell *c, const transmatrix& V, int col, int prio = -1, vectorvertices, isize(qfi.tinf->vertices), texture::config.mesh_color, texture::config.recolor(col), prio == -1 ? PPR_FLOOR : prio); + queuetable(V * qfi.spin, qfi.tinf->vertices, isize(qfi.tinf->vertices), texture::config.mesh_color, texture::config.recolor(col), prio == PPR_DEFAULT ? PPR_FLOOR : prio); lastptd().u.poly.tinf = qfi.tinf; if(true) lastptd().u.poly.flags = POLY_INVERSE; diff --git a/graph.cpp b/graph.cpp index e2f52a0f..4c0d7a9b 100644 --- a/graph.cpp +++ b/graph.cpp @@ -466,7 +466,7 @@ void animallegs(const transmatrix& V, eMonster mo, int col, double footphase) { bool noshadow; -void ShadowV(const transmatrix& V, const hpcshape& bp, int prio) { +void ShadowV(const transmatrix& V, const hpcshape& bp, PPR prio) { #if CAP_POLY if(mmspatial) { if(pmodel == mdHyperboloid || pmodel == mdBall || pmodel == mdHemisphere || noshadow) @@ -565,6 +565,10 @@ bool drawstar(cell *c) { return true; } +bool drawing_usershape_on(cell *c, mapeditor::eShapegroup sg) { + return c && c == mapeditor::drawcell && mapeditor::drawcellShapeGroup() == mapeditor::sgItem; + } + bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks, bool hidden) { char xch = iinf[it].glyph; #if !CAP_POLY @@ -604,9 +608,6 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks, if(c && conformal::includeHistory && conformal::infindhistory.count(c)) poly_outline = OUTLINE_DEAD; - if(c == mapeditor::drawcell && mapeditor::drawcellShapeGroup() == mapeditor::sgItem) - mapeditor::drawtrans = V; - if(!mmitem && it) return true; else if(it == itSavedPrincess) { @@ -691,7 +692,7 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks, if(xsh == &shBookCover && mmitem) queuepoly(V2, shBook, 0x805020FF); - int pr = PPR_ITEM; + PPR pr = PPR_ITEM; int alpha = hidden ? (it == itKraken ? 0xC0 : 0x40) : 0xF0; if(c && c->wall == waIcewall) pr = PPR_HIDDEN, alpha = 0x80; @@ -705,9 +706,9 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks, else if(xch == 'o' || it == itInventory) { if(it == itOrbFire) icol = firecolor(100); - int pr = PPR_ITEM; + PPR prio = PPR_ITEM; bool inice = c && c->wall == waIcewall; - if(inice) pr = PPR_HIDDEN; + if(inice) prio = PPR_HIDDEN; int icol1 = icol; if(it == itOrbFire) icol = firecolor(200); @@ -724,7 +725,7 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks, if(it == itOrbFish) queuepolyat(V * spin(ticks / 1500.), shFishTail, col, PPR_ITEM_BELOW); - queuepolyat(V, shDisk, darkena(icol1, 0, inice ? 0x80 : hidden ? 0x20 : 0xC0), pr); + queuepolyat(V, shDisk, darkena(icol1, 0, inice ? 0x80 : hidden ? 0x20 : 0xC0), prio); hpcshape& sh = it == itOrbLove ? shLoveRing : isRangedOrb(it) ? shTargetRing : @@ -734,7 +735,7 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks, isDirectionalOrb(it) ? shSpearRing : it == itOrb37 ? shHeptaRing : shRing; - queuepolyat(V * spin(ticks / 1500.), sh, col, pr); + queuepolyat(V * spin(ticks / 1500.), sh, col, prio); } else if(it) return true; @@ -770,9 +771,6 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou else if(where && !(isMetalBeast(m) && where->stuntime == 1)) drawStunStars(V, where->stuntime); - if(where == mapeditor::drawcell && mapeditor::drawcellShapeGroup() == (m == moPlayer ? mapeditor::sgPlayer : mapeditor::sgMonster)) - mapeditor::drawtrans = V; - if(m == moTortoise) { int bits = where ? tortoise::getb(where) : tortoise::last; tortoise::draw(V, bits, 0, where ? where->stuntime : 0); @@ -1876,13 +1874,8 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) { length = cellgfxdist(c, c->mondir); } - if(c == mapeditor::drawcell && mapeditor::drawcellShapeGroup() == 1) - mapeditor::drawtrans = Vb; - - if(mapeditor::drawUserShape(Vb, mapeditor::sgMonster, c->monst, (col << 8) + 0xFF, c)) { - if(c == mapeditor::drawcell) mapeditor::drawtrans = Vb; + if(mapeditor::drawUserShape(Vb, mapeditor::sgMonster, c->monst, (col << 8) + 0xFF, c)) return false; - } if(isIvy(c) || isMutantIvy(c) || c->monst == moFriendlyIvy) queuepoly(Vb, shIBranch, (col << 8) + 0xFF); @@ -3160,28 +3153,28 @@ void escherSidewall(cell *c, int sidepar, const transmatrix& V, int col) { if(sidepar >= SIDE_SLEV && sidepar <= SIDE_SLEV+2) { int sl = sidepar - SIDE_SLEV; for(int z=1; z<=4; z++) if(z == 1 || (z == 4 && detaillevel == 2)) - draw_qfi(c, mscale(V, zgrad0(geom3::slev * sl, geom3::slev * (sl+1), z, 4)), col, PPR_REDWALL-4+z+4*sl); + draw_qfi(c, mscale(V, zgrad0(geom3::slev * sl, geom3::slev * (sl+1), z, 4)), col, PPR(PPR_REDWALL-4+z+4*sl)); } else if(sidepar == SIDE_WALL) { const int layers = 2 << detaillevel; for(int z=1; zmove(i))) return false; if(qfi.fshape == &shTriheptaFloor && !pseudohept(c) && !pseudohept(c->move(i))) return false; - int prio; + PPR prio; /* if(mirr) prio = PPR_GLASS - 2; - else */ if(sidepar == SIDE_WALL) prio = PPR_WALL3 - 2; - else if(sidepar == SIDE_WTS3) prio = PPR_WALL3 - 2; + else */ if(sidepar == SIDE_WALL) prio = PPR(PPR_WALL3 - 2); + else if(sidepar == SIDE_WTS3) prio = PPR(PPR_WALL3 - 2); else if(sidepar == SIDE_LAKE) prio = PPR_LAKEWALL; else if(sidepar == SIDE_LTOB) prio = PPR_INLAKEWALL; else if(sidepar == SIDE_BTOI) prio = PPR_BELOWBOTTOM; - else prio = PPR_REDWALL-2+4*(sidepar-SIDE_SLEV); + else prio = PPR(PPR_REDWALL-2+4*(sidepar-SIDE_SLEV)); transmatrix V2 = V * ddspin(c, i); @@ -3422,7 +3415,7 @@ void draw_wall(cell *c, const transmatrix& V, int wcol, int& zcol, int ct6, int for(int z=1; zwall == waMagma) fd = 0; @@ -3795,7 +3788,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { bool eoh = euclid || nonbitrunc; - if(c == mapeditor::drawcell) + if(drawing_usershape_on(c, mapeditor::sgFloor)) mapeditor::drawtrans = V * applyPatterndir(c, si); if(c->wall == waChasm) { @@ -3858,7 +3851,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { if(wmspatial) { const int layers = 2 << detaillevel; for(int z=1; z p(poly_outline, OUTLINE_TRANS); queuepolyat(V2 * spin(M_PI*2/3), shSemiFloorShadow, SHADOW_WALL, PPR_WALLSHADOW); } - queuepolyat(V2, shSemiFloorSide[SIDE_WALL], darkena(vcol, fd, 0xFF), PPR_WALL3A-2+away(V2)); + queuepolyat(V2, shSemiFloorSide[SIDE_WALL], darkena(vcol, fd, 0xFF), PPR(PPR_WALL3A-2+away(V2))); if(validsidepar[SIDE_WALL]) forCellIdEx(c2, j, c) { int dis = i-j; @@ -4275,20 +4268,20 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { if(detaillevel >= 2) queuepolyat(mmscale(V, zgrad0(0, geom3::slev, 1, 2)), shHeptaMarker, darkena(wcol, 0, 0xFF), PPR_REDWALL); if(detaillevel >= 1) - queuepolyat(mmscale(V, geom3::SLEV[1]) * pispin, shWeakBranch, darkena(wcol, 0, 0xFF), PPR_REDWALL+1); + queuepolyat(mmscale(V, geom3::SLEV[1]) * pispin, shWeakBranch, darkena(wcol, 0, 0xFF), PPR(PPR_REDWALL+1)); if(detaillevel >= 2) - queuepolyat(mmscale(V, zgrad0(0, geom3::slev, 3, 2)), shHeptaMarker, darkena(wcol, 0, 0xFF), PPR_REDWALL+2); - queuepolyat(mmscale(V, geom3::SLEV[2]), shSolidBranch, darkena(wcol, 0, 0xFF), PPR_REDWALL+3); + queuepolyat(mmscale(V, zgrad0(0, geom3::slev, 3, 2)), shHeptaMarker, darkena(wcol, 0, 0xFF), PPR(PPR_REDWALL+2)); + queuepolyat(mmscale(V, geom3::SLEV[2]), shSolidBranch, darkena(wcol, 0, 0xFF), PPR(PPR_REDWALL+3)); break; case waSmallBush: if(detaillevel >= 2) queuepolyat(mmscale(V, zgrad0(0, geom3::slev, 1, 2)), shHeptaMarker, darkena(wcol, 0, 0xFF), PPR_REDWALL); if(detaillevel >= 1) - queuepolyat(mmscale(V, geom3::SLEV[1]) * pispin, shWeakBranch, darkena(wcol, 0, 0xFF), PPR_REDWALL+1); + queuepolyat(mmscale(V, geom3::SLEV[1]) * pispin, shWeakBranch, darkena(wcol, 0, 0xFF), PPR(PPR_REDWALL+1)); if(detaillevel >= 2) - queuepolyat(mmscale(V, zgrad0(0, geom3::slev, 3, 2)), shHeptaMarker, darkena(wcol, 0, 0xFF), PPR_REDWALL+2); - queuepolyat(mmscale(V, geom3::SLEV[2]), shWeakBranch, darkena(wcol, 0, 0xFF), PPR_REDWALL+3); + queuepolyat(mmscale(V, zgrad0(0, geom3::slev, 3, 2)), shHeptaMarker, darkena(wcol, 0, 0xFF), PPR(PPR_REDWALL+2)); + queuepolyat(mmscale(V, geom3::SLEV[2]), shWeakBranch, darkena(wcol, 0, 0xFF), PPR(PPR_REDWALL+3)); break; case waSolidBranch: @@ -4305,8 +4298,8 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { draw_floorshape(c, V, shMFloor2, 0x000000FF); } else { - draw_floorshape(c, V, shFloor, 0x804000FF, PPR_FLOOR+1); - draw_floorshape(c, V, shMFloor, 0x000000FF, PPR_FLOOR+2); + draw_floorshape(c, V, shFloor, 0x804000FF, PPR(PPR_FLOOR+1)); + draw_floorshape(c, V, shMFloor, 0x000000FF, PPR(PPR_FLOOR+2)); } break; @@ -4458,7 +4451,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { for(int z=1; z& t, int fillcol, int linecol, int lev); polytodraw& lastptd(); -void queuepolyat(const transmatrix& V, const hpcshape& h, int col, int prio); -void queuetable(const transmatrix& V, const vector& f, int cnt, int linecol, int fillcol, int prio); +void queuepolyat(const transmatrix& V, const hpcshape& h, int col, PPR prio); +void queuetable(const transmatrix& V, const vector& f, int cnt, int linecol, int fillcol, PPR prio); struct floorshape; @@ -3556,7 +3561,8 @@ extern qfloorinfo qfi; extern int chasmg; struct hpcshape { - int s, e, prio; + int s, e; + PPR prio; int flags; }; @@ -3690,7 +3696,7 @@ namespace gp { extern bool debug_geometry; void queuepoly(const transmatrix& V, const hpcshape& h, int col); -void queuepolyat(const transmatrix& V, const hpcshape& h, int col, int prio); +void queuepolyat(const transmatrix& V, const hpcshape& h, int col, PPR prio); void queuestr(const hyperpoint& h, int size, const string& chr, int col, int frame = 0); void queuechr(const transmatrix& V, double size, char chr, int col, int frame = 0); @@ -3748,7 +3754,8 @@ void set_blizzard_frame(cell *c, int frameid); struct floorshape { bool is_plain; - int shapeid, prio; + int shapeid; + PPR prio; vector b, shadow, side[SIDEPARS], gpside[SIDEPARS][MAX_EDGE]; floorshape() { prio = PPR_FLOOR; } }; diff --git a/mapeditor.cpp b/mapeditor.cpp index e9e0db26..52d9d64b 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -546,7 +546,7 @@ namespace mapeditor { return si.id + patterns::subcode(drawcell, si); } - bool editingShape(int group, int id) { + bool editingShape(eShapegroup group, int id) { if(group != mapeditor::drawcellShapeGroup()) return false; return id == drawcellShapeID(); } @@ -1701,11 +1701,14 @@ namespace mapeditor { #endif } - bool drawUserShape(transmatrix V, eShapegroup group, int id, int color, cell *c, int priority) { + bool drawUserShape(const transmatrix& V, eShapegroup group, int id, int color, cell *c, PPR prio) { #if !CAP_EDIT return false; #else + if(c == drawcell && editingShape(group, id) && prio == PPR_DEFAULT) + drawtrans = V; + usershape *us = usershapes[group][id]; if(us) { for(int i=0; i= PPR_MAX) { printf("Illegal priority %d of kind %d\n", ptds[i].prio, ptds[i].kind); - ptds[i].prio = rand() % PPR_MAX; + ptds[i].prio = PPR(rand() % PPR_MAX); } qp[ptds[i].prio]++; } @@ -1458,11 +1457,11 @@ void finishshape() { printf("bad end\n"); */ } -void bshape(hpcshape& sh, int p) { +void bshape(hpcshape& sh, PPR prio) { if(last) finishshape(); hpc.push_back(hpxy(0,0)); last = &sh; - last->s = isize(hpc), last->prio = p; + last->s = isize(hpc), last->prio = prio; last->flags = 0; first = true; } @@ -1474,8 +1473,8 @@ static const #endif double bscale7 = 1, brot7 = 0, bscale6 = 1, brot6 = 0; -void bshape(hpcshape& sh, int p, double shzoom, int shapeid, double bonus = 0, flagtype flags = 0) { - bshape(sh, p); +void bshape(hpcshape& sh, PPR prio, double shzoom, int shapeid, double bonus = 0, flagtype flags = 0) { + bshape(sh, prio); int whereis = 0; while(polydata[whereis] != NEWSHAPE || polydata[whereis+1] != shapeid) whereis++; int rots = polydata[whereis+2]; int sym = polydata[whereis+3]; @@ -1537,14 +1536,14 @@ void bshape(hpcshape& sh, int p, double shzoom, int shapeid, double bonus = 0, f hpcpush(ipoint(0, 1)); } -void copyshape(hpcshape& sh, hpcshape& orig, int p) { +void copyshape(hpcshape& sh, hpcshape& orig, PPR prio) { if(last) last->e = isize(hpc); - sh = orig; sh.prio = p; + sh = orig; sh.prio = prio; } -void zoomShape(hpcshape& old, hpcshape& newsh, double factor, int lev) { +void zoomShape(hpcshape& old, hpcshape& newsh, double factor, PPR prio) { - bshape(newsh, lev); + bshape(newsh, prio); for(int i=old.s; id[i].sh.prio = (sg >= 3 ? 1:50) + i; + us->d[i].sh.prio = PPR((sg >= 3 ? 1:50) + i); us->d[i].rots = 1; us->d[i].sym = 0; @@ -2480,8 +2482,8 @@ void initShape(int sg, int id) { } } -void queuepolyat(const transmatrix& V, const hpcshape& h, int col, int prio) { - if(prio == -1) prio = h.prio; +void queuepolyat(const transmatrix& V, const hpcshape& h, int col, PPR prio) { + if(prio == PPR_DEFAULT) prio = h.prio; polytodraw& ptd = nextptd(); ptd.kind = pkPoly; @@ -2504,7 +2506,7 @@ void queuepolyat(const transmatrix& V, const hpcshape& h, int col, int prio) { part(col,2) = part(col,3) = (part(col,2) * 2 + part(col,3) + 1)/3; } ptd.col = (darkened(col >> 8) << 8) + (col & 0xFF); - ptd.prio = prio << PSHIFT; + ptd.prio = prio; ptd.u.poly.outline = poly_outline; ptd.u.poly.linewidth = vid.linewidth; ptd.u.poly.flags = h.flags; @@ -2515,14 +2517,14 @@ void addfloats(vector& v, hyperpoint h) { for(int i=0; i<3; i++) v.push_back(h[i]); } -void queuereset(eModel md, int prio) { +void queuereset(eModel md, PPR prio) { polytodraw& ptd = nextptd(); ptd.kind = pkResetModel; ptd.col = md; - ptd.prio = prio << PSHIFT; + ptd.prio = prio; } -void queuetable(const transmatrix& V, const vector& f, int cnt, int linecol, int fillcol, int prio) { +void queuetable(const transmatrix& V, const vector& f, int cnt, int linecol, int fillcol, PPR prio) { polytodraw& ptd = nextptd(); ptd.kind = pkPoly; ptd.u.poly.V = V; @@ -2530,7 +2532,7 @@ void queuetable(const transmatrix& V, const vector& f, int cnt, int li ptd.u.poly.offset = 0; ptd.u.poly.cnt = cnt; ptd.col = fillcol; - ptd.prio = prio << PSHIFT; + ptd.prio = prio; ptd.u.poly.outline = linecol; ptd.u.poly.linewidth = vid.linewidth; ptd.u.poly.flags = 0; @@ -2542,27 +2544,27 @@ void queuepoly(const transmatrix& V, const hpcshape& h, int col) { } void queuepolyb(const transmatrix& V, const hpcshape& h, int col, int b) { - queuepolyat(V,h,col,h.prio+b); + queuepolyat(V,h,col,PPR(h.prio+b)); } void curvepoint(const hyperpoint& H1) { curvedata.push_back(glhr::pointtogl(H1)); } -void queuecurve(int linecol, int fillcol, int prio) { +void queuecurve(int linecol, int fillcol, PPR prio) { queuetable(Id, curvedata, isize(curvedata)-curvestart, linecol, fillcol, prio); lastptd().u.poly.offset = curvestart; curvestart = isize(curvedata); } -void queuelink(const string *link, int prio) { +void queuelink(const string *link, PPR prio) { polytodraw& ptd = nextptd(); ptd.kind = pkLink; - ptd.prio = prio << PSHIFT; + ptd.prio = prio; ptd.u.link.link = link; } -void queueline(const hyperpoint& H1, const hyperpoint& H2, int col, int prf, int prio) { +void queueline(const hyperpoint& H1, const hyperpoint& H2, int col, int prf, PPR prio) { polytodraw& ptd = nextptd(); ptd.kind = pkLine; ptd.u.line.H1 = H1; @@ -2570,7 +2572,7 @@ void queueline(const hyperpoint& H1, const hyperpoint& H2, int col, int prf, int ptd.u.line.prf = prf; ptd.u.line.width = (linewidthat(H1, vid.linewidth, 0) + linewidthat(H2, vid.linewidth, 0)) / 2; ptd.col = (darkened(col >> 8) << 8) + (col & 0xFF); - ptd.prio = prio << PSHIFT; + ptd.prio = prio; } void queuestr(int x, int y, int shift, int size, string str, int col, int frame, int align) { @@ -2585,7 +2587,7 @@ void queuestr(int x, int y, int shift, int size, string str, int col, int frame, ptd.u.chr.size = size; ptd.col = darkened(col); ptd.u.chr.frame = frame ? ((poly_outline & ~ 255)+frame) : 0; - ptd.prio = PPR_TEXT << PSHIFT; + ptd.prio = PPR_TEXT; } void queuechr(int x, int y, int shift, int size, char chr, int col, int frame, int align) { @@ -2600,10 +2602,10 @@ void queuechr(int x, int y, int shift, int size, char chr, int col, int frame, i ptd.u.chr.align = align; ptd.col = col; ptd.u.chr.frame = frame ? (poly_outline & ~ 255) : 0; - ptd.prio = PPR_TEXT << PSHIFT; + ptd.prio = PPR_TEXT; } -void queuecircle(int x, int y, int size, int color, int prio = PPR_CIRCLE) { +void queuecircle(int x, int y, int size, int color, PPR prio = PPR_CIRCLE) { polytodraw& ptd = nextptd(); ptd.kind = pkCircle; ptd.u.cir.x = x; @@ -2611,7 +2613,7 @@ void queuecircle(int x, int y, int size, int color, int prio = PPR_CIRCLE) { ptd.u.cir.size = size; ptd.u.cir.boundary = false; ptd.col = color; - ptd.prio = prio << PSHIFT; + ptd.prio = prio; } void getcoord0(const hyperpoint& h, int& xc, int &yc, int &sc) {