Skip to content

Commit 0a81f6b

Browse files
authored
Picking feature (#363)
* add picking feature * fix clippy warning
1 parent b39c0bf commit 0a81f6b

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ all-features = true
1616

1717
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1818
[features]
19-
default = ["manage_clipboard", "open_url", "default_fonts", "render"]
19+
default = ["manage_clipboard", "open_url", "default_fonts", "render", "picking"]
2020
immutable_ctx = []
2121
manage_clipboard = ["arboard", "thread_local", "bytemuck"]
2222
open_url = ["webbrowser"]
2323
default_fonts = ["egui/default_fonts"]
2424
render = [
2525
"bevy_asset",
2626
"bevy_image",
27-
"bevy_picking",
2827
"bevy_render",
2928
"encase",
3029
"bytemuck",
3130
"egui/bytemuck",
3231
"wgpu-types",
3332
]
33+
picking = ["bevy_picking"]
3434
serde = ["egui/serde"]
3535
# The enabled logs will print with the info log level, to make it less cumbersome to debug in browsers.
3636
log_input_events = []
@@ -84,11 +84,13 @@ webbrowser = { version = "1.0.1", optional = true }
8484
bytemuck = { version = "1", optional = true }
8585
bevy_asset = { version = "0.15.0", optional = true }
8686
bevy_image = { version = "0.15.0", optional = true }
87-
bevy_picking = { version = "0.15.0", optional = true }
8887
bevy_render = { version = "0.15.0", optional = true }
8988
encase = { version = "0.10", optional = true }
9089
wgpu-types = { version = "23.0", optional = true }
9190

91+
# `picking` feature
92+
bevy_picking = { version = "0.15.0", optional = true }
93+
9294
# `manage_clipboard` feature
9395
[target.'cfg(not(any(target_arch = "wasm32", target_os = "android")))'.dependencies]
9496
arboard = { version = "3.2.0", optional = true }

src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,16 @@ use bevy_ecs::{
150150
use bevy_image::{Image, ImageSampler};
151151
use bevy_input::InputSystem;
152152
use bevy_log as log;
153-
#[cfg(feature = "render")]
153+
#[cfg(feature = "picking")]
154154
use bevy_picking::{
155155
backend::{HitData, PointerHits},
156156
pointer::{PointerId, PointerLocation},
157157
};
158158
use bevy_reflect::Reflect;
159+
#[cfg(feature = "picking")]
160+
use bevy_render::camera::NormalizedRenderTarget;
159161
#[cfg(feature = "render")]
160162
use bevy_render::{
161-
camera::NormalizedRenderTarget,
162163
extract_component::{ExtractComponent, ExtractComponentPlugin},
163164
extract_resource::{ExtractResource, ExtractResourcePlugin},
164165
render_resource::{LoadOp, SpecializedRenderPipelines},
@@ -227,7 +228,7 @@ pub struct EguiContextSettings {
227228
#[cfg(feature = "open_url")]
228229
pub default_open_url_target: Option<String>,
229230
/// Controls if Egui should capture pointer input when using [`bevy_picking`] (i.e. suppress `bevy_picking` events when a pointer is over an Egui window).
230-
#[cfg(feature = "render")]
231+
#[cfg(feature = "picking")]
231232
pub capture_pointer_input: bool,
232233
/// Controls running of the input systems.
233234
pub input_system_settings: EguiInputSystemSettings,
@@ -251,7 +252,7 @@ impl Default for EguiContextSettings {
251252
scale_factor: 1.0,
252253
#[cfg(feature = "open_url")]
253254
default_open_url_target: None,
254-
#[cfg(feature = "render")]
255+
#[cfg(feature = "picking")]
255256
capture_pointer_input: true,
256257
input_system_settings: EguiInputSystemSettings::default(),
257258
}
@@ -980,7 +981,7 @@ impl Plugin for EguiPlugin {
980981
PostUpdate,
981982
process_output_system.in_set(EguiPostUpdateSet::ProcessOutput),
982983
);
983-
#[cfg(feature = "render")]
984+
#[cfg(feature = "picking")]
984985
app.add_systems(PostUpdate, capture_pointer_input_system);
985986

986987
#[cfg(feature = "render")]
@@ -1180,11 +1181,11 @@ impl EguiClipboard {
11801181
}
11811182

11821183
/// The ordering value used for [`bevy_picking`].
1183-
#[cfg(feature = "render")]
1184+
#[cfg(feature = "picking")]
11841185
pub const PICKING_ORDER: f32 = 1_000_000.0;
11851186

11861187
/// Captures pointers on egui windows for [`bevy_picking`].
1187-
#[cfg(feature = "render")]
1188+
#[cfg(feature = "picking")]
11881189
pub fn capture_pointer_input_system(
11891190
pointers: Query<(&PointerId, &PointerLocation)>,
11901191
mut egui_context: Query<(Entity, &mut EguiContext, &EguiContextSettings), With<Window>>,

0 commit comments

Comments
 (0)