1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
use ffi; use std::mem; use DecodePosition; pub fn simplify<T: DecodePosition>( indices: &[u32], vertices: &[T], target_count: usize, target_error: f32, ) -> Vec<u32> { let positions = vertices .iter() .map(|vertex| vertex.decode_position()) .collect::<Vec<[f32; 3]>>(); let mut result: Vec<u32> = Vec::new(); result.resize(indices.len(), 0u32); let index_count = unsafe { ffi::meshopt_simplify( result.as_mut_ptr() as *mut ::std::os::raw::c_uint, indices.as_ptr() as *const ::std::os::raw::c_uint, indices.len(), positions.as_ptr() as *const f32, positions.len(), mem::size_of::<f32>() * 3, target_count, target_error, ) }; result.resize(index_count, 0u32); result }