Color visualization for grounded character controller (#705)
This commit is contained in:
@@ -29,6 +29,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let character_handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::capsule_y(0.3, 0.15);
|
||||
colliders.insert_with_parent(collider, character_handle, &mut bodies);
|
||||
testbed.set_initial_body_color(character_handle, [0.8, 0.1, 0.1]);
|
||||
|
||||
/*
|
||||
* Create the cubes
|
||||
|
||||
@@ -45,6 +45,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let character_handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::capsule_y(0.3 * scale, 0.15 * scale); // 0.15, 0.3, 0.15);
|
||||
colliders.insert_with_parent(collider, character_handle, &mut bodies);
|
||||
testbed.set_initial_body_color(character_handle, [0.8, 0.1, 0.1]);
|
||||
|
||||
/*
|
||||
* Create the cubes
|
||||
|
||||
@@ -845,6 +845,21 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> Testbed<'a, 'b, 'c, 'd, 'e, 'f> {
|
||||
QueryFilter::new().exclude_rigid_body(character_handle),
|
||||
|c| collisions.push(c),
|
||||
);
|
||||
if let Some(graphics) = &mut self.graphics {
|
||||
if mvt.grounded {
|
||||
graphics.graphics.set_body_color(
|
||||
graphics.materials,
|
||||
character_handle,
|
||||
[0.1, 0.8, 0.1],
|
||||
);
|
||||
} else {
|
||||
graphics.graphics.set_body_color(
|
||||
graphics.materials,
|
||||
character_handle,
|
||||
[0.8, 0.1, 0.1],
|
||||
);
|
||||
}
|
||||
}
|
||||
controller.solve_character_collision_impulses(
|
||||
phx.integration_parameters.dt,
|
||||
&mut phx.bodies,
|
||||
|
||||
Reference in New Issue
Block a user