@@ -383,7 +383,8 @@ impl ExecState {
383383 /// Update a scene object. This is useful to replace a placeholder.
384384 #[ cfg( feature = "artifact-graph" ) ]
385385 pub fn set_scene_object ( & mut self , object : Object ) {
386- self . mod_local . artifacts . set_scene_object ( object) ;
386+ let id = object. id ;
387+ self . mod_local . artifacts . scene_objects [ id. 0 ] = object;
387388 }
388389
389390 #[ cfg( feature = "artifact-graph" ) ]
@@ -730,16 +731,13 @@ impl ModuleArtifactState {
730731 pub ( crate ) fn scene_object_by_id ( & self , id : ObjectId ) -> Option < & Object > {
731732 #[ cfg( feature = "artifact-graph" ) ]
732733 {
733- if let Some ( first_object) = self . scene_objects . first ( ) {
734- // The scene objects are stored in order, but they may start
735- // with a non-zero ID. If so, shift the ID down to get the
736- // index.
737- debug_assert ! ( id. 0 >= first_object. id. 0 ) ;
738- let index = id. 0 . checked_sub ( first_object. id . 0 ) ;
739- index. and_then ( |i| self . scene_objects . get ( i) )
740- } else {
741- None
742- }
734+ debug_assert ! (
735+ id. 0 < self . scene_objects. len( ) ,
736+ "Requested object ID {} but only have {} objects" ,
737+ id. 0 ,
738+ self . scene_objects. len( )
739+ ) ;
740+ self . scene_objects . get ( id. 0 )
743741 }
744742 #[ cfg( not( feature = "artifact-graph" ) ) ]
745743 {
@@ -752,42 +750,20 @@ impl ModuleArtifactState {
752750 pub ( crate ) fn scene_object_by_id_mut ( & mut self , id : ObjectId ) -> Option < & mut Object > {
753751 #[ cfg( feature = "artifact-graph" ) ]
754752 {
755- if let Some ( first_object) = self . scene_objects . first ( ) {
756- // The scene objects are stored in order, but they may start
757- // with a non-zero ID. If so, shift the ID down to get the
758- // index.
759- debug_assert ! ( id. 0 >= first_object. id. 0 ) ;
760- let index = id. 0 . checked_sub ( first_object. id . 0 ) ;
761- index. and_then ( |i| self . scene_objects . get_mut ( i) )
762- } else {
763- None
764- }
753+ debug_assert ! (
754+ id. 0 < self . scene_objects. len( ) ,
755+ "Requested object ID {} but only have {} objects" ,
756+ id. 0 ,
757+ self . scene_objects. len( )
758+ ) ;
759+ self . scene_objects . get_mut ( id. 0 )
765760 }
766761 #[ cfg( not( feature = "artifact-graph" ) ) ]
767762 {
768763 let _ = id;
769764 None
770765 }
771766 }
772-
773- #[ cfg_attr( not( feature = "artifact-graph" ) , expect( dead_code) ) ]
774- pub ( crate ) fn set_scene_object ( & mut self , object : Object ) {
775- #[ cfg( feature = "artifact-graph" ) ]
776- {
777- if let Some ( first_object) = self . scene_objects . first ( ) {
778- // The scene objects are stored in order, but they may start
779- // with a non-zero ID. If so, shift the ID down to get the
780- // index.
781- debug_assert ! ( object. id. 0 >= first_object. id. 0 ) ;
782- let index = object. id . 0 . checked_sub ( first_object. id . 0 ) ;
783- if let Some ( index) = index {
784- self . scene_objects [ index] = object;
785- }
786- }
787- }
788- #[ cfg( not( feature = "artifact-graph" ) ) ]
789- drop ( object) ;
790- }
791767}
792768
793769impl ModuleState {
0 commit comments