jakobhellermann / bevy-inspector-egui

Inspector plugin for the bevy game engine
Apache License 2.0
1.1k stars 164 forks source link

Running egui_dock.rs example failed. #195

Open gloridifice opened 2 months ago

gloridifice commented 2 months ago
Caused by:
    In a RenderPass
      note: encoder = `main_opaque_pass_3d_command_encoder`
    In a set_viewport command
    Viewport has invalid rect Rect { x: 1501.0, y: 48.0, w: 5998.0, h: 7951.0 }; origin and/or size is less than or equal to 0, and/or is not contained in the render target (2560, 1440, 1)

Log: https://gist.github.com/gloridifice/088ce7de2c1502ccf86dd8bd9691b0c4

SuddenlyHazel commented 2 months ago

Seeing this happen as well. I'm not exactly sure the root cause. But, my best guess as of now is that

ui_state.viewport_rect.size()

is producing some absurd size on the first call. I'm not familiar enough with the codebase to provide more thoughts 🤔 .

If you modify you code as follows it'll at least get you working again:

if viewport_size.x > window.resolution.physical_width() as f32
    || viewport_size.y > window.resolution.physical_height() as f32
{
    return;
}

cam.viewport = Some(bevy::render::camera::Viewport {
    physical_position: UVec2::new(viewport_pos.x as u32, viewport_pos.y as u32),
    physical_size: UVec2::new( viewport_size.x as u32,  viewport_size.y as u32),
    depth: 0.0..1.0,
});