Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to fixedbitset 0.5 #12512

Merged
merged 2 commits into from Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/bevy_animation/Cargo.toml
Expand Up @@ -28,7 +28,7 @@ bevy_transform = { path = "../bevy_transform", version = "0.14.0-dev" }
bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.14.0-dev" }

# other
fixedbitset = "0.4"
fixedbitset = "0.5"
petgraph = { version = "0.6", features = ["serde-1"] }
ron = "0.8"
serde = "1"
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/Cargo.toml
Expand Up @@ -25,7 +25,7 @@ petgraph = "0.6"

bitflags = "2.3"
concurrent-queue = "2.4.0"
fixedbitset = "0.4.2"
fixedbitset = "0.5"
rustc-hash = "1.1"
serde = "1"
thiserror = "1.0"
Expand Down
36 changes: 9 additions & 27 deletions crates/bevy_ecs/src/query/access.rs
Expand Up @@ -97,26 +97,17 @@ impl<T: SparseSetIndex> Access<T> {
}
}

/// Increases the set capacity to the specified amount.
///
/// Does nothing if `capacity` is less than or equal to the current value.
pub fn grow(&mut self, capacity: usize) {
self.reads_and_writes.grow(capacity);
self.writes.grow(capacity);
}

/// Adds access to the element given by `index`.
pub fn add_read(&mut self, index: T) {
self.reads_and_writes.grow(index.sparse_set_index() + 1);
self.reads_and_writes.insert(index.sparse_set_index());
self.reads_and_writes
.grow_and_insert(index.sparse_set_index());
}

/// Adds exclusive access to the element given by `index`.
pub fn add_write(&mut self, index: T) {
self.reads_and_writes.grow(index.sparse_set_index() + 1);
self.reads_and_writes.insert(index.sparse_set_index());
self.writes.grow(index.sparse_set_index() + 1);
self.writes.insert(index.sparse_set_index());
self.reads_and_writes
.grow_and_insert(index.sparse_set_index());
self.writes.grow_and_insert(index.sparse_set_index());
}

/// Adds an archetypal (indirect) access to the element given by `index`.
Expand All @@ -128,8 +119,7 @@ impl<T: SparseSetIndex> Access<T> {
///
/// [`Has<T>`]: crate::query::Has
pub fn add_archetypal(&mut self, index: T) {
self.archetypal.grow(index.sparse_set_index() + 1);
self.archetypal.insert(index.sparse_set_index());
self.archetypal.grow_and_insert(index.sparse_set_index());
}

/// Returns `true` if this can access the element given by `index`.
Expand Down Expand Up @@ -389,20 +379,16 @@ impl<T: SparseSetIndex> FilteredAccess<T> {
}

fn add_required(&mut self, index: T) {
let index = index.sparse_set_index();
self.required.grow(index + 1);
self.required.insert(index);
self.required.grow_and_insert(index.sparse_set_index());
}

/// Adds a `With` filter: corresponds to a conjunction (AND) operation.
///
/// Suppose we begin with `Or<(With<A>, With<B>)>`, which is represented by an array of two `AccessFilter` instances.
/// Adding `AND With<C>` via this method transforms it into the equivalent of `Or<((With<A>, With<C>), (With<B>, With<C>))>`.
pub fn and_with(&mut self, index: T) {
let index = index.sparse_set_index();
for filter in &mut self.filter_sets {
filter.with.grow(index + 1);
filter.with.insert(index);
filter.with.grow_and_insert(index.sparse_set_index());
}
}

Expand All @@ -411,10 +397,8 @@ impl<T: SparseSetIndex> FilteredAccess<T> {
/// Suppose we begin with `Or<(With<A>, With<B>)>`, which is represented by an array of two `AccessFilter` instances.
/// Adding `AND Without<C>` via this method transforms it into the equivalent of `Or<((With<A>, Without<C>), (With<B>, Without<C>))>`.
pub fn and_without(&mut self, index: T) {
let index = index.sparse_set_index();
for filter in &mut self.filter_sets {
filter.without.grow(index + 1);
filter.without.insert(index);
filter.without.grow_and_insert(index.sparse_set_index());
}
}

Expand Down Expand Up @@ -689,7 +673,6 @@ mod tests {
fn read_all_access_conflicts() {
// read_all / single write
let mut access_a = Access::<usize>::default();
access_a.grow(10);
access_a.add_write(0);

let mut access_b = Access::<usize>::default();
Expand All @@ -699,7 +682,6 @@ mod tests {

// read_all / read_all
let mut access_a = Access::<usize>::default();
access_a.grow(10);
access_a.read_all();

let mut access_b = Access::<usize>::default();
Expand Down
6 changes: 2 additions & 4 deletions crates/bevy_ecs/src/query/state.rs
Expand Up @@ -304,14 +304,12 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {

let archetype_index = archetype.id().index();
if !self.matched_archetypes.contains(archetype_index) {
self.matched_archetypes.grow(archetype_index + 1);
self.matched_archetypes.set(archetype_index, true);
self.matched_archetypes.grow_and_insert(archetype_index);
self.matched_archetype_ids.push(archetype.id());
}
let table_index = archetype.table_id().as_usize();
if !self.matched_tables.contains(table_index) {
self.matched_tables.grow(table_index + 1);
self.matched_tables.set(table_index, true);
self.matched_tables.grow_and_insert(table_index);
self.matched_table_ids.push(archetype.table_id());
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/Cargo.toml
Expand Up @@ -35,7 +35,7 @@ bevy_derive = { path = "../bevy_derive", version = "0.14.0-dev" }

# other
bitflags = "2.3"
fixedbitset = "0.4"
fixedbitset = "0.5"
# direct dependency required for derive macro
bytemuck = { version = "1", features = ["derive"] }
radsort = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_sprite/Cargo.toml
Expand Up @@ -30,7 +30,7 @@ bevy_derive = { path = "../bevy_derive", version = "0.14.0-dev" }

# other
bytemuck = { version = "1.5", features = ["derive"] }
fixedbitset = "0.4"
fixedbitset = "0.5"
guillotiere = "0.6.0"
thiserror = "1.0"
rectangle-pack = "0.4"
Expand Down