From a50169e3d313ddb699019dde08e7686bf8eac601 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 1 Aug 2018 11:25:07 +0200 Subject: [PATCH] fixed the lines in the svg screenshots --- graph.cpp | 5 +++-- hyper.h | 4 ++-- polygons.cpp | 27 ++++++++++++++------------- screenshot.cpp | 10 +++++----- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/graph.cpp b/graph.cpp index 08febc4f..dec047df 100644 --- a/graph.cpp +++ b/graph.cpp @@ -1143,7 +1143,6 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou { dynamicval dp(poly_outline); - dynamicval dw(minwidth_global); int eyecolor = 0x202020; bool redeyes = false; if(m == moHunterDog) eyecolor = 0xFF0000, redeyes = true; @@ -1151,9 +1150,11 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou if(m == moHunterChanging) eyecolor = 0xFFFF00, redeyes = true; int eyes = darkena(eyecolor, 0, 0xFF); - if(redeyes) poly_outline = eyes, minwidth_global = 1; + if(redeyes) poly_outline = eyes; queuepoly(VAHEAD, shWolf1, eyes); + if(redeyes) lastptd().u.poly.flags |= POLY_FORCEWIDE; queuepoly(VAHEAD, shWolf2, eyes); + if(redeyes) lastptd().u.poly.flags |= POLY_FORCEWIDE; } queuepoly(VAHEAD, shWolf3, darkena(m == moRunDog ? 0x202020 : 0x000000, 0, 0xFF)); } diff --git a/hyper.h b/hyper.h index 09accae0..1d7d3b70 100644 --- a/hyper.h +++ b/hyper.h @@ -1583,7 +1583,7 @@ extern bool nonbitrunc; namespace svg { void circle(int x, int y, int size, int col); - void polygon(int *polyx, int *polyy, int polyi, int col, int outline, double minwidth); + void polygon(int *polyx, int *polyy, int polyi, int col, int outline, double linewidth); void text(int x, int y, int size, const string& str, bool frame, int col, int align); extern bool in; extern const string *link; @@ -2359,7 +2359,7 @@ struct qpoly { const vector *tab; int offset, cnt; int outline; - double minwidth; + double linewidth; int flags; textureinfo *tinf; }; diff --git a/polygons.cpp b/polygons.cpp index cbaa6397..bc506657 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -53,6 +53,9 @@ static const int POLY_CCONVEX = 8192; // new system of side checking static const int POLY_CENTERIN = 16384; +// force wide lines +static const int POLY_FORCEWIDE = (1<<15); + vector hpc; int prehpc; @@ -62,7 +65,6 @@ bool first; bool fatborder; int poly_outline; -double minwidth_global; #define PSHIFT 0 // #define STLSORT @@ -425,21 +427,20 @@ void gldraw(const transmatrix& V, const vector& v, int ps, int pq, int } #endif -double linewidthat(const hyperpoint& h, double minwidth) { - if((vid.antialias & AA_LINEWIDTH) && hyperbolic) { +double linewidthat(const hyperpoint& h, double linewidth, int flags) { + if((vid.antialias & AA_LINEWIDTH) && hyperbolic && !(flags & POLY_FORCEWIDE)) { double dz = h[2]; if(dz < 1 || abs(dz-stereo::scrdist) < 1e-6) return vid.linewidth; else { double dx = sqrt(dz * dz - 1); double dfc = dx/(dz+1); dfc = 1 - dfc*dfc; - return max(dfc, minwidth) * vid.linewidth; + return max(dfc, linewidth) * vid.linewidth; } } return vid.linewidth; } - // -radius to +3radius int mercator_coord; @@ -673,7 +674,7 @@ void drawpolyline(polytodraw& p) { #if CAP_GL if(vid.usingGL && using_perspective) { - glLineWidth(linewidthat(tC0(pp.V), pp.minwidth)); + glLineWidth(linewidthat(tC0(pp.V), pp.linewidth, pp.flags)); gldraw(pp.V, *pp.tab, pp.offset, pp.cnt, p.col, pp.outline, pp.flags &~ POLY_INVERSE, pp.tinf); return; } @@ -804,7 +805,7 @@ void drawpolyline(polytodraw& p) { if(pp.tinf && (poly_flags & POLY_INVERSE)) { return; } - glLineWidth(linewidthat(tC0(pp.V), pp.minwidth)); + glLineWidth(linewidthat(tC0(pp.V), pp.linewidth, pp.flags)); if(pp.tinf && pp.offset && !nofill) { vector tv; for(int i=0; i& t, int fillcol, int linecol, int lev) pp.tab = &prettylinepoints; pp.offset = 0; pp.cnt = isize(prettylinepoints); - pp.minwidth = minwidth_global; + pp.linewidth = vid.linewidth; p.col = fillcol; pp.outline = linecol; pp.flags = POLY_ISSIDE; @@ -2409,7 +2410,7 @@ void queuepolyat(const transmatrix& V, const hpcshape& h, int col, int prio) { ptd.col = (darkened(col >> 8) << 8) + (col & 0xFF); ptd.prio = prio << PSHIFT; ptd.u.poly.outline = poly_outline; - ptd.u.poly.minwidth = minwidth_global; + ptd.u.poly.linewidth = vid.linewidth; ptd.u.poly.flags = h.flags; ptd.u.poly.tinf = NULL; } @@ -2435,7 +2436,7 @@ void queuetable(const transmatrix& V, const vector& f, int cnt, int li ptd.col = fillcol; ptd.prio = prio << PSHIFT; ptd.u.poly.outline = linecol; - ptd.u.poly.minwidth = minwidth_global; + ptd.u.poly.linewidth = vid.linewidth; ptd.u.poly.flags = 0; ptd.u.poly.tinf = NULL; } @@ -2471,7 +2472,7 @@ void queueline(const hyperpoint& H1, const hyperpoint& H2, int col, int prf, int ptd.u.line.H1 = H1; ptd.u.line.H2 = H2; ptd.u.line.prf = prf; - ptd.u.line.width = (linewidthat(H1, minwidth_global) + linewidthat(H2, minwidth_global)) / 2; + 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; } diff --git a/screenshot.cpp b/screenshot.cpp index 11ef5507..b00a7dd4 100644 --- a/screenshot.cpp +++ b/screenshot.cpp @@ -136,7 +136,7 @@ namespace svg { } } - void polygon(int *polyx, int *polyy, int polyi, int col, int outline, double minwidth) { + void polygon(int *polyx, int *polyy, int polyi, int col, int outline, double linewidth) { if(invisible(col) && invisible(outline)) return; if(polyi < 2) return; @@ -148,17 +148,17 @@ namespace svg { avgy += polyy[i]; avgx /= polyi; avgy /= polyi; - dfc = (avgx - vid.xcenter) * (avgx - vid.xcenter) + - (avgy - vid.ycenter) * (avgy - vid.ycenter); + dfc = pow(avgx - vid.xcenter, 2) + + pow((avgy - vid.ycenter) / vid.stretch, 2); dfc /= vid.radius; dfc /= vid.radius; // 0 = center, 1 = edge dfc = 1 - dfc; if(dfc < 0) dfc = 1; - dfc = max(dfc, 1) * minwidth; + dfc = max(dfc, 1) * linewidth; } - else dfc = .8 * minwidth; + else dfc = .8 * linewidth; startstring(); for(int i=0; i