@@ -27,7 +27,7 @@ use crate::{
2727static IS_INIT : OnceLock < ( ) > = OnceLock :: new ( ) ;
2828
2929thread_local ! {
30- static APP : RefCell <Option <App >> = RefCell :: new( None ) ;
30+ static APP : RefCell <Option <App >> = const { RefCell :: new( None ) } ;
3131}
3232
3333#[ derive( Resource , Default ) ]
@@ -64,7 +64,7 @@ impl CameraProjection for ProcessingProjection {
6464 0.0 ,
6565 self . width ,
6666 self . height , // bottom = height
67- 0.0 , // top = 0
67+ 0.0 , // top = 0
6868 self . near ,
6969 self . far ,
7070 )
@@ -94,36 +94,25 @@ impl CameraProjection for ProcessingProjection {
9494
9595 [
9696 // near plane
97- near_center + Vec3A :: new ( half_width, half_height, 0.0 ) , // bottom-right
98- near_center + Vec3A :: new ( half_width, -half_height, 0.0 ) , // top-right
97+ near_center + Vec3A :: new ( half_width, half_height, 0.0 ) , // bottom-right
98+ near_center + Vec3A :: new ( half_width, -half_height, 0.0 ) , // top-right
9999 near_center + Vec3A :: new ( -half_width, -half_height, 0.0 ) , // top-left
100- near_center + Vec3A :: new ( -half_width, half_height, 0.0 ) , // bottom-left
100+ near_center + Vec3A :: new ( -half_width, half_height, 0.0 ) , // bottom-left
101101 // far plane
102- far_center + Vec3A :: new ( half_width, half_height, 0.0 ) , // bottom-right
103- far_center + Vec3A :: new ( half_width, -half_height, 0.0 ) , // top-right
104- far_center + Vec3A :: new ( -half_width, -half_height, 0.0 ) , // top-left
105- far_center + Vec3A :: new ( -half_width, half_height, 0.0 ) , // bottom-left
102+ far_center + Vec3A :: new ( half_width, half_height, 0.0 ) , // bottom-right
103+ far_center + Vec3A :: new ( half_width, -half_height, 0.0 ) , // top-right
104+ far_center + Vec3A :: new ( -half_width, -half_height, 0.0 ) , // top-left
105+ far_center + Vec3A :: new ( -half_width, half_height, 0.0 ) , // bottom-left
106106 ]
107107 }
108108}
109109
110- fn app < T > ( cb : impl FnOnce ( & App ) -> Result < T > ) -> Result < T > {
111- let res = APP . with ( |app_cell| {
112- let app_borrow = app_cell. borrow ( ) ;
113- let app = app_borrow
114- . as_ref ( )
115- . ok_or_else ( || error:: ProcessingError :: AppAccess ) ?;
116- cb ( app)
117- } ) ?;
118- Ok ( res)
119- }
120-
121110fn app_mut < T > ( cb : impl FnOnce ( & mut App ) -> Result < T > ) -> Result < T > {
122111 let res = APP . with ( |app_cell| {
123112 let mut app_borrow = app_cell. borrow_mut ( ) ;
124113 let app = app_borrow
125114 . as_mut ( )
126- . ok_or_else ( || error:: ProcessingError :: AppAccess ) ?;
115+ . ok_or ( error:: ProcessingError :: AppAccess ) ?;
127116 cb ( app)
128117 } ) ?;
129118 Ok ( res)
@@ -195,10 +184,7 @@ pub fn create_surface(
195184 let content_view: Option < Retained < NSView > > = ns_window_ref. contentView ( ) ;
196185
197186 match content_view {
198- Some ( view) => {
199- let view_ptr = Retained :: as_ptr ( & view) as * mut std:: ffi:: c_void ;
200- view_ptr
201- }
187+ Some ( view) => Retained :: as_ptr ( & view) as * mut std:: ffi:: c_void ,
202188 None => {
203189 return Err ( error:: ProcessingError :: InvalidWindowHandle ) ;
204190 }
@@ -215,10 +201,10 @@ pub fn create_surface(
215201
216202 #[ cfg( target_os = "windows" ) ]
217203 let ( raw_window_handle, raw_display_handle) = {
218- use raw_window_handle:: { Win32WindowHandle , WindowsDisplayHandle } ;
219204 use std:: num:: NonZeroIsize ;
220- use windows:: Win32 :: Foundation :: HINSTANCE ;
221- use windows:: Win32 :: System :: LibraryLoader :: GetModuleHandleW ;
205+
206+ use raw_window_handle:: { Win32WindowHandle , WindowsDisplayHandle } ;
207+ use windows:: Win32 :: { Foundation :: HINSTANCE , System :: LibraryLoader :: GetModuleHandleW } ;
222208
223209 if window_handle == 0 {
224210 return Err ( error:: ProcessingError :: InvalidWindowHandle ) ;
@@ -478,7 +464,6 @@ pub fn exit(exit_code: u8) -> Result<()> {
478464 Ok ( ( ) )
479465 } ) ?;
480466
481-
482467 // we need to drop the app in a deterministic manner to ensure resourcse are cleaned up
483468 // otherwise we'll get wgpu graphics backend errors on exit
484469 APP . with ( |app_cell| {
@@ -492,7 +477,7 @@ pub fn exit(exit_code: u8) -> Result<()> {
492477pub fn background_color ( window_entity : Entity , color : Color ) -> Result < ( ) > {
493478 app_mut ( |app| {
494479 let mut camera_query = app. world_mut ( ) . query :: < ( & mut Camera , & ChildOf ) > ( ) ;
495- for ( mut camera, parent) in camera_query. iter_mut ( & mut app. world_mut ( ) ) {
480+ for ( mut camera, parent) in camera_query. iter_mut ( app. world_mut ( ) ) {
496481 if parent. parent ( ) == window_entity {
497482 camera. clear_color = ClearColorConfig :: Custom ( color) ;
498483 }
0 commit comments