pub struct Positions<'a>(/* private fields */);Expand description
Checked borrowed XYZ view, preserving all supplied vertices, including unused ones.
Layout constructors do not scan values. Geometric operations reject non-finite components before changing destinations.
Implementations§
Source§impl<'a> Positions<'a>
impl<'a> Positions<'a>
Sourcepub const fn from_packed(data: &'a [[f32; 3]]) -> Self
pub const fn from_packed(data: &'a [[f32; 3]]) -> Self
Borrow tightly packed XYZ components without allocation.
Examples found in repository?
6fn main() -> Result<(), Error> {
7 let positions = [[0., 0., 0.], [1., 0., 0.], [0., 1., 0.], [1., 1., 0.]];
8 let indices = [0, 1, 2, 2, 1, 3];
9 let view = Positions::from_packed(&positions);
10 let mut workspace = Workspace::default();
11 let built = build_meshlets(
12 &indices,
13 view,
14 MeshletSettings::default(),
15 0.25,
16 &mut workspace,
17 )?;
18 let positions = BoundsPositions::new(view);
19 for m in &built.meshlets {
20 let v = m.vertex_offset as usize;
21 let t = m.triangle_offset as usize;
22 let bounds = compute_meshlet_bounds_with_positions(
23 &built.vertices[v..v + m.vertex_count as usize],
24 &built.triangles[t..t + m.triangle_count as usize * 3],
25 positions,
26 &mut workspace,
27 )?;
28 println!("center {:?}, radius {}", bounds.center, bounds.radius);
29 }
30 Ok(())
31}More examples
6fn main() -> Result<(), Error> {
7 let positions = [[0., 0., 0.], [1., 0., 0.], [0., 1., 0.], [1., 1., 0.]];
8 let indices = [0, 1, 2, 2, 1, 3];
9 let view = Positions::from_packed(&positions);
10 let mut workspace = Workspace::default();
11 let scale = simplify_scale(view)?;
12 let mut current = indices.to_vec();
13 for target_index_count in [6, 3, 0] {
14 let settings = SimplifySettings {
15 target_index_count,
16 target_error: 0.01,
17 options: SimplifyOptions::EMPTY,
18 };
19 let lod = simplify(¤t, view, settings, &mut workspace)?;
20 let cached = optimize_vertex_cache(&lod.indices, positions.len(), &mut workspace)?;
21 current = optimize_overdraw(&cached, view, 1.05, &mut workspace)?;
22 println!(
23 "{} indices, absolute error {}",
24 current.len(),
25 lod.error * scale
26 );
27 }
28 Ok(())
29}Sourcepub fn from_interleaved(
data: &'a [f32],
count: usize,
stride: usize,
offset: usize,
) -> Result<Self, Error>
pub fn from_interleaved( data: &'a [f32], count: usize, stride: usize, offset: usize, ) -> Result<Self, Error>
Borrow interleaved floats; stride and offset are in f32 elements.
The stride must be between 3 and 64 elements.
§Errors
InvalidLayout for an unsupported width, stride, offset or buffer length;
SizeOverflow if view size arithmetic overflows.
Sourcepub fn from_bytes(
data: &'a [u8],
count: usize,
stride: usize,
offset: usize,
order: ByteOrder,
) -> Result<Self, Error>
pub fn from_bytes( data: &'a [u8], count: usize, stride: usize, offset: usize, order: ByteOrder, ) -> Result<Self, Error>
Borrow initialized bytes; stride and offset are in bytes, with an explicit byte order. Stride must be a multiple of four between 12 and 256 bytes.
§Errors
InvalidLayout for an unsupported width, stride, offset or buffer length;
SizeOverflow if view size arithmetic overflows.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Positions<'a>
impl<'a> RefUnwindSafe for Positions<'a>
impl<'a> Send for Positions<'a>
impl<'a> Sync for Positions<'a>
impl<'a> Unpin for Positions<'a>
impl<'a> UnsafeUnpin for Positions<'a>
impl<'a> UnwindSafe for Positions<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more