@@ -574,6 +574,29 @@ macro_rules! impl_flag_filter {
574
574
575
575
impl_flag_filter ! (
576
576
/// Filter that retrieves components of type `T` that have been added since the start of the frame
577
+ ///
578
+ /// This filter is useful as a performance optimization as it means that the query contains fewer items
579
+ /// for a system to iterate over.
580
+ ///
581
+ /// Because the ordering of systems can change and this filter is only effective on changes before the query executes
582
+ /// you need to use explicit dependency ordering or ordered stages for these query filters to be useful.
583
+ ///
584
+ ///
585
+ /// Example:
586
+ /// ```
587
+ /// # use bevy_ecs::system::Query;
588
+ /// # use bevy_ecs::query::Added;
589
+ /// #
590
+ /// # #[derive(Debug)]
591
+ /// # struct Name {};
592
+ /// # struct Transform {};
593
+ /// #
594
+ /// fn print_add_name_component(query: Query<&Name, Added<Name>>) {
595
+ /// for name in query.iter() {
596
+ /// println!("Named entity created: {:?}", name)
597
+ /// }
598
+ /// }
599
+ /// ```
577
600
Added ,
578
601
AddedState ,
579
602
AddedFetch ,
@@ -583,6 +606,28 @@ impl_flag_filter!(
583
606
impl_flag_filter ! (
584
607
/// Filter that retrieves components of type `T` that have been mutated since the start of the frame.
585
608
/// Added components do not count as mutated.
609
+ ///
610
+ /// This filter is useful as a performance optimization as it means that the query contains fewer items
611
+ /// for a system to iterate over.
612
+ ///
613
+ /// Because the ordering of systems can change and this filter is only effective on changes before the query executes
614
+ /// you need to use explicit dependency ordering or ordered stages for these query filters to be useful.
615
+ ///
616
+ /// Example:
617
+ /// ```
618
+ /// # use bevy_ecs::system::Query;
619
+ /// # use bevy_ecs::query::Mutated;
620
+ /// #
621
+ /// # #[derive(Debug)]
622
+ /// # struct Name {};
623
+ /// # struct Transform {};
624
+ /// #
625
+ /// fn print_moving_objects_system(query: Query<&Name, Mutated<Transform>>) {
626
+ /// for name in query.iter() {
627
+ /// println!("Entity Moved: {:?}", name)
628
+ /// }
629
+ /// }
630
+ /// ```
586
631
Mutated ,
587
632
MutatedState ,
588
633
MutatedFetch ,
@@ -591,6 +636,14 @@ impl_flag_filter!(
591
636
592
637
impl_flag_filter ! (
593
638
/// Filter that retrieves components of type `T` that have been added or mutated since the start of the frame
639
+ ///
640
+ /// This filter is useful as a performance optimization as it means that the query contains fewer items
641
+ /// for a system to iterate over.
642
+ ///
643
+ /// Because the ordering of systems can change and this filter is only effective on changes before the query executes
644
+ /// you need to use explicit dependency ordering or ordered stages for these query filters to be useful.
645
+ ///
646
+ /// Also see the documentation for [`Mutated<T>`] and [`Added`] as this filter is a logical OR of them.
594
647
Changed ,
595
648
ChangedState ,
596
649
ChangedFetch ,
0 commit comments