From 62dd03795708e43059af232febd6ab0ec063124f Mon Sep 17 00:00:00 2001 From: Arkitu <85173315+Arkitu@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:56:50 +0100 Subject: [PATCH] custom picking for map --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- src/camera.rs | 33 ++++++++++++++++++++++----------- src/map.rs | 25 +++++++++++++++++-------- src/map/picking.rs | 38 ++++++++++++++++++++++++++++++++++++++ src/ui.rs | 27 ++++++++++++++++++--------- 6 files changed, 99 insertions(+), 32 deletions(-) create mode 100644 src/map/picking.rs diff --git a/Cargo.lock b/Cargo.lock index 4fccc48..616a3a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -338,9 +338,9 @@ dependencies = [ [[package]] name = "bevy-inspector-egui" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd64580f4496ed987c6231c6a7d833068914331a9084bf5a3dd9dcbc66fd8a73" +checksum = "36172627eb6fd8586600972bcbba2880ed6f59e4e243dcf2ed7ff68d987577ce" dependencies = [ "bevy-inspector-egui-derive", "bevy_app", @@ -2402,7 +2402,7 @@ dependencies = [ "vec_map", "wasm-bindgen", "web-sys", - "windows 0.52.0", + "windows 0.58.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 1c7bdcf..691bbc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ bevy = { version = "0.15", default-features = false, features = [ "bevy_gltf", "bevy_mesh_picking_backend", "bevy_pbr", - "bevy_picking", + # "bevy_picking", "bevy_render", "bevy_scene", "bevy_sprite", diff --git a/src/camera.rs b/src/camera.rs index 381ec6d..2c12fa2 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -1,4 +1,6 @@ -use bevy::{input::mouse::MouseWheel, math::NormedVectorSpace, picking::{focus::HoverMap, pointer::PointerId}, prelude::*, utils::{dbg, HashMap}, window::PrimaryWindow}; +use std::time::Duration; + +use bevy::{input::mouse::MouseWheel, math::NormedVectorSpace, picking::{focus::HoverMap, pointer::PointerId}, prelude::*, utils::HashMap, window::PrimaryWindow}; use crate::ui; @@ -20,7 +22,7 @@ fn setup(mut cmds: Commands, window: Query<&Window>) { } #[derive(Resource, Default)] -struct Pointers(HashMap); +struct Pointers(HashMap)>); fn move_cam( mut cam: Query<&mut Transform, With>, @@ -30,18 +32,24 @@ fn move_cam( touches: Res, window: Query<&Window, With>, mut pointers: ResMut, - hover_map: Res + hover_map: Res, + time: Res