mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-03-25 21:07:03 +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)
|
if(rosedist(c2) < rd)
|
||||||
placeSidewall(c, i, SIDE_WALL, V, rcol);
|
placeSidewall(c, i, SIDE_WALL, V, rcol);
|
||||||
for(int i=t; i<isize(ptds); i++) {
|
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;
|
if(p) p->prio = PPR::TRANSPARENT_WALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ struct drawqueueitem {
|
|||||||
virtual ~drawqueueitem() = default;
|
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. */
|
/** \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 color_t outline_group() = 0;
|
||||||
|
virtual dqi_poly* as_poly() { return nullptr; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Drawqueueitem used to draw polygons. The majority of drawqueueitems fall here. */
|
/** \brief Drawqueueitem used to draw polygons. The majority of drawqueueitems fall here. */
|
||||||
@ -96,6 +97,7 @@ struct dqi_poly : drawqueueitem {
|
|||||||
#endif
|
#endif
|
||||||
void draw_back() override;
|
void draw_back() override;
|
||||||
color_t outline_group() override { return outline; }
|
color_t outline_group() override { return outline; }
|
||||||
|
virtual dqi_poly* as_poly() { return this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Drawqueueitem used to draw lines */
|
/** \brief Drawqueueitem used to draw lines */
|
||||||
@ -2476,7 +2478,7 @@ EX void draw_main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(auto& ptd: ptds) if(ptd->prio == PPR::OUTCIRCLE) {
|
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; }
|
if(c) { c->color = 0; c->outline = 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2637,7 +2639,7 @@ EX void drawqueue() {
|
|||||||
int pp = int(p);
|
int pp = int(p);
|
||||||
if(qp0[pp] == qp[pp]) continue;
|
if(qp0[pp] == qp[pp]) continue;
|
||||||
auto get_z = [&] (const unique_ptr<drawqueueitem>& p) -> ld {
|
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;
|
if(!d) return 0;
|
||||||
hyperpoint h = Hypc;
|
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 MAXMDIM >= 4
|
||||||
if(GDIM == 3) {
|
if(GDIM == 3) {
|
||||||
for(int i=q; i<isize(ptds); i++) {
|
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;
|
if(!pp) continue;
|
||||||
auto& ptd = *pp;
|
auto& ptd = *pp;
|
||||||
ptd.V = ptd.V * lzpush(+down);
|
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)) {
|
while(q < isize(ptds)) {
|
||||||
auto pp = dynamic_cast<dqi_poly*> (&*ptds[q++]);
|
auto pp = ptds[q++]->as_poly();
|
||||||
if(!pp) continue;
|
if(!pp) continue;
|
||||||
auto& ptd = *pp;
|
auto& ptd = *pp;
|
||||||
|
|
||||||
|
@ -2654,7 +2654,7 @@ EX namespace mapeditor {
|
|||||||
initShape(sg, id);
|
initShape(sg, id);
|
||||||
|
|
||||||
for(int i=0; i<isize(ptds); i++) {
|
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;
|
if(!pp) continue;
|
||||||
auto& ptd = *pp;
|
auto& ptd = *pp;
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@ EX always_false in;
|
|||||||
EX void render() {
|
EX void render() {
|
||||||
#if MAXMDIM >= 4
|
#if MAXMDIM >= 4
|
||||||
for(auto& p: ptds) {
|
for(auto& p: ptds) {
|
||||||
auto p2 = dynamic_cast<dqi_poly*>(&*p);
|
auto p2 = p->as_poly();
|
||||||
if(p2)
|
if(p2)
|
||||||
prepare(*p2);
|
prepare(*p2);
|
||||||
}
|
}
|
||||||
@ -524,7 +524,7 @@ EX always_false in;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(auto& p: ptds) {
|
for(auto& p: ptds) {
|
||||||
auto p2 = dynamic_cast<dqi_poly*>(&*p);
|
auto p2 = p->as_poly();
|
||||||
if(p2)
|
if(p2)
|
||||||
polygon(*p2);
|
polygon(*p2);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user