Use Canvas::Stroke, not Canvas::Fill, for drawing a point.

Our points are more like fat lines than actual quads, in that they
are scale-invariant.
pull/97/head
Evil-Spirit 2016-07-17 20:46:38 +06:00 committed by whitequark
parent e80a3a0a71
commit 1108a6f37d
6 changed files with 43 additions and 25 deletions

View File

@ -496,11 +496,12 @@ void Entity::Draw(DrawAs how, Canvas *canvas) {
}
Canvas::hStroke hcs = canvas->GetStroke(stroke);
Canvas::Fill fill = {};
fill.layer = stroke.layer;
fill.zIndex = IsPoint() ? 5 : 0;
fill.color = stroke.color;
Canvas::hFill hcf = canvas->GetFill(fill);
Canvas::Stroke pointStroke = {};
pointStroke.layer = stroke.layer;
pointStroke.zIndex = IsPoint() ? zIndex + 1 : 0;
pointStroke.color = stroke.color;
pointStroke.width = 7.0;
Canvas::hStroke hcsPoint = canvas->GetStroke(pointStroke);
switch(type) {
case Type::POINT_N_COPY:
@ -528,14 +529,15 @@ void Entity::Draw(DrawAs how, Canvas *canvas) {
free = pu->free || pv->free;
}
if(free) {
Canvas::Fill fillAnalyze = fill;
fillAnalyze.color = Style::Color(Style::ANALYZE);
Canvas::hFill hcfAnalyze = canvas->GetFill(fillAnalyze);
Canvas::Stroke analyzeStroke = pointStroke;
analyzeStroke.color = Style::Color(Style::ANALYZE);
analyzeStroke.width = 14.0;
Canvas::hStroke hcsAnalyze = canvas->GetStroke(analyzeStroke);
canvas->DrawPoint(PointGetNum(), 7.0, hcfAnalyze);
canvas->DrawPoint(PointGetNum(), hcsAnalyze);
}
canvas->DrawPoint(PointGetNum(), 3.5, hcf);
canvas->DrawPoint(PointGetNum(), hcsPoint);
return;
}

View File

