Accept maybeFat in ssglStippledLine.

This commit is contained in:
EvilSpirit 2016-03-25 14:05:50 +06:00 committed by whitequark
parent 1e0fcf1e6c
commit e19a2f4f35
3 changed files with 13 additions and 13 deletions

View File

@ -23,7 +23,7 @@ void Entity::LineDrawOrGetDistance(Vector a, Vector b, bool maybeFat) {
ssglDepthRangeOffset((group.v == SS.GW.activeGroup.v) ? 4 : 3); ssglDepthRangeOffset((group.v == SS.GW.activeGroup.v) ? 4 : 3);
// Narrow lines are drawn as lines, but fat lines must be drawn as // Narrow lines are drawn as lines, but fat lines must be drawn as
// filled polygons, to get the line join style right. // filled polygons, to get the line join style right.
ssglStippledLine(a, b, dogd.lineWidth, dogd.stippleType, dogd.stippleScale); ssglStippledLine(a, b, dogd.lineWidth, dogd.stippleType, dogd.stippleScale, maybeFat);
ssglDepthRangeOffset(0); ssglDepthRangeOffset(0);
} else { } else {
Point2d ap = SS.GW.ProjectPoint(a); Point2d ap = SS.GW.ProjectPoint(a);

View File

@ -200,7 +200,7 @@ static void FatLineEndcap(Vector p, Vector u, Vector v)
glEnd(); glEnd();
} }
void ssglLine(const Vector &a, const Vector &b, double pixelWidth, bool maybeFat = true) { void ssglLine(const Vector &a, const Vector &b, double pixelWidth, bool maybeFat) {
if(!maybeFat || pixelWidth < 3.0) { if(!maybeFat || pixelWidth < 3.0) {
glBegin(GL_LINES); glBegin(GL_LINES);
ssglVertex3v(a); ssglVertex3v(a);
@ -229,11 +229,11 @@ void ssglPoint(Vector p, double pixelSize)
} }
void ssglStippledLine(Vector a, Vector b, double width, void ssglStippledLine(Vector a, Vector b, double width,
int stippleType, double stippleScale) int stippleType, double stippleScale, bool maybeFat)
{ {
const char *stipplePattern; const char *stipplePattern;
switch(stippleType) { switch(stippleType) {
case Style::STIPPLE_CONTINUOUS: ssglLine(a, b, width); return; case Style::STIPPLE_CONTINUOUS: ssglLine(a, b, width, maybeFat); return;
case Style::STIPPLE_DASH: stipplePattern = "- "; break; case Style::STIPPLE_DASH: stipplePattern = "- "; break;
case Style::STIPPLE_LONG_DASH: stipplePattern = "_ "; break; case Style::STIPPLE_LONG_DASH: stipplePattern = "_ "; break;
case Style::STIPPLE_DASH_DOT: stipplePattern = "-."; break; case Style::STIPPLE_DASH_DOT: stipplePattern = "-."; break;
@ -243,11 +243,11 @@ void ssglStippledLine(Vector a, Vector b, double width,
case Style::STIPPLE_ZIGZAG: stipplePattern = "~__"; break; case Style::STIPPLE_ZIGZAG: stipplePattern = "~__"; break;
default: oops(); default: oops();
} }
ssglStippledLine(a, b, width, stipplePattern, stippleScale); ssglStippledLine(a, b, width, stipplePattern, stippleScale, maybeFat);
} }
void ssglStippledLine(Vector a, Vector b, double width, void ssglStippledLine(Vector a, Vector b, double width,
const char *stipplePattern, double stippleScale) const char *stipplePattern, double stippleScale, bool maybeFat)
{ {
if(stipplePattern == NULL || *stipplePattern == 0) oops(); if(stipplePattern == NULL || *stipplePattern == 0) oops();
@ -269,13 +269,13 @@ void ssglStippledLine(Vector a, Vector b, double width,
start = max(start - 0.5 * ss, 0.0); start = max(start - 0.5 * ss, 0.0);
end = max(start - 2.0 * ss, 0.0); end = max(start - 2.0 * ss, 0.0);
if(start == end) break; if(start == end) break;
ssglLine(a.Plus(dir.ScaledBy(start)), a.Plus(dir.ScaledBy(end)), width); ssglLine(a.Plus(dir.ScaledBy(start)), a.Plus(dir.ScaledBy(end)), width, maybeFat);
end = max(end - 0.5 * ss, 0.0); end = max(end - 0.5 * ss, 0.0);
break; break;
case '_': case '_':
end = max(end - 4.0 * ss, 0.0); end = max(end - 4.0 * ss, 0.0);
ssglLine(a.Plus(dir.ScaledBy(start)), a.Plus(dir.ScaledBy(end)), width); ssglLine(a.Plus(dir.ScaledBy(start)), a.Plus(dir.ScaledBy(end)), width, maybeFat);
break; break;
case '.': case '.':
@ -296,7 +296,7 @@ void ssglStippledLine(Vector a, Vector b, double width,
Vector aa = a.Plus(dir.ScaledBy(start)); Vector aa = a.Plus(dir.ScaledBy(start));
Vector bb = a.Plus(dir.ScaledBy(end)) Vector bb = a.Plus(dir.ScaledBy(end))
.Plus(abn.ScaledBy(pws * (start - end) / (0.5 * ss))); .Plus(abn.ScaledBy(pws * (start - end) / (0.5 * ss)));
ssglLine(aa, bb, width); ssglLine(aa, bb, width, maybeFat);
if(end == 0.0) break; if(end == 0.0) break;
start = end; start = end;
@ -304,7 +304,7 @@ void ssglStippledLine(Vector a, Vector b, double width,
aa = a.Plus(dir.ScaledBy(end)) aa = a.Plus(dir.ScaledBy(end))
.Plus(abn.ScaledBy(pws)) .Plus(abn.ScaledBy(pws))
.Minus(abn.ScaledBy(2.0 * pws * (start - end) / ss)); .Minus(abn.ScaledBy(2.0 * pws * (start - end) / ss));
ssglLine(bb, aa, width); ssglLine(bb, aa, width, maybeFat);
if(end == 0.0) break; if(end == 0.0) break;
start = end; start = end;
@ -312,7 +312,7 @@ void ssglStippledLine(Vector a, Vector b, double width,
bb = a.Plus(dir.ScaledBy(end)) bb = a.Plus(dir.ScaledBy(end))
.Minus(abn.ScaledBy(pws)) .Minus(abn.ScaledBy(pws))
.Plus(abn.ScaledBy(pws * (start - end) / (0.5 * ss))); .Plus(abn.ScaledBy(pws * (start - end) / (0.5 * ss)));
ssglLine(aa, bb, width); ssglLine(aa, bb, width, maybeFat);
break; break;
} }

View File

@ -357,9 +357,9 @@ double ssglStrWidth(const std::string &str, double h);
double ssglStrHeight(double h); double ssglStrHeight(double h);
void ssglLockColorTo(RgbaColor rgb); void ssglLockColorTo(RgbaColor rgb);
void ssglStippledLine(Vector a, Vector b, double width, void ssglStippledLine(Vector a, Vector b, double width,
int stippleType, double stippleScale); int stippleType, double stippleScale, bool maybeFat);
void ssglStippledLine(Vector a, Vector b, double width, void ssglStippledLine(Vector a, Vector b, double width,
const char *stipplePattern, double stippleScale); const char *stipplePattern, double stippleScale, bool maybeFat);
void ssglFatLine(Vector a, Vector b, double width); void ssglFatLine(Vector a, Vector b, double width);
void ssglUnlockColor(void); void ssglUnlockColor(void);
void ssglColorRGB(RgbaColor rgb); void ssglColorRGB(RgbaColor rgb);