From d2c250324b2f9833ef9f4231c5145c4fd11abab7 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Thu, 13 Oct 2016 20:23:22 +0700 Subject: [PATCH] Fix many rendering bugs introduced in df83ee4 and 9f97e9a. --- src/draw.cpp | 4 ++++ src/drawentity.cpp | 22 ++++++++++------------ src/groupmesh.cpp | 5 ++--- src/render/render.cpp | 3 +++ src/style.cpp | 2 +- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/draw.cpp b/src/draw.cpp index 0256f45e..539e4a93 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -60,6 +60,7 @@ void GraphicsWindow::Selection::Draw(bool isHovered, Canvas *canvas) { strokeEmphasis.layer = Canvas::Layer::FRONT; strokeEmphasis.color = Style::Color(Style::HOVERED).WithAlpha(50); strokeEmphasis.width = 40; + strokeEmphasis.unit = Canvas::Unit::PX; Canvas::hStroke hcsEmphasis = canvas->GetStroke(strokeEmphasis); Point2d topLeftScreen; @@ -545,6 +546,8 @@ void GraphicsWindow::DrawSnapGrid(Canvas *canvas) { Canvas::Stroke stroke = {}; stroke.layer = Canvas::Layer::BACK; stroke.color = Style::Color(Style::DATUM).WithAlpha(75); + stroke.unit = Canvas::Unit::PX; + stroke.width = 1.0f; Canvas::hStroke hcs = canvas->GetStroke(stroke); for(i = i0 + 1; i < i1; i++) { @@ -679,6 +682,7 @@ void GraphicsWindow::Draw(Canvas *canvas) { SK.GetGroup(activeGroup)->DrawMesh(Group::DrawMeshAs::SELECTED, canvas); Canvas::Stroke strokeDatum = Style::Stroke(Style::DATUM); + strokeDatum.unit = Canvas::Unit::PX; strokeDatum.layer = Canvas::Layer::FRONT; strokeDatum.width = 1; Canvas::hStroke hcsDatum = canvas->GetStroke(strokeDatum); diff --git a/src/drawentity.cpp b/src/drawentity.cpp index 3d720335..8242a1c9 100644 --- a/src/drawentity.cpp +++ b/src/drawentity.cpp @@ -463,32 +463,30 @@ void Entity::Draw(DrawAs how, Canvas *canvas) { hs = Style::ForEntity(h); } - Canvas::Stroke stroke = {}; + Canvas::Stroke stroke = Style::Stroke(hs); switch(how) { case DrawAs::DEFAULT: - stroke = Style::Stroke(hs); - stroke.layer = Canvas::Layer::NORMAL; + stroke.layer = Canvas::Layer::NORMAL; break; case DrawAs::OVERLAY: - stroke.layer = Canvas::Layer::FRONT; + stroke.layer = Canvas::Layer::FRONT; break; case DrawAs::HIDDEN: - stroke = Style::Stroke(Style::HIDDEN_EDGE); - stroke.layer = Canvas::Layer::OCCLUDED; + stroke.layer = Canvas::Layer::OCCLUDED; + stroke.stipplePattern = Style::PatternType({ Style::HIDDEN_EDGE }); + stroke.stippleScale = Style::Get({ Style::HIDDEN_EDGE })->stippleScale; break; case DrawAs::HOVERED: - stroke = Style::Stroke(hs); - stroke.layer = Canvas::Layer::FRONT; - stroke.color = Style::Color(Style::HOVERED); + stroke.layer = Canvas::Layer::FRONT; + stroke.color = Style::Color(Style::HOVERED); break; case DrawAs::SELECTED: - stroke = Style::Stroke(hs); - stroke.layer = Canvas::Layer::FRONT; - stroke.color = Style::Color(Style::SELECTED); + stroke.layer = Canvas::Layer::FRONT; + stroke.color = Style::Color(Style::SELECTED); break; } stroke.zIndex = zIndex; diff --git a/src/groupmesh.cpp b/src/groupmesh.cpp index 3c68d418..afd76bb2 100644 --- a/src/groupmesh.cpp +++ b/src/groupmesh.cpp @@ -479,6 +479,7 @@ void Group::DrawMesh(DrawMeshAs how, Canvas *canvas) { strokeTriangle.zIndex = 1; strokeTriangle.color = RgbaColor::FromFloat(0.0f, 1.0f, 0.0f); strokeTriangle.width = 1; + strokeTriangle.unit = Canvas::Unit::PX; hcsTriangle = canvas->GetStroke(strokeTriangle); } @@ -551,10 +552,8 @@ void Group::Draw(Canvas *canvas) { } if(SS.GW.showOutlines) { - Canvas::Stroke strokeOutline = {}; + Canvas::Stroke strokeOutline = Style::Stroke(Style::OUTLINE); strokeOutline.zIndex = 1; - strokeOutline.color = Style::Color(Style::OUTLINE); - strokeOutline.width = Style::Width(Style::OUTLINE); Canvas::hStroke hcsOutline = canvas->GetStroke(strokeOutline); canvas->DrawOutlines(displayOutlines, hcsOutline, diff --git a/src/render/render.cpp b/src/render/render.cpp index 4c2911a5..94f00408 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -133,6 +133,7 @@ bool Canvas::Stroke::Equals(const Stroke &other) const { zIndex == other.zIndex && color.Equals(other.color) && width == other.width && + unit == other.unit && stipplePattern == other.stipplePattern && stippleScale == other.stippleScale); } @@ -221,6 +222,7 @@ void UiCanvas::DrawLine(int x1, int y1, int x2, int y2, RgbaColor color, int wid stroke.layer = Canvas::Layer::FRONT; stroke.width = (double)width; stroke.color = color; + stroke.unit = Canvas::Unit::PX; Canvas::hStroke hcs = canvas->GetStroke(stroke); canvas->DrawLine(va, vb, hcs); @@ -247,6 +249,7 @@ void UiCanvas::DrawRect(int l, int r, int t, int b, stroke.layer = Canvas::Layer::FRONT; stroke.width = 1.0; stroke.color = outlineColor; + stroke.unit = Canvas::Unit::PX; Canvas::hStroke hcs = canvas->GetStroke(stroke); canvas->DrawLine(va, vb, hcs); diff --git a/src/style.cpp b/src/style.cpp index b3e913ea..30df5596 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -289,7 +289,7 @@ Canvas::Stroke Style::Stroke(hStyle hs) { Style *style = Style::Get(hs); stroke.color = style->color; stroke.stipplePattern = style->stippleType; - stroke.stippleScale = Style::StippleScaleMm(hs); + stroke.stippleScale = style->stippleScale; stroke.width = Style::Width(hs.v); switch(style->widthAs) { case Style::UnitsAs::PIXELS: