From cf968c8be1d3fb54991d6c54c098cb81b7c66d6e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 8 Mar 2020 00:33:18 +0100 Subject: [PATCH] optimized drawing side walls --- drawing.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drawing.cpp b/drawing.cpp index e712094e..6f1d88a6 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -57,6 +57,7 @@ struct dqi_poly : drawqueueitem { int flags; struct basic_textureinfo *tinf; hyperpoint intester; + float cache; void draw(); void gldraw(); void draw_back(); @@ -1737,6 +1738,7 @@ EX void quickqueue() { ld xintval(const hyperpoint& h) { if(sphereflipped()) return -h[2]; + if(hyperbolic) return -h[2]; return -intval(h, C0); } @@ -1938,15 +1940,21 @@ EX void drawqueue() { sort_drawqueue(); + if(GDIM == 2) for(PPR p: {PPR::REDWALLs, PPR::REDWALLs2, PPR::REDWALLs3, PPR::WALL3s, - PPR::LAKEWALL, PPR::INLAKEWALL, PPR::BELOWBOTTOM}) - if(GDIM == 2) sort(&ptds[qp0[int(p)]], &ptds[qp[int(p)]], - [] (const unique_ptr& p1, const unique_ptr& p2) { - auto ap1 = (dqi_poly&) *p1; - auto ap2 = (dqi_poly&) *p2; - return xintval(ap1.V * xpush0(.1)) - < xintval(ap2.V * xpush0(.1)); - }); + PPR::LAKEWALL, PPR::INLAKEWALL, PPR::BELOWBOTTOM, PPR::ASHALLOW, PPR::BSHALLOW}) { + int pp = int(p); + for(int i=qp0[pp]; i& p1, const unique_ptr& p2) { + auto ap1 = (dqi_poly&) *p1; + auto ap2 = (dqi_poly&) *p2; + return ap1.cache < ap2.cache; + }); + } for(PPR p: {PPR::TRANSPARENT_WALL}) sort(&ptds[qp0[int(p)]], &ptds[qp[int(p)]],