Skip to content

Commit 6df768a

Browse files
committed
chore: update to 0.16 🎉
Some notes: - bevy_core was removed upstream in bevyengine/bevy#16897 - we actually just used bevy_core for `Name` which is now exposed through bevy_ecs
1 parent 3b6f726 commit 6df768a

File tree

15 files changed

+391
-390
lines changed

15 files changed

+391
-390
lines changed

Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ members = [
77

88
[workspace.dependencies]
99
tracing = "0.1"
10-
bevy_ecs = "0.15"
11-
bevy_app = "0.15"
12-
bevy_core = "0.15"
10+
bevy_ecs = "0.16.0"
11+
bevy_app = "0.16.0"
1312

1413
# proc macro
1514
bevy-trait-query-impl = { version = "0.7.0", path = "./bevy-trait-query-impl" }
@@ -20,4 +19,4 @@ proc-macro-crate = "3"
2019

2120
# dev deps
2221
criterion = "0.5"
23-
bevy = { version = "0.15", default-features = false }
22+
bevy = { version = "0.16.0", default-features = false }

benches/all.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![allow(clippy::all)]
22

3-
use bevy_core::Name;
43
use bevy_ecs::prelude::*;
54
use bevy_trait_query::*;
65
use criterion::*;

benches/concrete.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![allow(clippy::all)]
22

3-
use bevy_core::Name;
43
use bevy_ecs::prelude::*;
54
use bevy_trait_query::*;
65
use criterion::*;

benches/one.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![allow(clippy::all)]
22

3-
use bevy_core::Name;
43
use bevy_ecs::prelude::*;
54
use bevy_trait_query::*;
65
use criterion::*;

bevy-trait-query-impl/src/lib.rs

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,30 @@ fn impl_trait_query(arg: TokenStream, item: TokenStream) -> Result<TokenStream2>
152152
#where_clause
153153
{
154154
type ReadOnly = Self;
155+
156+
const IS_READ_ONLY: bool = true;
157+
158+
type Item<'__w> = #my_crate::ReadTraits<'__w, #trait_object>;
159+
160+
#[inline]
161+
fn shrink<'wlong: 'wshort, 'wshort>(
162+
item: Self::Item<'wlong>,
163+
) -> Self::Item<'wshort> {
164+
item
165+
}
166+
167+
#[inline]
168+
unsafe fn fetch<'w>(
169+
fetch: &mut Self::Fetch<'w>,
170+
entity: #imports::Entity,
171+
table_row: #imports::TableRow,
172+
) -> Self::Item<'w> {
173+
<#my_crate::All<&#trait_object> as #imports::QueryData>::fetch(
174+
fetch,
175+
entity,
176+
table_row,
177+
)
178+
}
155179
}
156180
unsafe impl #impl_generics #imports::ReadOnlyQueryData for &#trait_object
157181
#where_clause
@@ -160,7 +184,6 @@ fn impl_trait_query(arg: TokenStream, item: TokenStream) -> Result<TokenStream2>
160184
unsafe impl #impl_generics_with_lifetime #imports::WorldQuery for &'__a #trait_object
161185
#where_clause
162186
{
163-
type Item<'__w> = #my_crate::ReadTraits<'__w, #trait_object>;
164187
type Fetch<'__w> = <#my_crate::All<&'__a #trait_object> as #imports::WorldQuery>::Fetch<'__w>;
165188
type State = #my_crate::TraitQueryState<#trait_object>;
166189

@@ -179,13 +202,6 @@ fn impl_trait_query(arg: TokenStream, item: TokenStream) -> Result<TokenStream2>
179202
)
180203
}
181204

182-
#[inline]
183-
fn shrink<'wlong: 'wshort, 'wshort>(
184-
item: Self::Item<'wlong>,
185-
) -> Self::Item<'wshort> {
186-
item
187-
}
188-
189205
const IS_DENSE: bool = <#my_crate::All<&#trait_object> as #imports::WorldQuery>::IS_DENSE;
190206

191207
#[inline]
@@ -209,19 +225,6 @@ fn impl_trait_query(arg: TokenStream, item: TokenStream) -> Result<TokenStream2>
209225
<#my_crate::All<&#trait_object> as #imports::WorldQuery>::set_table(fetch, state, table);
210226
}
211227

