Skip to content

Commit

Permalink
fix dashed lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Nertsal committed Oct 13, 2024
1 parent f7f4a56 commit 5b4af95
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions src/render/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ impl UtilRender {
ugli::draw(
framebuffer,
&self.context.assets.shaders.solid,
ugli::DrawMode::TriangleFan,
ugli::DrawMode::Triangles,
&ugli::VertexBuffer::new_dynamic(self.context.geng.ugli(), vertices),
(
ugli::uniforms! {
Expand Down Expand Up @@ -767,27 +767,26 @@ fn build_segment(
start: draw2d::ColoredVertex,
end: draw2d::ColoredVertex,
width: f32,
) -> [draw2d::ColoredVertex; 4] {
) -> [draw2d::ColoredVertex; 6] {
use draw2d::ColoredVertex;

let half_width = width / 2.0;
let normal = (end.a_pos - start.a_pos).normalize_or_zero().rotate_90();
[
ColoredVertex {
a_pos: start.a_pos - normal * half_width,
a_color: start.a_color,
},
ColoredVertex {
a_pos: start.a_pos + normal * half_width,
a_color: start.a_color,
},
ColoredVertex {
a_pos: end.a_pos + normal * half_width,
a_color: end.a_color,
},
ColoredVertex {
a_pos: end.a_pos - normal * half_width,
a_color: end.a_color,
},
]
let a = ColoredVertex {
a_pos: start.a_pos - normal * half_width,
a_color: start.a_color,
};
let b = ColoredVertex {
a_pos: start.a_pos + normal * half_width,
a_color: start.a_color,
};
let c = ColoredVertex {
a_pos: end.a_pos - normal * half_width,
a_color: end.a_color,
};
let d = ColoredVertex {
a_pos: end.a_pos + normal * half_width,
a_color: end.a_color,
};
[a, b, c, b, d, c]
}

0 comments on commit 5b4af95

Please sign in to comment.