From 61610282ca1b3c64247bb83c38597eb1b7a2545f Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 30 May 2023 18:42:18 +0200 Subject: [PATCH] correct ordering of plain floors when z-ordering cannot be trusted in SVG or with alpha --- drawing.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drawing.cpp b/drawing.cpp index b39f98f5..53d9acfd 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -2582,6 +2582,25 @@ EX void drawqueue() { }); } + if(draw_plain_floors && (default_flooralpha < 255 || svg::in)) for(PPR p: {PPR::FLOOR}) { + int pp = int(p); + if(qp0[pp] == qp[pp]) continue; + auto get_z = [&] (const unique_ptr& p) -> ld { + auto d = dynamic_cast (&*p); + if(!d) return 0; + hyperpoint h = Hypc; + + for(int i=0; icnt; i++) h += glhr::gltopoint( (*d->tab)[d->offset + i] ); + h /= d->cnt; normalize(h); + h = unshift(d->V) * h; + return h[2]; + }; + sort(&ptds[qp0[int(p)]], &ptds[qp[int(p)]], + [&] (const unique_ptr& p1, const unique_ptr& p2) { + return get_z(p1) > get_z(p2); + }); + } + #if CAP_SDL if(current_display->stereo_active() && !vid.usingGL) {