Skip to content

Commit

Permalink
Fix missing data when writing mesh file (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
MJohnson459 committed Jan 17, 2024
1 parent 255c457 commit 1a0a93e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/input/polyanya_file.rs
Expand Up @@ -105,9 +105,10 @@ impl PolyanyaFile {
for vertex in &self.vertices {
bytes.extend_from_slice(
format!(
"{} {} {}\n",
"{:.06} {:.06} {} {}\n",
vertex.coords.x,
vertex.coords.y,
vertex.polygons.len(),
vertex
.polygons
.iter()
Expand Down
6 changes: 4 additions & 2 deletions src/primitives.rs
Expand Up @@ -65,12 +65,14 @@ impl Polygon {
}

pub(crate) fn using(nb: usize, data: Vec<isize>) -> Self {
assert!(data.len() == nb * 2);
let (vertices, neighbours) = data.split_at(nb);
let vertices = vertices.iter().copied().map(|v| v as u32).collect();
let neighbours = neighbours.to_vec();
let mut found_trav = false;
let mut is_one_way = true;
// Hack to handle case where there are no neighbours in the file. In
// this case we want to assume it is not a one way. The correct fix is
// to update the polyanya file format to include the neighbours.
let mut is_one_way = !neighbours.is_empty();
for neighbour in &neighbours {
if *neighbour != -1 {
if found_trav {
Expand Down

0 comments on commit 1a0a93e

Please sign in to comment.