|
|
|
|
@ -18,7 +18,7 @@ pub(crate) fn update_colliders()
|
|
|
|
|
|
|
|
|
|
pub(crate) fn debug_draw_aabbs(
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
aabbs: Query<&AABB>,
|
|
|
|
|
aabbs: Query<(Entity, &AABB), Without<ColliderDebug>>,
|
|
|
|
|
mut meshes: ResMut<Assets<Mesh>>,
|
|
|
|
|
mut materials: ResMut<Assets<StandardMaterial>>
|
|
|
|
|
){
|
|
|
|
|
@ -26,26 +26,49 @@ pub(crate) fn debug_draw_aabbs(
|
|
|
|
|
|
|
|
|
|
// TODO: Spawn one of these for each collider in the scene,
|
|
|
|
|
// need to set the scale, rotation and translation to match the AABB
|
|
|
|
|
|
|
|
|
|
// TEST CUBE
|
|
|
|
|
// Spawns a cube with a colored wireframe and partially transparent body
|
|
|
|
|
// Should be able to update the material on the fly to change the colors
|
|
|
|
|
// to red when the AABB is intersecting another AABB
|
|
|
|
|
for (entity, _aabb) in aabbs.iter()
|
|
|
|
|
{
|
|
|
|
|
let cube_mesh_handle: Handle<Mesh> = meshes.add(Cuboid::default());
|
|
|
|
|
commands.spawn((PbrBundle {
|
|
|
|
|
commands.entity(entity).insert((PbrBundle
|
|
|
|
|
{
|
|
|
|
|
mesh: cube_mesh_handle,
|
|
|
|
|
material: materials.add(StandardMaterial {
|
|
|
|
|
material: materials.add(StandardMaterial
|
|
|
|
|
{
|
|
|
|
|
base_color: Color::Rgba { red: 0.0, green: 1.0, blue: 0.0, alpha: 0.25 },
|
|
|
|
|
alpha_mode: AlphaMode::Blend,
|
|
|
|
|
..default()
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
transform: Transform::from_xyz(0.0, 7.25, -1.0)
|
|
|
|
|
//.with_rotation(Quat::from_rotation_y(45.0))
|
|
|
|
|
.with_rotation(Quat::from_rotation_x(45.0)),
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
Wireframe, WireframeColor { color: Color::GREEN },
|
|
|
|
|
|
|
|
|
|
Wireframe,
|
|
|
|
|
WireframeColor { color: Color::GREEN },
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TEST CUBE
|
|
|
|
|
// Spawns a cube with a colored wireframe and partially transparent body
|
|
|
|
|
// Should be able to update the material on the fly to change the colors
|
|
|
|
|
// to red when the AABB is intersecting another AABB
|
|
|
|
|
// commands.spawn((PbrBundle {
|
|
|
|
|
// mesh: cube_mesh_handle,
|
|
|
|
|
// material: materials.add(StandardMaterial {
|
|
|
|
|
// base_color: Color::Rgba { red: 0.0, green: 1.0, blue: 0.0, alpha: 0.25 },
|
|
|
|
|
// alpha_mode: AlphaMode::Blend,
|
|
|
|
|
// ..default()
|
|
|
|
|
// }),
|
|
|
|
|
// transform: Transform::from_xyz(0.0, 7.25, -1.0)
|
|
|
|
|
// //.with_rotation(Quat::from_rotation_y(45.0))
|
|
|
|
|
// .with_rotation(Quat::from_rotation_x(45.0)),
|
|
|
|
|
// ..default()
|
|
|
|
|
// },
|
|
|
|
|
// Wireframe, WireframeColor { color: Color::GREEN },
|
|
|
|
|
// ));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn debug_update_colliders(colliders: Query<&ColliderDebug>)
|
|
|
|
|
|