@@ -88,31 +88,22 @@ fn main() {
8888 "You are running the example with the empty backend, no graphical output is to be expected"
8989 ) ;
9090
91- let teapot = wavefront_obj:: obj:: parse ( include_str ! ( "./data/teapot.obj" ) ) . unwrap ( ) ;
92- assert_eq ! ( teapot. objects. len( ) , 1 ) ;
93- let teapot_vertices = teapot. objects [ 0 ]
94- . vertices
95- . iter ( )
96- . map ( |vertex| Vertex {
97- a_Pos : [ vertex. x as f32 , vertex. y as f32 , vertex. z as f32 ] ,
98- } )
99- . collect :: < Vec < _ > > ( ) ;
91+ let teapot = obj:: Obj :: load ( concat ! (
92+ env!( "CARGO_MANIFEST_DIR" ) ,
93+ "/ray-tracing/data/teapot.obj"
94+ ) )
95+ . unwrap ( ) ;
96+ assert_eq ! ( teapot. data. objects. len( ) , 1 ) ;
97+ let teapot_vertices = & teapot. data . position ;
10098 let teapot_indices = {
101- let object = & teapot. objects [ 0 ] ;
102- assert_eq ! ( object. geometry . len( ) , 1 ) ;
103- object. geometry [ 0 ]
104- . shapes
99+ let object = & teapot. data . objects [ 0 ] ;
100+ assert_eq ! ( object. groups . len( ) , 1 ) ;
101+ object. groups [ 0 ]
102+ . polys
105103 . iter ( )
106- . flat_map ( |shape| match shape. primitive {
107- wavefront_obj:: obj:: Primitive :: Point ( _) => {
108- unimplemented ! ( )
109- }
110- wavefront_obj:: obj:: Primitive :: Line ( _, _) => {
111- unimplemented ! ( )
112- }
113- wavefront_obj:: obj:: Primitive :: Triangle ( a, b, c) => std:: iter:: once ( a. 0 as u16 )
114- . chain ( std:: iter:: once ( b. 0 as u16 ) )
115- . chain ( std:: iter:: once ( c. 0 as u16 ) ) ,
104+ . flat_map ( |poly| {
105+ assert_eq ! ( poly. 0 . len( ) , 3 , "this isn't a triangle!?!" ) ;
106+ poly. 0 . iter ( ) . map ( |index_tuple| index_tuple. 0 as u16 )
116107 } )
117108 . collect :: < Vec < _ > > ( )
118109 } ;
@@ -198,7 +189,7 @@ fn main() {
198189 & memory_types,
199190 buffer:: Usage :: ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY
200191 | buffer:: Usage :: SHADER_DEVICE_ADDRESS ,
201- & teapot_vertices,
192+ teapot_vertices,
202193 ) ;
203194
204195 let index_buffer = upload_to_buffer :: < back:: Backend , _ > (
@@ -623,14 +614,14 @@ fn main() {
623614 & [ ] ,
624615 )
625616 . unwrap ( ) ;
626- let descriptor_set = descriptor_pool. allocate_set ( & layout) . unwrap ( ) ;
617+ let mut descriptor_set = descriptor_pool. allocate_set ( & layout) . unwrap ( ) ;
627618
628- device. write_descriptor_sets ( iter :: once ( pso:: DescriptorSetWrite {
629- set : & descriptor_set,
619+ device. write_descriptor_set ( pso:: DescriptorSetWrite {
620+ set : & mut descriptor_set,
630621 binding : 0 ,
631622 array_offset : 0 ,
632623 descriptors : vec ! [ pso:: Descriptor :: AccelerationStructure ( & tlas. accel_struct) ] ,
633- } ) ) ;
624+ } ) ;
634625 }
635626 }
636627}
@@ -694,7 +685,7 @@ fn upload_to_buffer<B: hal::Backend, T>(
694685 let buffer_stride = mem:: size_of :: < T > ( ) as u64 ;
695686 let buffer_len = data. len ( ) as u64 * buffer_stride;
696687
697- let ( buffer, buffer_memory) = create_empty_buffer :: < B > (
688+ let ( buffer, mut buffer_memory) = create_empty_buffer :: < B > (
698689 device,
699690 non_coherent_alignment,
700691 memory_types,
@@ -704,13 +695,13 @@ fn upload_to_buffer<B: hal::Backend, T>(
704695
705696 unsafe {
706697 let mapping = device
707- . map_memory ( & buffer_memory, memory:: Segment :: ALL )
698+ . map_memory ( & mut buffer_memory, memory:: Segment :: ALL )
708699 . unwrap ( ) ;
709700 ptr:: copy_nonoverlapping ( data. as_ptr ( ) as * const u8 , mapping, buffer_len as usize ) ;
710701 device
711702 . flush_mapped_memory_ranges ( iter:: once ( ( & buffer_memory, memory:: Segment :: ALL ) ) )
712703 . unwrap ( ) ;
713- device. unmap_memory ( & buffer_memory) ;
704+ device. unmap_memory ( & mut buffer_memory) ;
714705 }
715706
716707 ( buffer, buffer_memory)
0 commit comments