Commit e019963f authored by Rahix's avatar Rahix 🦀
Browse files

systems: Add a system to draw colliders for debugging

This allows one to debug wrong colliders in-engine.  Quite helpful if
inkscape messed up the SVG again ...
parent 62b83537
......@@ -7,7 +7,7 @@ use std::sync::mpsc;
pub struct Collider {
pub handle: Option<ncollide2d::pipeline::CollisionObjectSlabHandle>,
drop_notifier: Option<mpsc::SyncSender<ncollide2d::pipeline::CollisionObjectSlabHandle>>,
shape: shape::ShapeHandle<f32>,
pub shape: shape::ShapeHandle<f32>,
groups: pipeline::CollisionGroups,
......@@ -48,6 +48,7 @@ impl InGameState {
// .add_thread_local(systems::draw_debug_colliders_system())
InGameState {
use crate::colliders;
use crate::components;
use crate::resources;
use ncollide2d::shape;
const DEBUG_COLLIDER_COLOR: resources::Color = resources::Color {
red: 1.0,
green: 0.0,
blue: 0.0,
alpha: 0.5,
pub fn draw_debug_colliders(
position: &components::Position,
collider: &colliders::Collider,
#[resource] rendering: &mut resources::Rendering,
) {
if let Some(ball) = collider.shape.downcast_ref::<shape::Ball<f32>>() {
position.0.x as f64,
position.0.y as f64,
ball.radius as f64,
} else if let Some(cuboid) = collider.shape.downcast_ref::<shape::Cuboid<f32>>() {
position.0.x as f64 - cuboid.half_extents.x as f64,
position.0.y as f64 - cuboid.half_extents.y as f64,
cuboid.half_extents.x as f64 * 2.0,
cuboid.half_extents.y as f64 * 2.0,
mod camera;
mod draw_colliders;
mod level;
mod moving;
mod tmp_player;
pub use camera::camera_system;
pub use draw_colliders::draw_debug_colliders_system;
pub use level::draw_level_layer_system;
pub use moving::{move_camera_to_player_system, move_movable_system};
pub use tmp_player::draw_tmp_player_system;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment