Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing data when writing mesh file #43

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/input/polyanya_file.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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