bevy_rapier icon indicating copy to clipboard operation
bevy_rapier copied to clipboard

Separate debug-render dimensions from simulation.

Open irate-devil opened this issue 1 year ago • 0 comments

Split debug-render feature into debug-render-2d and debug-render-3d and allow either or both for bevy_rapier2d and bevy_rapier3d.

Fixes #139. Fixes #170.

Replace setup_graphics in boxes3 with the following snippet and run it with cargo run --example boxes3 --features debug-render-2d to see this PR in action.

Snippet
fn setup_graphics(mut commands: Commands, windows: Res<Windows>) {
    use bevy::{core_pipeline::clear_color::ClearColorConfig, render::camera::Viewport};

    let window = windows.primary();

    let half_width = (window.width() / 2.) as u32;
    let height = window.height() as u32;

    commands.spawn_bundle(Camera3dBundle {
        transform: Transform::from_xyz(-30.0, 20.0, 100.0)
            .looking_at(Vec3::X * -30. + Vec3::Y * 10., Vec3::Y),
        camera: Camera {
            viewport: Some(Viewport {
                physical_size: UVec2::new(half_width, height),
                ..default()
            }),
            ..default()
        },
        ..default()
    });
    commands.spawn_bundle(Camera2dBundle {
        transform: Transform::from_xyz(-25.0, 20.0, 100.0),
        camera: Camera {
            viewport: Some(Viewport {
                physical_position: UVec2::X * half_width,
                physical_size: UVec2::new(half_width, height),
                ..default()
            }),
            priority: 1,
            ..default()
        },
        projection: OrthographicProjection {
            scale: 0.15,
            ..Default::default()
        },
        camera_2d: Camera2d {
            clear_color: ClearColorConfig::None,
        },
        ..default()
    });
}

I kept the debug-render feature around partially because removing it broke the checks q: and that way this is not a breaking change which is nice? Probably better to remove it though since it's redundant.

irate-devil avatar Jul 31 '22 16:07 irate-devil