remove redundant time :f32 from harness callbacks. it can be access via run_state.time
This commit is contained in:
@@ -10,7 +10,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let rad = 0.5;
|
let rad = 0.5;
|
||||||
|
|
||||||
// Callback that will be executed on the main loop to handle proximities.
|
// 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()
|
let rigid_body = RigidBodyBuilder::new_dynamic()
|
||||||
.translation(0.0, 10.0)
|
.translation(0.0, 10.0)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
*/
|
*/
|
||||||
testbed
|
testbed
|
||||||
.harness_mut()
|
.harness_mut()
|
||||||
.add_callback(move |physics, _, run_state, _| {
|
.add_callback(move |physics, _, run_state| {
|
||||||
let platform = physics.bodies.get_mut(platform_handle).unwrap();
|
let platform = physics.bodies.get_mut(platform_handle).unwrap();
|
||||||
let mut next_pos = *platform.position();
|
let mut next_pos = *platform.position();
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
// Callback that will be executed on the main loop to handle proximities.
|
// Callback that will be executed on the main loop to handle proximities.
|
||||||
testbed
|
testbed
|
||||||
.harness_mut()
|
.harness_mut()
|
||||||
.add_callback(move |physics, events, _, _| {
|
.add_callback(move |physics, events, _| {
|
||||||
while let Ok(prox) = events.proximity_events.try_recv() {
|
while let Ok(prox) = events.proximity_events.try_recv() {
|
||||||
let color = match prox.new_status {
|
let color = match prox.new_status {
|
||||||
Proximity::WithinMargin | Proximity::Intersecting => Point3::new(1.0, 1.0, 0.0),
|
Proximity::WithinMargin | Proximity::Intersecting => Point3::new(1.0, 1.0, 0.0),
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let collider = ColliderBuilder::ball(ball_rad).density(100.0).build();
|
let collider = ColliderBuilder::ball(ball_rad).density(100.0).build();
|
||||||
colliders.insert(collider, ball_handle, &mut bodies);
|
colliders.insert(collider, ball_handle, &mut bodies);
|
||||||
|
|
||||||
testbed.harness_mut().add_callback(move |physics, _, _, _| {
|
testbed.harness_mut().add_callback(move |physics, _, _| {
|
||||||
// Remove then re-add the ground collider.
|
// Remove then re-add the ground collider.
|
||||||
let coll = physics
|
let coll = physics
|
||||||
.colliders
|
.colliders
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let mut extra_colliders = Vec::new();
|
let mut extra_colliders = Vec::new();
|
||||||
let snapped_frame = 51;
|
let snapped_frame = 51;
|
||||||
|
|
||||||
testbed.harness_mut().add_callback(move |physics, _, _, _| {
|
testbed.harness_mut().add_callback(move |physics, _, _| {
|
||||||
step += 1;
|
step += 1;
|
||||||
|
|
||||||
// Add a bigger ball collider
|
// Add a bigger ball collider
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let mut step = 0;
|
let mut step = 0;
|
||||||
let snapped_frame = 51;
|
let snapped_frame = 51;
|
||||||
|
|
||||||
testbed.harness_mut().add_callback(move |physics, _, _, _| {
|
testbed.harness_mut().add_callback(move |physics, _, _| {
|
||||||
step += 1;
|
step += 1;
|
||||||
|
|
||||||
// Snap the ball velocity or restore it.
|
// Snap the ball velocity or restore it.
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let mut k = 0;
|
let mut k = 0;
|
||||||
|
|
||||||
// Callback that will be executed on the main loop to handle proximities.
|
// 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;
|
k += 1;
|
||||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
let rigid_body = RigidBodyBuilder::new_dynamic()
|
||||||
.translation(0.0, 10.0, 0.0)
|
.translation(0.0, 10.0, 0.0)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
testbed
|
testbed
|
||||||
.harness_mut()
|
.harness_mut()
|
||||||
.add_callback(move |physics, _, run_state, _| {
|
.add_callback(move |physics, _, run_state| {
|
||||||
count += 1;
|
count += 1;
|
||||||
if count % 100 > 50 {
|
if count % 100 > 50 {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
|||||||
// Callback that will be executed on the main loop to handle proximities.
|
// Callback that will be executed on the main loop to handle proximities.
|
||||||
testbed
|
testbed
|
||||||
.harness_mut()
|
.harness_mut()
|
||||||
.add_callback(move |physics, events, _, _| {
|
.add_callback(move |physics, events, _| {
|
||||||
while let Ok(prox) = events.proximity_events.try_recv() {
|
while let Ok(prox) = events.proximity_events.try_recv() {
|
||||||
let color = match prox.new_status {
|
let color = match prox.new_status {
|
||||||
Proximity::WithinMargin | Proximity::Intersecting => Point3::new(1.0, 1.0, 0.0),
|
Proximity::WithinMargin | Proximity::Intersecting => Point3::new(1.0, 1.0, 0.0),
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ pub struct Harness {
|
|||||||
pub state: RunState,
|
pub state: RunState,
|
||||||
}
|
}
|
||||||
|
|
||||||
type Callbacks = Vec<Box<dyn FnMut(&mut PhysicsState, &PhysicsEvents, &RunState, f32)>>;
|
type Callbacks = Vec<Box<dyn FnMut(&mut PhysicsState, &PhysicsEvents, &RunState)>>;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
impl Harness {
|
impl Harness {
|
||||||
@@ -130,7 +130,7 @@ impl Harness {
|
|||||||
self.plugins.push(Box::new(plugin));
|
self.plugins.push(Box::new(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_callback<F: FnMut(&mut PhysicsState, &PhysicsEvents, &RunState, f32) + 'static>(
|
pub fn add_callback<F: FnMut(&mut PhysicsState, &PhysicsEvents, &RunState) + 'static>(
|
||||||
&mut self,
|
&mut self,
|
||||||
callback: F,
|
callback: F,
|
||||||
) {
|
) {
|
||||||
@@ -185,7 +185,6 @@ impl Harness {
|
|||||||
&mut self.physics,
|
&mut self.physics,
|
||||||
&self.events,
|
&self.events,
|
||||||
&self.state,
|
&self.state,
|
||||||
self.state.time,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user