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 --- examples2d/add_remove2.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'examples2d/add_remove2.rs') diff --git a/examples2d/add_remove2.rs b/examples2d/add_remove2.rs index a3d223d..7ace00f 100644 --- a/examples2d/add_remove2.rs +++ b/examples2d/add_remove2.rs @@ -10,7 +10,7 @@ pub fn init_world(testbed: &mut Testbed) { let rad = 0.5; // 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, _, _, _| { let rigid_body = RigidBodyBuilder::new_dynamic() .translation(0.0, 10.0) .build(); @@ -19,7 +19,9 @@ 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); let to_remove: Vec<_> = physics .bodies @@ -31,7 +33,9 @@ pub fn init_world(testbed: &mut Testbed) { physics .bodies .remove(handle, &mut physics.colliders, &mut physics.joints); - 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 --- examples2d/add_remove2.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples2d/add_remove2.rs') diff --git a/examples2d/add_remove2.rs b/examples2d/add_remove2.rs index 7ace00f..a351a8f 100644 --- a/examples2d/add_remove2.rs +++ b/examples2d/add_remove2.rs @@ -19,7 +19,7 @@ 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); @@ -33,7 +33,7 @@ pub fn init_world(testbed: &mut Testbed) { physics .bodies .remove(handle, &mut physics.colliders, &mut physics.joints); - + // 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 --- examples2d/add_remove2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples2d/add_remove2.rs') diff --git a/examples2d/add_remove2.rs b/examples2d/add_remove2.rs index a351a8f..614829b 100644 --- a/examples2d/add_remove2.rs +++ b/examples2d/add_remove2.rs @@ -10,7 +10,7 @@ pub fn init_world(testbed: &mut Testbed) { let rad = 0.5; // 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, _, _| { let rigid_body = RigidBodyBuilder::new_dynamic() .translation(0.0, 10.0) .build(); -- 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 --- examples2d/add_remove2.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'examples2d/add_remove2.rs') diff --git a/examples2d/add_remove2.rs b/examples2d/add_remove2.rs index 614829b..cb71025 100644 --- a/examples2d/add_remove2.rs +++ b/examples2d/add_remove2.rs @@ -10,7 +10,7 @@ pub fn init_world(testbed: &mut Testbed) { let rad = 0.5; // 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, _, _| { let rigid_body = RigidBodyBuilder::new_dynamic() .translation(0.0, 10.0) .build(); @@ -20,8 +20,11 @@ pub fn init_world(testbed: &mut Testbed) { .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); + } let to_remove: Vec<_> = physics .bodies @@ -34,8 +37,10 @@ pub fn init_world(testbed: &mut Testbed) { .bodies .remove(handle, &mut physics.colliders, &mut physics.joints); - // TODO: need a way to access graphics & window - // graphics.remove_body_nodes(window, handle); + // FIXME: need a way to access graphics & window in a loop + // 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 --- examples2d/add_remove2.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'examples2d/add_remove2.rs') diff --git a/examples2d/add_remove2.rs b/examples2d/add_remove2.rs index cb71025..0aeffbe 100644 --- a/examples2d/add_remove2.rs +++ b/examples2d/add_remove2.rs @@ -10,7 +10,7 @@ pub fn init_world(testbed: &mut Testbed) { let rad = 0.5; // 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, _, _| { let rigid_body = RigidBodyBuilder::new_dynamic() .translation(0.0, 10.0) .build(); @@ -20,10 +20,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); } let to_remove: Vec<_> = physics @@ -37,10 +35,9 @@ pub fn init_world(testbed: &mut Testbed) { .bodies .remove(handle, &mut physics.colliders, &mut physics.joints); - // FIXME: need a way to access graphics & window in a loop - // 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