Closed ManevilleF closed 4 months ago
@f-hoenix Thanks for the feedback, I see the problem with the offset, I'll fix it once I have merged #156 and add tests and an example reproducing this use case
Sorry didn't have the chance to review the PR In any case it's working just fine 👍
Sorry didn't have the chance to review the PR In any case it's working just fine 👍
Glad to hear it, the implementation is still young so don't hesitate opening follow up issues or PRs
Mmmh I still have something weird that I did not notice I had this code to draw an 'area'
pub fn draw_borders(
self: &Self,
layout: &HexLayout,
gizmos: &mut Gizmos,
color: Color,
) {
for edge in self.edges.iter() {
let vertices = layout.edge_coordinates(edge.rotate_ccw(1)); // <<<< Notice the rotate
draw_gizmo_between_vec2(gizmos, vertices[0], vertices[1], color);
}
}
Result :
If I remove the rotate:
No issue when using flat layout
I don't think the issue is in the code that creates the edges of an area (group of hexes) because it's layout agnostic:
pub fn recalculate_edges(self: &mut Self) {
self.edges = HashSet::new();
for tile in &self.tiles {
for n in tile.all_neighbors() {
if !self.tiles.contains(&n) {
let direction = tile.neighbor_direction(n).unwrap();
self.edges.insert(GridEdge { origin: *tile, direction });
}
}
}
}
Probably an error in the angle calculation in pointy layout, I'll try to reproduce in an example and fix it before release
@f-hoenix I could reproduce the issue:
This new example and the associated fix will be part of #157
Awesome !
GridVertex
andGridEdge
utility structs representing orientated edge and vertices.hex_grid
example using the new edges to draw a gizmo on the hovered tile