Skip to content

Commit

Permalink
Bump bevy_egui.
Browse files Browse the repository at this point in the history
  • Loading branch information
n3vu0r committed Feb 20, 2024
1 parent dfb1aed commit 8698abe
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ c11-orbit = ["trackball/cc"]

[dependencies]
bevy = { version = "0.13.0", default-features = false, features = ["bevy_render"] }
bevy_egui = { version = "0.24.0", default-features = false, optional = true }
bevy_egui = { version = "0.25.0", default-features = false, features = ["render"], optional = true }
trackball = { git = "https://github.com/qu1x/trackball", features = ["glam"] }

[dev-dependencies.bevy]
Expand Down
17 changes: 6 additions & 11 deletions examples/egui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use std::f32::consts::PI;

use bevy::{
core_pipeline::clear_color::ClearColorConfig,
prelude::*,
render::{
camera::RenderTarget,
Expand Down Expand Up @@ -91,7 +90,7 @@ fn setup(
..default()
};

let cube_handle = meshes.add(Mesh::from(shape::Cube { size: 4.0 }));
let cube_handle = meshes.add(Cuboid::new(4.0, 4.0, 4.0));
let default_material = StandardMaterial {
base_color: Color::rgb(0.8, 0.7, 0.6),
reflectance: 0.02,
Expand All @@ -117,7 +116,7 @@ fn setup(

// Cube parameters.
let cube_size = 4.0;
let cube_handle = meshes.add(Mesh::from(shape::Box::new(cube_size, cube_size, cube_size)));
let cube_handle = meshes.add(Cuboid::new(cube_size, cube_size, cube_size));

// Main pass cube.
let main_material_handle = materials.add(default_material);
Expand All @@ -142,7 +141,7 @@ fn setup(
commands.spawn(SpotLightBundle {
transform: Transform::from_xyz(eye.x, eye.y, eye.z).looking_at(target, up),
spot_light: SpotLight {
intensity: 4400.0, // lumens
intensity: 10_000_000.,
range: 100.0,
color: Color::WHITE,
shadows_enabled: true,
Expand All @@ -166,14 +165,11 @@ fn setup(
commands
.spawn((
Camera3dBundle {
camera_3d: Camera3d {
clear_color: ClearColorConfig::Custom(Color::rgba(1.0, 1.0, 1.0, 0.0)),
..default()
},
camera: Camera {
// render before the "main pass" camera
order: -1,
target: RenderTarget::Image(image_handle),
clear_color: ClearColorConfig::Custom(Color::rgba(1.0, 1.0, 1.0, 0.0)),
..default()
},
..default()
Expand Down Expand Up @@ -248,13 +244,12 @@ fn color_picker_widget(ui: &mut egui::Ui, color: &mut Color) -> egui::Response {
egui::color_picker::Alpha::Opaque,
);
let [r, g, b, a] = egui_color.to_srgba_unmultiplied();
*color = [
*color = Color::rgba(
r as f32 / 255.0,
g as f32 / 255.0,
b as f32 / 255.0,
a as f32 / 255.0,
]
.into();
);
res
}

Expand Down
2 changes: 1 addition & 1 deletion src/camera.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use bevy::{prelude::*, render::camera::ScalingMode, transform::components::Transform};
use bevy::{prelude::*, render::camera::ScalingMode};
use trackball::{approx::AbsDiffEq, nalgebra::Point2, Clamp, Delta, Fixed, Frame, Scope};

/// Trackball camera component mainly defined by [`Frame`] and [`Scope`].
Expand Down
8 changes: 2 additions & 6 deletions src/controller.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use bevy::{
input::{
keyboard::KeyCode,
mouse::{MouseMotion, MouseWheel},
},
input::mouse::{MouseMotion, MouseWheel},
prelude::*,
time::Time,
window::{CursorGrabMode, CursorIcon, PrimaryWindow},
window::{CursorGrabMode, PrimaryWindow},
};
pub use input::{TrackballInput, TrackballVelocity, TrackballWheelUnit};
use key::key;
Expand Down
2 changes: 1 addition & 1 deletion src/controller/input.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::{input::keyboard::KeyCode, prelude::*};
use bevy::prelude::*;
use trackball::Fixed;

/// Trackball controller input mappings and settings.
Expand Down
2 changes: 1 addition & 1 deletion src/controller/key.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::{input::keyboard::KeyCode, prelude::*, window::CursorGrabMode};
use bevy::{prelude::*, window::CursorGrabMode};
use trackball::nalgebra::{Point3, Unit, UnitQuaternion};

use crate::{TrackballCamera, TrackballController, TrackballEvent};
Expand Down
2 changes: 1 addition & 1 deletion src/controller/mouse.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bevy::{
input::mouse::{MouseMotion, MouseScrollUnit, MouseWheel},
prelude::*,
window::{CursorGrabMode, CursorIcon},
window::CursorGrabMode,
};
use trackball::{
nalgebra::{Point2, Point3},
Expand Down
6 changes: 3 additions & 3 deletions src/controller/viewport.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use bevy::prelude::*;
use bevy::{
input::{keyboard::KeyCode, mouse::MouseWheel, touch::TouchPhase},
input::{mouse::MouseWheel, touch::TouchPhase},
prelude::*,
render::camera::RenderTarget,
window::{PrimaryWindow, Window, WindowRef},
window::{PrimaryWindow, WindowRef},
};

use super::{TrackballCamera, TrackballController};
Expand Down
12 changes: 4 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,10 @@ impl Plugin for TrackballPlugin {
mut viewport: ResMut<TrackballViewport>,
mut contexts: Query<&mut EguiContext>,
) {
let stolen = contexts
.iter_mut()
.next()
.map(|mut context| {
let context = context.get_mut();
context.wants_pointer_input() || context.wants_keyboard_input()
})
.unwrap_or_default();
let stolen = contexts.iter_mut().next().is_some_and(|mut context| {
let context = context.get_mut();
context.wants_pointer_input() || context.wants_keyboard_input()
});
viewport.set_stolen(stolen.then_some(2));
}

Expand Down

0 comments on commit 8698abe

Please sign in to comment.