212-
#[inline]
213-
unsafe fn fetch<'w>(
214-
fetch: &mut Self::Fetch<'w>,
215-
entity: #imports::Entity,
216-
table_row: #imports::TableRow,
217-
) -> Self::Item<'w> {
218-
<#my_crate::All<&#trait_object> as #imports::WorldQuery>::fetch(
219-
fetch,
220-
entity,
221-
table_row,
222-
)
223-
}
224-
225228
#[inline]
226229
fn update_component_access(
227230
state: &Self::State,
@@ -261,12 +264,35 @@ fn impl_trait_query(arg: TokenStream, item: TokenStream) -> Result<TokenStream2>
261264
#where_clause
262265
{
263266
type ReadOnly = &'__a #trait_object;
267+
268+
type Item<'__w> = #my_crate::WriteTraits<'__w, #trait_object>;
269+
270+
const IS_READ_ONLY: bool = false;
271+
272+
#[inline]
273+
fn shrink<'wlong: 'wshort, 'wshort>(
274+
item: Self::Item<'wlong>,
275+
) -> Self::Item<'wshort> {
276+
item
277+
}
278+
279+
#[inline]
280+
unsafe fn fetch<'w>(
281+
fetch: &mut Self::Fetch<'w>,
282+
entity: #imports::Entity,
283+
table_row: #imports::TableRow,
284+
) -> Self::Item<'w> {
285+
<#my_crate::All<&mut #trait_object> as #imports::QueryData>::fetch(
286+
fetch,
287+
entity,
288+
table_row,
289+
)
290+
}
264291
}
265292

266293
unsafe impl #impl_generics_with_lifetime #imports::WorldQuery for &'__a mut #trait_object
267294
#where_clause
268295
{
269-
type Item<'__w> = #my_crate::WriteTraits<'__w, #trait_object>;
270296
type Fetch<'__w> = <#my_crate::All<&'__a #trait_object> as #imports::WorldQuery>::Fetch<'__w>;
271297
type State = #my_crate::TraitQueryState<#trait_object>;
272298

@@ -285,13 +311,6 @@ fn impl_trait_query(arg: TokenStream, item: TokenStream) -> Result<TokenStream2>
285311
)
286312
}
287313

288-
#[inline]
289-
fn shrink<'wlong: 'wshort, 'wshort>(
290-
item: Self::Item<'wlong>,
291-
) -> Self::Item<'wshort> {
292-
item
293-
}
294-
295314
const IS_DENSE: bool = <#my_crate::All<&mut #trait_object> as #imports::WorldQuery>::IS_DENSE;
296315

297316
#[inline]
@@ -315,19 +334,6 @@ fn impl_trait_query(arg: TokenStream, item: TokenStream) -> Result<TokenStream2>
315334
<#my_crate::All<&mut #trait_object> as #imports::WorldQuery>::set_table(fetch, state, table);
316335
}
317336

318-
#[inline]
319-
unsafe fn fetch<'w>(
320-
fetch: &mut Self::Fetch<'w>,
321-
entity: #imports::Entity,
322-
table_row: #imports::TableRow,
323-
) -> Self::Item<'w> {
324-
<#my_crate::All<&mut #trait_object> as #imports::WorldQuery>::fetch(
325-
fetch,
326-
entity,
327-
table_row,
328-
)
329-
}
330-
331337
#[inline]
332338
fn update_component_access(
333339
state: &Self::State,

bevy-trait-query/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ keywords = ["bevy", "gamedev", "plugin", "query", "trait"]
1010
categories = ["game-development"]
1111

1212
[features]
13-
default = ["bevy_app", "bevy_core"]
13+
default = ["bevy_app"]
1414

1515
[dependencies]
1616
bevy-trait-query-impl.workspace = true
1717
tracing.workspace = true
1818
bevy_ecs.workspace = true
1919
bevy_app = { workspace = true, optional = true}
20-
bevy_core = { workspace = true, optional = true}
2120

2221
[dev-dependencies]
2322
criterion.workspace = true

bevy-trait-query/src/all/core/read.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'a, Trait: ?Sized + TraitQuery> Iterator for ReadTableTraitsIter<'a, Trait>
5252
fn next(&mut self) -> Option<Self::Item> {
5353
// Iterate the remaining table components that are registered,
5454
// until we find one that exists in the table.
55-
let (ptr, component, meta) = unsafe { zip_exact(&mut self.components, &mut self.meta) }
55+
let (ptr, component_id, meta) = unsafe { zip_exact(&mut self.components, &mut self.meta) }
5656
.find_map(|(&component, meta)| {
5757
// SAFETY: we know that the `table_row` is a valid index.
5858
let ptr = unsafe { self.table.get_component(component, self.table_row) }?;
@@ -64,21 +64,28 @@ impl<'a, Trait: ?Sized + TraitQuery> Iterator for ReadTableTraitsIter<'a, Trait>
6464
// Read access has been registered, so we can dereference it immutably.
6565
let added_tick = unsafe {
6666
self.table
67-
.get_added_tick(component, self.table_row)?
67+
.get_added_tick(component_id, self.table_row)?
6868
.deref()
6969
};
7070
let changed_tick = unsafe {
7171
self.table
72-
.get_changed_tick(component, self.table_row)?
72+
.get_changed_tick(component_id, self.table_row)?
7373
.deref()
7474
};
75+
let location = unsafe {
76+
self.table
77+
.get_changed_by(component_id, self.table_row)
78+
.transpose()?
79+
.map(|loc| loc.deref())
80+
};
7581

7682
Some(Ref::new(
7783
trait_object,
7884
added_tick,
7985
changed_tick,
8086
self.last_run,
8187
self.this_run,
88+
location,
8289
))
8390
}
8491
}
@@ -100,12 +107,14 @@ impl<'a, Trait: ?Sized + TraitQuery> Iterator for ReadSparseTraitsIter<'a, Trait
100107
fn next(&mut self) -> Option<Self::Item> {
101108
// Iterate the remaining sparse set components that are registered,
102109
// until we find one that exists in the archetype.
103-
let (ptr, ticks_ptr, meta) = unsafe { zip_exact(&mut self.components, &mut self.meta) }
104-
.find_map(|(&component, meta)| {
105-
let set = self.sparse_sets.get(component)?;
106-
let (ptr, ticks, _) = set.get_with_ticks(self.entity)?;
107-
Some((ptr, ticks, meta))
108-
})?;
110+
let (ptr, ticks_ptr, meta, location) =
111+
unsafe { zip_exact(&mut self.components, &mut self.meta) }.find_map(
112+
|(&component, meta)| {
113+
let set = self.sparse_sets.get(component)?;
114+
let (ptr, ticks, location) = set.get_with_ticks(self.entity)?;
115+
Some((ptr, ticks, meta, location))
116+
},
117+
)?;
109118
let trait_object = unsafe { meta.dyn_ctor.cast(ptr) };
110119
let added_tick = unsafe { ticks_ptr.added.deref() };
111120
let changed_tick = unsafe { ticks_ptr.changed.deref() };
@@ -115,6 +124,7 @@ impl<'a, Trait: ?Sized + TraitQuery> Iterator for ReadSparseTraitsIter<'a, Trait
115124
changed_tick,
116125
self.last_run,
117126
self.this_run,
127+
location.map(|loc| unsafe { loc.deref() }),
118128
))
119129
}
120130
}

