mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-03-21 19:07:04 +00:00
as_poly() to eliminate dynamic_cast<dqi_poly*>
This commit is contained in:
parent
324b670c29
commit
2d8397d289
@ -2385,7 +2385,7 @@ void celldrawer::draw_wall_full() {
|
||||
if(rosedist(c2) < rd)
|
||||
placeSidewall(c, i, SIDE_WALL, V, rcol);
|
||||
for(int i=t; i<isize(ptds); i++) {
|
||||
auto p = dynamic_cast<dqi_poly*>(&*(ptds[i]));
|
||||
auto p = ptds[i]->as_poly();
|
||||
if(p) p->prio = PPR::TRANSPARENT_WALL;
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ struct drawqueueitem {
|
||||
virtual ~drawqueueitem() = default;
|
||||
/** \brief When minimizing OpenGL calls, we need to group items of the same color, etc. together. This value is used as an extra sorting key. */
|
||||
virtual color_t outline_group() = 0;
|
||||
virtual dqi_poly* as_poly() { return nullptr; }
|
||||
};
|
||||
|
||||
/** \brief Drawqueueitem used to draw polygons. The majority of drawqueueitems fall here. */
|
||||
@ -96,6 +97,7 @@ struct dqi_poly : drawqueueitem {
|
||||
#endif
|
||||
void draw_back() override;
|
||||
color_t outline_group() override { return outline; }
|
||||
virtual dqi_poly* as_poly() { return this; }
|
||||
};
|
||||
|
||||
/** \brief Drawqueueitem used to draw lines */
|
||||
@ -2476,7 +2478,7 @@ EX void draw_main() {
|
||||
}
|
||||
|
||||
for(auto& ptd: ptds) if(ptd->prio == PPR::OUTCIRCLE) {
|
||||
auto c = dynamic_cast<dqi_poly*> (&*ptd);
|
||||
auto c = ptd->as_poly();
|
||||
if(c) { c->color = 0; c->outline = 0; }
|
||||
}
|
||||
|
||||
@ -2637,7 +2639,7 @@ EX void drawqueue() {
|
||||
int pp = int(p);
|
||||
if(qp0[pp] == qp[pp]) continue;
|
||||
auto get_z = [&] (const unique_ptr<drawqueueitem>& p) -> ld {
|
||||
auto d = dynamic_cast<dqi_poly*> (&*p);
|
||||
auto d = p->as_poly();
|
||||
if(!d) return 0;
|
||||
hyperpoint h = Hypc;
|
||||
|
||||
|
@ -3921,7 +3921,7 @@ EX void pushdown(cell *c, int& q, const shiftmatrix &V, double down, bool rezoom
|
||||
#if MAXMDIM >= 4
|
||||
if(GDIM == 3) {
|
||||
for(int i=q; i<isize(ptds); i++) {
|
||||
auto pp = dynamic_cast<dqi_poly*> (&*ptds[q++]);
|
||||
auto pp = ptds[q++]->as_poly();
|
||||
if(!pp) continue;
|
||||
auto& ptd = *pp;
|
||||
ptd.V = ptd.V * lzpush(+down);
|
||||
@ -3942,7 +3942,7 @@ EX void pushdown(cell *c, int& q, const shiftmatrix &V, double down, bool rezoom
|
||||
}
|
||||
|
||||
while(q < isize(ptds)) {
|
||||
auto pp = dynamic_cast<dqi_poly*> (&*ptds[q++]);
|
||||
auto pp = ptds[q++]->as_poly();
|
||||
if(!pp) continue;
|
||||
auto& ptd = *pp;
|
||||
|
||||
|
@ -2654,7 +2654,7 @@ EX namespace mapeditor {
|
||||
initShape(sg, id);
|
||||
|
||||
for(int i=0; i<isize(ptds); i++) {
|
||||
auto pp = dynamic_cast<dqi_poly*> (&*ptds[i]);
|
||||
auto pp = ptds[i]->as_poly();
|
||||
if(!pp) continue;
|
||||
auto& ptd = *pp;
|
||||
|
||||
|
@ -502,7 +502,7 @@ EX always_false in;
|
||||
EX void render() {
|
||||
#if MAXMDIM >= 4
|
||||
for(auto& p: ptds) {
|
||||
auto p2 = dynamic_cast<dqi_poly*>(&*p);
|
||||
auto p2 = p->as_poly();
|
||||
if(p2)
|
||||
prepare(*p2);
|
||||
}
|
||||
@ -524,7 +524,7 @@ EX always_false in;
|
||||
#endif
|
||||
|
||||
for(auto& p: ptds) {
|
||||
auto p2 = dynamic_cast<dqi_poly*>(&*p);
|
||||
auto p2 = p->as_poly();
|
||||
if(p2)
|
||||
polygon(*p2);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user