mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-30 15:39:54 +00:00
linewidth cleanup, SVG output should now work for spheres
This commit is contained in:
parent
07dc1d4616
commit
2eaddae6ee
16
polygons.cpp
16
polygons.cpp
@ -334,7 +334,7 @@ void gldraw(int useV, const transmatrix& V, const vector<glvertex>& v, int ps, i
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
double linewidthat(const hyperpoint& h, double minwidth) {
|
double linewidthat(const hyperpoint& h, double minwidth) {
|
||||||
if(vid.antialias & AA_LINEWIDTH) {
|
if((vid.antialias & AA_LINEWIDTH) && hyperbolic) {
|
||||||
double dz = h[2];
|
double dz = h[2];
|
||||||
if(dz < 1 || abs(dz-stereo::scrdist) < 1e-6) return vid.linewidth;
|
if(dz < 1 || abs(dz-stereo::scrdist) < 1e-6) return vid.linewidth;
|
||||||
else {
|
else {
|
||||||
@ -511,7 +511,7 @@ void drawpolyline(polytodraw& p) {
|
|||||||
}
|
}
|
||||||
else poly_flags &=~ POLY_INVERSE;
|
else poly_flags &=~ POLY_INVERSE;
|
||||||
|
|
||||||
if(sphereflipped()) {
|
if(spherespecial) {
|
||||||
if(!hiliteclick && !(poly_flags & POLY_INFRONT)) return;
|
if(!hiliteclick && !(poly_flags & POLY_INFRONT)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,6 +540,7 @@ void drawpolyline(polytodraw& p) {
|
|||||||
if(pp.tinf && (poly_flags & POLY_INVERSE)) {
|
if(pp.tinf && (poly_flags & POLY_INVERSE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
glLineWidth(linewidthat(tC0(pp.V), pp.minwidth));
|
||||||
gldraw(3, Id, glcoords, 0, size(glcoords), p.col, pp.outline, poly_flags, pp.tinf);
|
gldraw(3, Id, glcoords, 0, size(glcoords), p.col, pp.outline, poly_flags, pp.tinf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -629,7 +630,7 @@ void prettyline(hyperpoint h1, hyperpoint h2, int col, int lev) {
|
|||||||
pp.tab = &prettylinepoints;
|
pp.tab = &prettylinepoints;
|
||||||
pp.offset = 0;
|
pp.offset = 0;
|
||||||
pp.cnt = size(prettylinepoints);
|
pp.cnt = size(prettylinepoints);
|
||||||
pp.minwidth = minwidth_global;
|
pp.minwidth = vid.linewidth;
|
||||||
p.col = 0;
|
p.col = 0;
|
||||||
pp.outline = col;
|
pp.outline = col;
|
||||||
pp.flags = POLY_ISSIDE;
|
pp.flags = POLY_ISSIDE;
|
||||||
@ -2558,8 +2559,8 @@ namespace svg {
|
|||||||
|
|
||||||
if(invisible(col) && invisible(outline)) return;
|
if(invisible(col) && invisible(outline)) return;
|
||||||
if(polyi < 2) return;
|
if(polyi < 2) return;
|
||||||
double dfc = 0.8;
|
double dfc;
|
||||||
if(!pmodel && !euclid) {
|
if(!pmodel && hyperbolic) {
|
||||||
int avgx = 0, avgy = 0;
|
int avgx = 0, avgy = 0;
|
||||||
for(int i=0; i<polyi; i++)
|
for(int i=0; i<polyi; i++)
|
||||||
avgx += polyx[i],
|
avgx += polyx[i],
|
||||||
@ -2574,8 +2575,9 @@ namespace svg {
|
|||||||
dfc = 1 - dfc;
|
dfc = 1 - dfc;
|
||||||
|
|
||||||
if(dfc < 0) dfc = 1;
|
if(dfc < 0) dfc = 1;
|
||||||
dfc = max(dfc, minwidth);
|
dfc = max<double>(dfc, 1) * minwidth;
|
||||||
}
|
}
|
||||||
|
else dfc = .8 * minwidth;
|
||||||
|
|
||||||
startstring();
|
startstring();
|
||||||
for(int i=0; i<polyi; i++) {
|
for(int i=0; i<polyi; i++) {
|
||||||
@ -2586,7 +2588,7 @@ namespace svg {
|
|||||||
fprintf(f, "%s %s", coord(polyx[i]), coord(polyy[i]));
|
fprintf(f, "%s %s", coord(polyx[i]), coord(polyy[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, "\" %s/>", stylestr(col, outline, vid.radius*dfc/256));
|
fprintf(f, "\" %s/>", stylestr(col, outline, (hyperbolic ? vid.radius : vid.scrsize) *dfc/256));
|
||||||
stopstring();
|
stopstring();
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user