Skip to content

Commit

Permalink
Merge branch 'main' into process-configs
Browse files Browse the repository at this point in the history
  • Loading branch information
yyogo authored Mar 16, 2024
2 parents 9f9d643 + 1323de7 commit b8b6710
Show file tree
Hide file tree
Showing 31 changed files with 1,080 additions and 324 deletions.
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,17 @@ description = "Illustrates how to (constantly) rotate an object around an axis"
category = "Transforms"
wasm = true

[[example]]
name = "align"
path = "examples/transforms/align.rs"
doc-scrape-examples = true

[package.metadata.example.align]
name = "Alignment"
description = "A demonstration of Transform's axis-alignment feature"
category = "Transforms"
wasm = true

[[example]]
name = "scale"
path = "examples/transforms/scale.rs"
Expand Down
22 changes: 19 additions & 3 deletions crates/bevy_ecs/src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ type IdCursor = isize;
/// [`Query::get`]: crate::system::Query::get
/// [`World`]: crate::world::World
/// [SemVer]: https://semver.org/
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect))]
#[cfg_attr(
feature = "bevy_reflect",
Expand Down Expand Up @@ -384,9 +384,15 @@ impl<'de> Deserialize<'de> for Entity {
}
}

impl fmt::Debug for Entity {
impl fmt::Display for Entity {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}v{}", self.index(), self.generation())
write!(
f,
"{}v{}|{}",
self.index(),
self.generation(),
self.to_bits()
)
}
}

Expand Down Expand Up @@ -1147,4 +1153,14 @@ mod tests {
assert_ne!(hash, first_hash);
}
}

#[test]
fn entity_display() {
let entity = Entity::from_raw(42);
let string = format!("{}", entity);
let bits = entity.to_bits().to_string();
assert!(string.contains("42"));
assert!(string.contains("v1"));
assert!(string.contains(&bits));
}
}
8 changes: 8 additions & 0 deletions crates/bevy_ecs/src/query/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,17 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {

/// Checks if the query is empty for the given [`World`], where the last change and current tick are given.
///
/// This is equivalent to `self.iter().next().is_none()`, and thus the worst case runtime will be `O(n)`
/// where `n` is the number of *potential* matches. This can be notably expensive for queries that rely
/// on non-archetypal filters such as [`Added`] or [`Changed`] which must individually check each query
/// result for a match.
///
/// # Panics
///
/// If `world` does not match the one used to call `QueryState::new` for this instance.
///
/// [`Added`]: crate::query::Added
/// [`Changed`]: crate::query::Changed
#[inline]
pub fn is_empty(&self, world: &World, last_run: Tick, this_run: Tick) -> bool {
self.validate_world(world.id());
Expand Down
8 changes: 8 additions & 0 deletions crates/bevy_ecs/src/system/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,11 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {

/// Returns `true` if there are no query items.
///
/// This is equivalent to `self.iter().next().is_none()`, and thus the worst case runtime will be `O(n)`
/// where `n` is the number of *potential* matches. This can be notably expensive for queries that rely
/// on non-archetypal filters such as [`Added`] or [`Changed`] which must individually check each query
/// result for a match.
///
/// # Example
///
/// Here, the score is increased only if an entity with a `Player` component is present in the world:
Expand All @@ -1226,6 +1231,9 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
/// }
/// # bevy_ecs::system::assert_is_system(update_score_system);
/// ```
///
/// [`Added`]: crate::query::Added
/// [`Changed`]: crate::query::Changed
#[inline]
pub fn is_empty(&self) -> bool {
// SAFETY:
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_ecs/src/system/system_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ impl<I, O> RemovedSystem<I, O> {
///
/// These are opaque identifiers, keyed to a specific [`World`],
/// and are created via [`World::register_system`].
#[derive(Eq)]
pub struct SystemId<I = (), O = ()>(Entity, std::marker::PhantomData<fn(I) -> O>);

// A manual impl is used because the trait bounds should ignore the `I` and `O` phantom parameters.
impl<I, O> Eq for SystemId<I, O> {}

// A manual impl is used because the trait bounds should ignore the `I` and `O` phantom parameters.
impl<I, O> Copy for SystemId<I, O> {}

Expand Down
Loading

0 comments on commit b8b6710

Please sign in to comment.