From f7820139471178fd273c7698eba17cb4ee0cf00d Mon Sep 17 00:00:00 2001 From: rezural Date: Thu, 31 Dec 2020 13:24:29 +1100 Subject: make examples compile, code that accessed window & graphics via the callback is currently disabled, until that is added back in --- examples3d/fountain3.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'examples3d/fountain3.rs') diff --git a/examples3d/fountain3.rs b/examples3d/fountain3.rs index fafa988..8dd12ed 100644 --- a/examples3d/fountain3.rs +++ b/examples3d/fountain3.rs @@ -26,7 +26,7 @@ pub fn init_world(testbed: &mut Testbed) { let mut k = 0; // Callback that will be executed on the main loop to handle proximities. - testbed.add_callback(move |window, physics, _, graphics, _| { + testbed.harness_mut().add_callback(move |physics, _, _, _| { k += 1; let rigid_body = RigidBodyBuilder::new_dynamic() .translation(0.0, 10.0, 0.0) @@ -41,7 +41,8 @@ pub fn init_world(testbed: &mut Testbed) { physics .colliders .insert(collider, handle, &mut physics.bodies); - graphics.add(window, handle, &physics.bodies, &physics.colliders); + // TODO: need a way to access graphics & window + // graphics.add(window, handle, &physics.bodies, &physics.colliders); if physics.bodies.len() > MAX_NUMBER_OF_BODIES { let mut to_remove: Vec<_> = physics @@ -67,7 +68,9 @@ pub fn init_world(testbed: &mut Testbed) { physics .narrow_phase .maintain(&mut physics.colliders, &mut physics.bodies); - graphics.remove_body_nodes(window, *handle); + + // TODO: need a way to access graphics & window + // graphics.remove_body_nodes(window, *handle); } } }); -- cgit From e11ace383164de39dfaadcb00f258497b132cf1d Mon Sep 17 00:00:00 2001 From: rezural Date: Thu, 31 Dec 2020 13:31:30 +1100 Subject: cargo fmt --- examples3d/fountain3.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples3d/fountain3.rs') diff --git a/examples3d/fountain3.rs b/examples3d/fountain3.rs index 8dd12ed..5dcf2d8 100644 --- a/examples3d/fountain3.rs +++ b/examples3d/fountain3.rs @@ -68,7 +68,7 @@ pub fn init_world(testbed: &mut Testbed) { physics .narrow_phase .maintain(&mut physics.colliders, &mut physics.bodies); - + // TODO: need a way to access graphics & window // graphics.remove_body_nodes(window, *handle); } -- cgit From 6f508e5d04e5652991f9feaad09231af84542ac1 Mon Sep 17 00:00:00 2001 From: rezural Date: Thu, 31 Dec 2020 15:23:25 +1100 Subject: remove redundant time :f32 from harness callbacks. it can be access via run_state.time --- examples3d/fountain3.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples3d/fountain3.rs') diff --git a/examples3d/fountain3.rs b/examples3d/fountain3.rs index 5dcf2d8..0909a0c 100644 --- a/examples3d/fountain3.rs +++ b/examples3d/fountain3.rs @@ -26,7 +26,7 @@ pub fn init_world(testbed: &mut Testbed) { let mut k = 0; // Callback that will be executed on the main loop to handle proximities. - testbed.harness_mut().add_callback(move |physics, _, _, _| { + testbed.harness_mut().add_callback(move |physics, _, _| { k += 1; let rigid_body = RigidBodyBuilder::new_dynamic() .translation(0.0, 10.0, 0.0) -- cgit From 34e79e9afc21ff0202d8a0338d0e8e038402a159 Mon Sep 17 00:00:00 2001 From: rezural Date: Sat, 2 Jan 2021 16:45:55 +1100 Subject: unify callbacks with & without graphics & window --- examples3d/fountain3.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'examples3d/fountain3.rs') diff --git a/examples3d/fountain3.rs b/examples3d/fountain3.rs index 0909a0c..e42f71a 100644 --- a/examples3d/fountain3.rs +++ b/examples3d/fountain3.rs @@ -26,7 +26,7 @@ pub fn init_world(testbed: &mut Testbed) { let mut k = 0; // Callback that will be executed on the main loop to handle proximities. - testbed.harness_mut().add_callback(move |physics, _, _| { + testbed.add_callback(move |window, graphics, physics, _, _| { k += 1; let rigid_body = RigidBodyBuilder::new_dynamic() .translation(0.0, 10.0, 0.0) @@ -41,8 +41,12 @@ pub fn init_world(testbed: &mut Testbed) { physics .colliders .insert(collider, handle, &mut physics.bodies); - // TODO: need a way to access graphics & window - // graphics.add(window, handle, &physics.bodies, &physics.colliders); + + if graphics.is_some() { + graphics + .unwrap() + .add(window.unwrap(), handle, &physics.bodies, &physics.colliders); + } if physics.bodies.len() > MAX_NUMBER_OF_BODIES { let mut to_remove: Vec<_> = physics @@ -69,8 +73,9 @@ pub fn init_world(testbed: &mut Testbed) { .narrow_phase .maintain(&mut physics.colliders, &mut physics.bodies); - // TODO: need a way to access graphics & window - // graphics.remove_body_nodes(window, *handle); + // if graphics.is_some() { + // graphics.unwrap().remove_body_nodes(window.unwrap(), *handle); + // } } } }); -- cgit From 5ca82eeaee5c45d31cdbb5f963d0f93b19196ea8 Mon Sep 17 00:00:00 2001 From: rezural Date: Sun, 3 Jan 2021 19:54:56 +1100 Subject: enable graphics and windows related code in examples --- examples3d/fountain3.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'examples3d/fountain3.rs') diff --git a/examples3d/fountain3.rs b/examples3d/fountain3.rs index e42f71a..5acc2e8 100644 --- a/examples3d/fountain3.rs +++ b/examples3d/fountain3.rs @@ -26,7 +26,7 @@ pub fn init_world(testbed: &mut Testbed) { let mut k = 0; // Callback that will be executed on the main loop to handle proximities. - testbed.add_callback(move |window, graphics, physics, _, _| { + testbed.add_callback(move |mut window, mut graphics, physics, _, _| { k += 1; let rigid_body = RigidBodyBuilder::new_dynamic() .translation(0.0, 10.0, 0.0) @@ -42,10 +42,8 @@ pub fn init_world(testbed: &mut Testbed) { .colliders .insert(collider, handle, &mut physics.bodies); - if graphics.is_some() { - graphics - .unwrap() - .add(window.unwrap(), handle, &physics.bodies, &physics.colliders); + if let (Some(graphics), Some(window)) = (&mut graphics, &mut window) { + graphics.add(window, handle, &physics.bodies, &physics.colliders); } if physics.bodies.len() > MAX_NUMBER_OF_BODIES { @@ -73,9 +71,9 @@ pub fn init_world(testbed: &mut Testbed) { .narrow_phase .maintain(&mut physics.colliders, &mut physics.bodies); - // if graphics.is_some() { - // graphics.unwrap().remove_body_nodes(window.unwrap(), *handle); - // } + if let (Some(graphics), Some(window)) = (&mut graphics, &mut window) { + graphics.remove_body_nodes(window, *handle); + } } } }); -- cgit