Reflect derived traits on all components and resources: bevy_picking (#15225)

Solves https://github.com/bevyengine/bevy/issues/15187 for bevy_picking
This commit is contained in:
Blazepaws 2024-09-15 18:17:39 +02:00 committed by GitHub
parent b6b28a621f
commit 0c92908baf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 7 deletions

View file

@ -58,6 +58,7 @@ use crate::{
/// The documentation for the [`pointer_events`] explains the events this module exposes and /// The documentation for the [`pointer_events`] explains the events this module exposes and
/// the order in which they fire. /// the order in which they fire.
#[derive(Clone, PartialEq, Debug, Reflect, Component)] #[derive(Clone, PartialEq, Debug, Reflect, Component)]
#[reflect(Component, Debug)]
pub struct Pointer<E: Debug + Clone + Reflect> { pub struct Pointer<E: Debug + Clone + Reflect> {
/// The pointer that triggered this event /// The pointer that triggered this event
pub pointer_id: PointerId, pub pointer_id: PointerId,

View file

@ -190,7 +190,7 @@ fn build_hover_map(
/// the entity will be considered pressed. If that entity is instead being hovered by both pointers, /// the entity will be considered pressed. If that entity is instead being hovered by both pointers,
/// it will be considered hovered. /// it will be considered hovered.
#[derive(Component, Copy, Clone, Default, Eq, PartialEq, Debug, Reflect)] #[derive(Component, Copy, Clone, Default, Eq, PartialEq, Debug, Reflect)]
#[reflect(Component, Default)] #[reflect(Component, Default, PartialEq, Debug)]
pub enum PickingInteraction { pub enum PickingInteraction {
/// The entity is being pressed down by a pointer. /// The entity is being pressed down by a pointer.
Pressed = 2, Pressed = 2,

View file

@ -175,7 +175,7 @@ pub mod prelude {
/// make an entity non-hoverable, or allow items below it to be hovered. See the documentation on /// make an entity non-hoverable, or allow items below it to be hovered. See the documentation on
/// the fields for more details. /// the fields for more details.
#[derive(Component, Debug, Clone, Reflect, PartialEq, Eq)] #[derive(Component, Debug, Clone, Reflect, PartialEq, Eq)]
#[reflect(Component, Default)] #[reflect(Component, Default, Debug, PartialEq)]
pub struct Pickable { pub struct Pickable {
/// Should this entity block entities below it from being picked? /// Should this entity block entities below it from being picked?
/// ///
@ -317,7 +317,7 @@ impl Plugin for DefaultPickingPlugins {
/// This plugin contains several settings, and is added to the wrold as a resource after initialization. You /// This plugin contains several settings, and is added to the wrold as a resource after initialization. You
/// can configure picking settings at runtime through the resource. /// can configure picking settings at runtime through the resource.
#[derive(Copy, Clone, Debug, Resource, Reflect)] #[derive(Copy, Clone, Debug, Resource, Reflect)]
#[reflect(Resource, Default)] #[reflect(Resource, Default, Debug)]
pub struct PickingPlugin { pub struct PickingPlugin {
/// Enables and disables all picking features. /// Enables and disables all picking features.
pub is_enabled: bool, pub is_enabled: bool,

View file

@ -26,7 +26,7 @@ use crate::backend::HitData;
/// This component is needed because pointers can be spawned and despawned, but they need to have a /// This component is needed because pointers can be spawned and despawned, but they need to have a
/// stable ID that persists regardless of the Entity they are associated with. /// stable ID that persists regardless of the Entity they are associated with.
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash, Component, Reflect)] #[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash, Component, Reflect)]
#[reflect(Component, Default)] #[reflect(Component, Default, Debug, Hash, PartialEq)]
pub enum PointerId { pub enum PointerId {
/// The mouse pointer. /// The mouse pointer.
#[default] #[default]
@ -65,7 +65,7 @@ impl PointerId {
/// Holds a list of entities this pointer is currently interacting with, sorted from nearest to /// Holds a list of entities this pointer is currently interacting with, sorted from nearest to
/// farthest. /// farthest.
#[derive(Debug, Default, Clone, Component, Reflect)] #[derive(Debug, Default, Clone, Component, Reflect)]
#[reflect(Component, Default)] #[reflect(Component, Default, Debug)]
pub struct PointerInteraction { pub struct PointerInteraction {
pub(crate) sorted_entities: Vec<(Entity, HitData)>, pub(crate) sorted_entities: Vec<(Entity, HitData)>,
} }
@ -93,7 +93,7 @@ pub fn update_pointer_map(pointers: Query<(Entity, &PointerId)>, mut map: ResMut
/// Tracks the state of the pointer's buttons in response to [`PointerInput`] events. /// Tracks the state of the pointer's buttons in response to [`PointerInput`] events.
#[derive(Debug, Default, Clone, Component, Reflect, PartialEq, Eq)] #[derive(Debug, Default, Clone, Component, Reflect, PartialEq, Eq)]
#[reflect(Component, Default)] #[reflect(Component, Default, Debug, PartialEq)]
pub struct PointerPress { pub struct PointerPress {
primary: bool, primary: bool,
secondary: bool, secondary: bool,
@ -155,7 +155,7 @@ impl PointerButton {
/// Component that tracks a pointer's current [`Location`]. /// Component that tracks a pointer's current [`Location`].
#[derive(Debug, Default, Clone, Component, Reflect, PartialEq)] #[derive(Debug, Default, Clone, Component, Reflect, PartialEq)]
#[reflect(Component, Default)] #[reflect(Component, Default, Debug, PartialEq)]
pub struct PointerLocation { pub struct PointerLocation {
/// The [`Location`] of the pointer. Note that a location is both the target, and the position /// The [`Location`] of the pointer. Note that a location is both the target, and the position
/// on the target. /// on the target.
@ -180,6 +180,7 @@ impl PointerLocation {
/// render target. It is up to picking backends to associate a Pointer's `Location` with a /// render target. It is up to picking backends to associate a Pointer's `Location` with a
/// specific `Camera`, if any. /// specific `Camera`, if any.
#[derive(Debug, Clone, Component, Reflect, PartialEq)] #[derive(Debug, Clone, Component, Reflect, PartialEq)]
#[reflect(Component, Debug, PartialEq)]
pub struct Location { pub struct Location {
/// The [`NormalizedRenderTarget`] associated with the pointer, usually a window. /// The [`NormalizedRenderTarget`] associated with the pointer, usually a window.
pub target: NormalizedRenderTarget, pub target: NormalizedRenderTarget,