aboutsummaryrefslogtreecommitdiff
path: root/examples3d/fountain3.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples3d/fountain3.rs')
-rw-r--r--examples3d/fountain3.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/examples3d/fountain3.rs b/examples3d/fountain3.rs
index fafa988..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, physics, _, graphics, _| {
+ testbed.add_callback(move |mut window, mut graphics, physics, _, _| {
k += 1;
let rigid_body = RigidBodyBuilder::new_dynamic()
.translation(0.0, 10.0, 0.0)
@@ -41,7 +41,10 @@ pub fn init_world(testbed: &mut Testbed) {
physics
.colliders
.insert(collider, handle, &mut physics.bodies);
- graphics.add(window, 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 {
let mut to_remove: Vec<_> = physics
@@ -67,7 +70,10 @@ pub fn init_world(testbed: &mut Testbed) {
physics
.narrow_phase
.maintain(&mut physics.colliders, &mut physics.bodies);
- graphics.remove_body_nodes(window, *handle);
+
+ if let (Some(graphics), Some(window)) = (&mut graphics, &mut window) {
+ graphics.remove_body_nodes(window, *handle);
+ }
}
}
});