mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
refactor: Change Option<With<T>> query params to Has<T> (#9959)
# Objective `Has<T>` was added to bevy_ecs, but we're still using the `Option<With<T>>` pattern in multiple locations. ## Solution Replace them with `Has<T>`.
This commit is contained in:
parent
dfdc9f8369
commit
21518de0de
2 changed files with 10 additions and 10 deletions
|
@ -453,16 +453,16 @@ fn entity_from_path(
|
|||
/// Verify that there are no ancestors of a given entity that have an [`AnimationPlayer`].
|
||||
fn verify_no_ancestor_player(
|
||||
player_parent: Option<&Parent>,
|
||||
parents: &Query<(Option<With<AnimationPlayer>>, Option<&Parent>)>,
|
||||
parents: &Query<(Has<AnimationPlayer>, Option<&Parent>)>,
|
||||
) -> bool {
|
||||
let Some(mut current) = player_parent.map(Parent::get) else {
|
||||
return true;
|
||||
};
|
||||
loop {
|
||||
let Ok((maybe_player, parent)) = parents.get(current) else {
|
||||
let Ok((has_player, parent)) = parents.get(current) else {
|
||||
return true;
|
||||
};
|
||||
if maybe_player.is_some() {
|
||||
if has_player {
|
||||
return false;
|
||||
}
|
||||
if let Some(parent) = parent {
|
||||
|
@ -483,7 +483,7 @@ pub fn animation_player(
|
|||
names: Query<&Name>,
|
||||
transforms: Query<&mut Transform>,
|
||||
morphs: Query<&mut MorphWeights>,
|
||||
parents: Query<(Option<With<AnimationPlayer>>, Option<&Parent>)>,
|
||||
parents: Query<(Has<AnimationPlayer>, Option<&Parent>)>,
|
||||
mut animation_players: Query<(Entity, Option<&Parent>, &mut AnimationPlayer)>,
|
||||
) {
|
||||
animation_players
|
||||
|
@ -515,7 +515,7 @@ fn run_animation_player(
|
|||
transforms: &Query<&mut Transform>,
|
||||
morphs: &Query<&mut MorphWeights>,
|
||||
maybe_parent: Option<&Parent>,
|
||||
parents: &Query<(Option<With<AnimationPlayer>>, Option<&Parent>)>,
|
||||
parents: &Query<(Has<AnimationPlayer>, Option<&Parent>)>,
|
||||
children: &Query<&Children>,
|
||||
) {
|
||||
let paused = player.paused;
|
||||
|
@ -601,7 +601,7 @@ fn apply_animation(
|
|||
transforms: &Query<&mut Transform>,
|
||||
morphs: &Query<&mut MorphWeights>,
|
||||
maybe_parent: Option<&Parent>,
|
||||
parents: &Query<(Option<With<AnimationPlayer>>, Option<&Parent>)>,
|
||||
parents: &Query<(Has<AnimationPlayer>, Option<&Parent>)>,
|
||||
children: &Query<&Children>,
|
||||
) {
|
||||
if let Some(animation_clip) = animations.get(&animation.animation_clip) {
|
||||
|
|
|
@ -256,8 +256,8 @@ pub fn extract_meshes(
|
|||
&GlobalTransform,
|
||||
Option<&PreviousGlobalTransform>,
|
||||
&Handle<Mesh>,
|
||||
Option<With<NotShadowReceiver>>,
|
||||
Option<With<NotShadowCaster>>,
|
||||
Has<NotShadowReceiver>,
|
||||
Has<NotShadowCaster>,
|
||||
Has<NoAutomaticBatching>,
|
||||
)>,
|
||||
>,
|
||||
|
@ -278,7 +278,7 @@ pub fn extract_meshes(
|
|||
}
|
||||
let transform = transform.affine();
|
||||
let previous_transform = previous_transform.map(|t| t.0).unwrap_or(transform);
|
||||
let mut flags = if not_receiver.is_some() {
|
||||
let mut flags = if not_receiver {
|
||||
MeshFlags::empty()
|
||||
} else {
|
||||
MeshFlags::SHADOW_RECEIVER
|
||||
|
@ -298,7 +298,7 @@ pub fn extract_meshes(
|
|||
RenderMeshInstance {
|
||||
mesh_asset_id: handle.id(),
|
||||
transforms,
|
||||
shadow_caster: not_caster.is_none(),
|
||||
shadow_caster: !not_caster,
|
||||
material_bind_group_id: MaterialBindGroupId::default(),
|
||||
automatic_batching: !no_automatic_batching,
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue