void Constraint::LineDrawOrGetDistance(Vector a, Vector b) { if(dogd.drawing) { // Draw comments in the specified style, but everything else in the // default style for constraints. hStyle hs; if(type == COMMENT && disp.style.v) { hs = disp.style; } else { hs.v = Style::CONSTRAINT; } if(dogd.sel) { dogd.sel->AddEdge(a, b, hs.v); } else { // The only constraints with styles should be comments, so don't // check otherwise, save looking up the styles constantly. if(type == COMMENT && Style::Width(hs) >= 3.0) { ssglFatLine(a, b, Style::Width(hs) / SS.GW.scale); } else { glBegin(GL_LINE_STRIP); ssglVertex3v(a); ssglVertex3v(b); glEnd(); } } } else { Point2d ap = SS.GW.ProjectPoint(a); Point2d bp = SS.GW.ProjectPoint(b); double d = dogd.mp.DistanceToLine(ap, bp.Minus(ap), true); dogd.dmin = min(dogd.dmin, d); } dogd.refp = (a.Plus(b)).ScaledBy(0.5); }
void Entity::LineDrawOrGetDistance(Vector a, Vector b, bool maybeFat) { if(dogd.drawing) { // Draw lines from active group in front of those from previous ssglDepthRangeOffset((group.v == SS.GW.activeGroup.v) ? 4 : 3); // Narrow lines are drawn as lines, but fat lines must be drawn as // filled polygons, to get the line join style right. if(!maybeFat || dogd.lineWidth < 3) { glBegin(GL_LINES); ssglVertex3v(a); ssglVertex3v(b); glEnd(); } else { ssglFatLine(a, b, dogd.lineWidth/SS.GW.scale); } ssglDepthRangeOffset(0); } else { Point2d ap = SS.GW.ProjectPoint(a); Point2d bp = SS.GW.ProjectPoint(b); double d = dogd.mp.DistanceToLine(ap, bp.Minus(ap), true); // A little bit easier to select in the active group if(group.v == SS.GW.activeGroup.v) d -= 1; dogd.dmin = min(dogd.dmin, d); } dogd.refp = (a.Plus(b)).ScaledBy(0.5); }