Skip to content

Allow avoidance of exclusive World's ownership from Testbed #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples2d/body_status2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ fn main() {
*/
let mut testbed = Testbed::new(world);
testbed.add_callback(move |world, _, time| {
let mut world = world.get_mut();
let platform = world.rigid_body_mut(platform_handle).unwrap();
let platform_x = platform.position().translation.vector.x;

Expand Down
5 changes: 3 additions & 2 deletions examples2d/sensor2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ fn main() {

// Callback that will be executed on the main loop to handle proximities.
testbed.add_callback(move |world, graphics, _| {
let world = world.get();
for prox in world.proximity_events() {
let color = match prox.new_status {
Proximity::WithinMargin | Proximity::Intersecting => Point3::new(1.0, 1.0, 0.0),
Expand All @@ -98,10 +99,10 @@ fn main() {
let body2 = world.collider(prox.collider2).unwrap().data().body();

if !body1.is_ground() && body1 != sensor_body {
graphics.set_body_color(world, body1, color);
graphics.set_body_color(&world, body1, color);
}
if !body2.is_ground() && body2 != sensor_body {
graphics.set_body_color(world, body2, color);
graphics.set_body_color(&world, body2, color);
}
}
});
Expand Down
3 changes: 2 additions & 1 deletion examples3d/body_status3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ fn main() {
* Setup a callback to control the platform.
*/
let mut testbed = Testbed::new(world);
testbed.add_callback(move |world, _, time| {
testbed.add_callback(move |world_owner, _, time| {
let mut world = world_owner.get_mut();
let platform = world.rigid_body_mut(platform_handle).unwrap();
let platform_z = platform.position().translation.vector.z;

Expand Down
4 changes: 4 additions & 0 deletions examples3d/joints3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ fn main() {
*/
let mut testbed = Testbed::new(world);
testbed.add_callback(move |world, _, _| {
let mut world = world.get_mut();

/*
* Activate the helical joint motor if it is to low.
*/
Expand All @@ -334,6 +336,8 @@ fn main() {
});

testbed.add_callback(move |world, _, _| {
let mut world = world.get_mut();

/*
* Activate the pin-slot joint linear motor if it is to low.
*/
Expand Down
8 changes: 5 additions & 3 deletions examples3d/sensor3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ fn main() {
testbed.set_body_color(&world, sensor_body, Point3::new(0.5, 1.0, 1.0));

// Callback that will be executed on the main loop to handle proximities.
testbed.add_callback(move |world, graphics, _| {
testbed.add_callback(move |world_owner, graphics, _| {
let world = world_owner.get();

for prox in world.proximity_events() {
let color = match prox.new_status {
Proximity::WithinMargin | Proximity::Intersecting => Point3::new(1.0, 1.0, 0.0),
Expand All @@ -102,10 +104,10 @@ fn main() {
let body2 = world.collider(prox.collider2).unwrap().data().body();

if !body1.is_ground() && body1 != sensor_body {
graphics.set_body_color(world, body1, color);
graphics.set_body_color(&world, body1, color);
}
if !body2.is_ground() && body2 != sensor_body {
graphics.set_body_color(world, body2, color);
graphics.set_body_color(&world, body2, color);
}
}
});
Expand Down
2 changes: 2 additions & 0 deletions nphysics_testbed2d/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ extern crate time;

pub use engine::GraphicsManager;
pub use testbed::Testbed;
pub use world_owner::WorldOwner;

mod engine;
pub mod objects;
mod testbed;
mod world_owner;
Loading