bevy-trait-query/src/all/core/write.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'a, Trait: ?Sized + TraitQuery> Iterator for WriteTableTraitsIter<'a, Trait
5858
fn next(&mut self) -> Option<Self::Item> {
5959
// Iterate the remaining table components that are registered,
6060
// until we find one that exists in the table.
61-
let (ptr, component, meta) = unsafe { zip_exact(&mut self.components, &mut self.meta) }
61+
let (ptr, component_id, meta) = unsafe { zip_exact(&mut self.components, &mut self.meta) }
6262
.find_map(|(&component, meta)| {
6363
// SAFETY: we know that the `table_row` is a valid index.
6464
let ptr = unsafe { self.table.get_component(component, self.table_row) }?;
@@ -75,20 +75,27 @@ impl<'a, Trait: ?Sized + TraitQuery> Iterator for WriteTableTraitsIter<'a, Trait
7575
// we have exclusive access to the corresponding `ComponentTicks`.
7676
let added = unsafe {
7777
self.table
78-
.get_added_tick(component, self.table_row)?
78+
.get_added_tick(component_id, self.table_row)?
7979
.deref_mut()
8080
};
8181
let changed = unsafe {
8282
self.table
83-
.get_changed_tick(component, self.table_row)?
83+
.get_changed_tick(component_id, self.table_row)?
8484
.deref_mut()
8585
};
86+
let location = unsafe {
87+
self.table
88+
.get_changed_by(component_id, self.table_row)
89+
.transpose()?
90+
.map(|loc| loc.deref_mut())
91+
};
8692
Some(Mut::new(
8793
trait_object,
8894
added,
8995
changed,
9096
self.last_run,
9197
self.this_run,
98+
location,
9299
))
93100
}
94101
}
@@ -111,12 +118,12 @@ impl<'a, Trait: ?Sized + TraitQuery> Iterator for WriteSparseTraitsIter<'a, Trai
111118
fn next(&mut self) -> Option<Self::Item> {
112119
// Iterate the remaining sparse set components we have registered,
113120
// until we find one that exists in the archetype.
114-
let (ptr, component_ticks, meta) =
121+
let (ptr, component_ticks, meta, location) =
115122
unsafe { zip_exact(&mut self.components, &mut self.meta) }.find_map(
116123
|(&component, meta)| {
117124
let set = self.sparse_sets.get(component)?;
118-
let (ptr, ticks, _) = set.get_with_ticks(self.entity)?;
119-
Some((ptr, ticks, meta))
125+
let (ptr, ticks, location) = set.get_with_ticks(self.entity)?;
126+
Some((ptr, ticks, meta, location))
120127
},
121128
)?;
122129

@@ -138,6 +145,7 @@ impl<'a, Trait: ?Sized + TraitQuery> Iterator for WriteSparseTraitsIter<'a, Trai
138145
changed,
139146
self.last_run,
140147
self.this_run,
148+
location.map(|loc| unsafe { loc.deref_mut() }),
141149
))
142150
}
143151
}

0 commit comments

Comments
 (0)