1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// mod any_of;
use crateEpochId;
pub use ;
/// Query over modified component.
///
/// Should be used as either [`Modified<&T>`], [`Modified<&mut T>`]
/// or [`Modified<Alt<T>>`].
///
/// This is tracking query that uses epoch lower bound to filter out entities with unmodified components.
// /// Query that concerns exactly one specific component.
// pub trait ComponentQuery: Query {
// /// Returns archetype component for this query.
// fn archetype_component(&self, archetype: &Archetype) -> &ArchetypeComponent;
// }
// /// Query that concerns exactly one specific component.
// pub trait ComponentFetch<'a>: Fetch<'a> {
// /// Returns epoch id of the specified chunk
// fn chunk_epoch(&self, chunk_idx: u32) -> EpochId;
// /// Returns epoch id of the specified item.
// fn item_epoch(&self, idx: u32) -> EpochId;
// }
// pub struct ModifiedFetch<'a, F> {
// fetch: F,
// after_epoch: EpochId,
// epoch: EpochId,
// entity_epochs: NonNull<EpochId>,
// chunk_epochs: NonNull<Cell<EpochId>>,
// archetype_epoch: NonNull<Cell<EpochId>>,
// }
// unsafe impl<'a, F> Fetch<'a> for ModifiedFetch<'a, F>
// where
// F: Fetch<'a>,
// {
// type Item = F::Item;
// fn dangling() -> Self {}
// }
// unsafe impl<Q> Query for Modified<Q>
// where
// Q: ComponentQuery,
// {
// type Item<'a> = Q::Item<'a>;
// type Fetch<'a> = Q::Fetch<'a>;
// const MUTABLE: bool = true;
// #[inline(always)]
// fn component_access(&self, comp: &ComponentInfo) -> Result<Option<Access>, WriteAlias> {
// self.query.component_access(ty)
// }
// #[inline(always)]
// fn visit_archetype(&self, archetype: &Archetype) -> bool {
// self.query.visit_archetype(archetype)
// }
// #[inline(always)]
// unsafe fn access_archetype(&self, archetype: &Archetype, mut f: impl FnMut(TypeId, Access)) {
// self.query.access_archetype(archetype, f);
// }
// #[inline(always)]
// fn visit_archetype_late(&self, archetype: &Archetype) -> bool {
// if !self.query.visit_archetype_late(archetype) {
// return false;
// }
// let component = self.query.archetype_component(archetype);
// unsafe {
// let data = component.data();
// data.epoch.after(self.after_epoch)
// }
// }
// #[inline(always)]
// unsafe fn fetch<'a>(
// &self,
// _arch_idx: u32,
// archetype: &'a Archetype,
// epoch: EpochId,
// ) -> Option<ModifiedFetch<'a, T>> {
// match archetype.component(type_id::<T>()) {
// None => None,
// Some(component) => {
// let data = component.data_mut();
// debug_assert!(data.epoch.after(self.after_epoch));
// Some(ModifiedFetchAlt {
// after_epoch: self.after_epoch,
// epoch,
// ptr: data.ptr.cast(),
// entity_epochs: NonNull::new_unchecked(
// data.entity_epochs.as_ptr() as *mut EpochId
// ),
// chunk_epochs: NonNull::new_unchecked(data.chunk_epochs.as_mut_ptr()).cast(),
// archetype_epoch: NonNull::from(&mut data.epoch).cast(),
// marker: PhantomData,
// })
// }
// }
// }
// }