fix ci tests

This commit is contained in:
Danila 2025-06-08 21:24:40 +03:00
commit 66392b0540
2 changed files with 26 additions and 15 deletions

View File

@ -1,4 +1,5 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")] //! Macros for deriving ECS traits.
#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
extern crate proc_macro; extern crate proc_macro;
@ -29,6 +30,7 @@ enum BundleFieldKind {
const BUNDLE_ATTRIBUTE_NAME: &str = "bundle"; const BUNDLE_ATTRIBUTE_NAME: &str = "bundle";
const BUNDLE_ATTRIBUTE_IGNORE_NAME: &str = "ignore"; const BUNDLE_ATTRIBUTE_IGNORE_NAME: &str = "ignore";
/// Implement the `Bundle` trait.
#[proc_macro_derive(Bundle, attributes(bundle))] #[proc_macro_derive(Bundle, attributes(bundle))]
pub fn derive_bundle(input: TokenStream) -> TokenStream { pub fn derive_bundle(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput); let ast = parse_macro_input!(input as DeriveInput);
@ -187,6 +189,7 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
}) })
} }
/// Implement the `MapEntities` trait.
#[proc_macro_derive(MapEntities, attributes(entities))] #[proc_macro_derive(MapEntities, attributes(entities))]
pub fn derive_map_entities(input: TokenStream) -> TokenStream { pub fn derive_map_entities(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput); let ast = parse_macro_input!(input as DeriveInput);
@ -522,16 +525,19 @@ pub(crate) fn bevy_ecs_path() -> syn::Path {
BevyManifest::shared().get_path("bevy_ecs") BevyManifest::shared().get_path("bevy_ecs")
} }
/// Implement the `Event` trait.
#[proc_macro_derive(Event, attributes(event))] #[proc_macro_derive(Event, attributes(event))]
pub fn derive_event(input: TokenStream) -> TokenStream { pub fn derive_event(input: TokenStream) -> TokenStream {
component::derive_event(input) component::derive_event(input)
} }
/// Implement the `Resource` trait.
#[proc_macro_derive(Resource)] #[proc_macro_derive(Resource)]
pub fn derive_resource(input: TokenStream) -> TokenStream { pub fn derive_resource(input: TokenStream) -> TokenStream {
component::derive_resource(input) component::derive_resource(input)
} }
/// Implement the `Component` trait.
#[proc_macro_derive( #[proc_macro_derive(
Component, Component,
attributes(component, require, relationship, relationship_target, entities) attributes(component, require, relationship, relationship_target, entities)
@ -540,6 +546,7 @@ pub fn derive_component(input: TokenStream) -> TokenStream {
component::derive_component(input) component::derive_component(input)
} }
/// Implement the `FromWorld` trait.
#[proc_macro_derive(FromWorld, attributes(from_world))] #[proc_macro_derive(FromWorld, attributes(from_world))]
pub fn derive_from_world(input: TokenStream) -> TokenStream { pub fn derive_from_world(input: TokenStream) -> TokenStream {
let bevy_ecs_path = bevy_ecs_path(); let bevy_ecs_path = bevy_ecs_path();

View File

@ -208,18 +208,6 @@ pub fn update_interactions(
mut pointers: Query<(&PointerId, &PointerPress, &mut PointerInteraction)>, mut pointers: Query<(&PointerId, &PointerPress, &mut PointerInteraction)>,
mut interact: Query<&mut PickingInteraction>, mut interact: Query<&mut PickingInteraction>,
) { ) {
// Clear all previous hover data from pointers and entities
for (pointer, _, mut pointer_interaction) in &mut pointers {
pointer_interaction.sorted_entities.clear();
if let Some(previously_hovered_entities) = previous_hover_map.get(pointer) {
for entity in previously_hovered_entities.keys() {
if let Ok(mut interaction) = interact.get_mut(*entity) {
*interaction = PickingInteraction::None;
}
}
}
}
// Create a map to hold the aggregated interaction for each entity. This is needed because we // Create a map to hold the aggregated interaction for each entity. This is needed because we
// need to be able to insert the interaction component on entities if they do not exist. To do // need to be able to insert the interaction component on entities if they do not exist. To do
// so we need to know the final aggregated interaction state to avoid the scenario where we set // so we need to know the final aggregated interaction state to avoid the scenario where we set
@ -239,13 +227,29 @@ pub fn update_interactions(
} }
// Take the aggregated entity states and update or insert the component if missing. // Take the aggregated entity states and update or insert the component if missing.
for (hovered_entity, new_interaction) in new_interaction_state.drain() { for (&hovered_entity, &new_interaction) in new_interaction_state.iter() {
if let Ok(mut interaction) = interact.get_mut(hovered_entity) { if let Ok(mut interaction) = interact.get_mut(hovered_entity) {
*interaction = new_interaction; interaction.set_if_neq(new_interaction);
} else if let Ok(mut entity_commands) = commands.get_entity(hovered_entity) { } else if let Ok(mut entity_commands) = commands.get_entity(hovered_entity) {
entity_commands.try_insert(new_interaction); entity_commands.try_insert(new_interaction);
} }
} }
// Clear all previous hover data from pointers that are no longer hovering any entities.
// We do this last to preserve change detection for picking interactions.
for (pointer, _, _) in &mut pointers {
let Some(previously_hovered_entities) = previous_hover_map.get(pointer) else {
continue;
};
for entity in previously_hovered_entities.keys() {
if !new_interaction_state.contains_key(entity) {
if let Ok(mut interaction) = interact.get_mut(*entity) {
interaction.set_if_neq(PickingInteraction::None);
}
}
}
}
} }
/// Merge the interaction state of this entity into the aggregated map. /// Merge the interaction state of this entity into the aggregated map.