@ -143,7 +143,7 @@ public:
void DrawOutlines(const SOutlineList &ol, hStroke hcs, DrawOutlinesAs drawAs) override {
ssassert(false, "Not implemented");
}
void DrawPoint(const Vector &o, double d, hFill hcf) override {
void DrawPoint(const Vector &o, hStroke hcs) override {
ssassert(false, "Not implemented");
}
void DrawPolygon(const SPolygon &p, hFill hcf) override {

View File

@ -346,10 +346,10 @@ void ObjectPicker::DrawQuad(const Vector &a, const Vector &b, const Vector &c, c
DoQuad(a, b, c, d, fill->zIndex);
}
void ObjectPicker::DrawPoint(const Vector &o, double s, hFill hcf) {
Fill *fill = fills.FindById(hcf);
double distance = point.DistanceTo(camera.ProjectPoint(o)) - s / 2;
DoCompare(distance, fill->zIndex);
void ObjectPicker::DrawPoint(const Vector &o, Canvas::hStroke hcs) {
Stroke *stroke = strokes.FindById(hcs);
double distance = point.DistanceTo(camera.ProjectPoint(o)) - stroke->width / 2;
DoCompare(distance, stroke->zIndex);
}
void ObjectPicker::DrawPolygon(const SPolygon &p, hFill hcf) {

View File

@ -140,7 +140,7 @@ public:
virtual void DrawQuad(const Vector &a, const Vector &b, const Vector &c, const Vector &d,
hFill hcf) = 0;
virtual void DrawPoint(const Vector &o, double d, hFill hcf) = 0;
virtual void DrawPoint(const Vector &o, hStroke hcs) = 0;
virtual void DrawPolygon(const SPolygon &p, hFill hcf) = 0;
virtual void DrawMesh(const SMesh &m, hFill hcfFront, hFill hcfBack = {},
hStroke hcsTriangles = {}) = 0;
@ -196,7 +196,7 @@ public:
void DrawQuad(const Vector &a, const Vector &b, const Vector &c, const Vector &d,
hFill hcf) override;
void DrawPoint(const Vector &o, double s, hFill hcf) override;
void DrawPoint(const Vector &o, hStroke hcs) override;
void DrawPolygon(const SPolygon &p, hFill hcf) override;
void DrawMesh(const SMesh &m, hFill hcfFront, hFill hcfBack, hStroke hcsTriangles) override;
void DrawFaces(const SMesh &m, const std::vector<uint32_t> &faces, hFill hcf) override;
@ -244,7 +244,7 @@ public:
void DrawQuad(const Vector &a, const Vector &b, const Vector &c, const Vector &d,
hFill hcf) override;
void DrawPoint(const Vector &o, double s, hFill hcf) override;
void DrawPoint(const Vector &o, hStroke hcs) override;
void DrawPolygon(const SPolygon &p, hFill hcf) override;
void DrawMesh(const SMesh &m, hFill hcfFront, hFill hcfBack, hStroke hcsTriangles) override;
void DrawFaces(const SMesh &m, const std::vector<uint32_t> &faces, hFill hcf) override;
@ -347,7 +347,7 @@ public:
void DrawQuad(const Vector &a, const Vector &b, const Vector &c, const Vector &d,
hFill hcf) override;
void DrawPoint(const Vector &o, double s, hFill hcf) override;
void DrawPoint(const Vector &o, hStroke hcs) override;
void DrawPolygon(const SPolygon &p, hFill hcf) override;
void DrawMesh(const SMesh &m, hFill hcfFront, hFill hcfBack, hStroke hcsTriangles) override;
void DrawFaces(const SMesh &m, const std::vector<uint32_t> &faces, hFill hcf) override;

View File

@ -104,9 +104,17 @@ void SurfaceRenderer::DrawQuad(const Vector &a, const Vector &b, const Vector &c
mesh.AddTriangle(meta, ta, td, tc);
}
void SurfaceRenderer::DrawPoint(const Vector &o, double s, hFill hcf) {
Vector u = camera.projRight.ScaledBy(1 / camera.scale * s),
v = camera.projUp.ScaledBy(1 / camera.scale * s);
void SurfaceRenderer::DrawPoint(const Vector &o, Canvas::hStroke hcs) {
Stroke *stroke = strokes.FindById(hcs);
Fill fill = {};
fill.layer = stroke->layer;
fill.zIndex = stroke->zIndex;
fill.color = stroke->color;
hFill hcf = GetFill(fill);
Vector u = camera.projRight.ScaledBy(stroke->width/2.0/camera.scale),
v = camera.projUp.ScaledBy(stroke->width/2.0/camera.scale);
DrawQuad(o.Minus(u).Minus(v), o.Minus(u).Plus(v),
o.Plus(u).Plus(v), o.Plus(u).Minus(v), hcf);
}

View File

@ -501,9 +501,17 @@ void OpenGl1Renderer::DrawQuad(const Vector &a, const Vector &b, const Vector &c
ssglVertex3v(d);
}
void OpenGl1Renderer::DrawPoint(const Vector &o, double s, hFill hcf) {
Vector r = camera.projRight.ScaledBy(s/camera.scale);
Vector u = camera.projUp.ScaledBy(s/camera.scale);
void OpenGl1Renderer::DrawPoint(const Vector &o, Canvas::hStroke hcs) {
Stroke *stroke = SelectStroke(hcs);
Canvas::Fill fill = {};
fill.layer = stroke->layer;
fill.zIndex = stroke->zIndex;
fill.color = stroke->color;
hFill hcf = GetFill(fill);
Vector r = camera.projRight.ScaledBy(stroke->width/2.0/camera.scale);
Vector u = camera.projUp.ScaledBy(stroke->width/2.0/camera.scale);
Vector a = o.Plus (r).Plus (u),
b = o.Plus (r).Minus(u),
c = o.Minus(r).Minus(u),