dimforge / dimforge/parry

feature request: more ergonomic `Voxels::new`

Open
#404 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
867
Forks
157
Avg merge
7d 13h
Merged PRs (30d)
2

Description

`Voxels::new` and `Voxels::from_points` both take a slice of coordinates, when, in their current implementations, they only need to iterate them.

This means that if you have an iterator of points, you have to collect into a `Vec` first, causing an unnecessary allocation.

Would it be possible to have these functions take an `Iterator` instead? I don't think this would be a breaking change, since slices implement `Iterator` anyway.

---

~~Possibly related: would it be possible to have a function to create a `Voxels` from chunks? (like `Voxels::from_chunks(voxel_size: Vector, chunks: impl Iterator) -> Voxels`. That could be more efficient for someone who already has the voxels in chunk form (and with the same chunk size as parry), although I appreciate that the chunks may be an implementation detail that you might not want to expose more.~~

~~I'll write an implementation, and some benchmarks for that when I have the time.~~

Edit: my benchmarks have shown only a slight speed improvement from creating from chunks, probably not worth adding.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.