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
@ -453,16 +453,16 @@ fn entity_from_path(
|
|||||||
/// Verify that there are no ancestors of a given entity that have an [`AnimationPlayer`].
|
/// Verify that there are no ancestors of a given entity that have an [`AnimationPlayer`].
|
||||||
fn verify_no_ancestor_player(
|
fn verify_no_ancestor_player(
|
||||||
player_parent: Option<&Parent>,
|
player_parent: Option<&Parent>,
|
||||||
parents: &Query<(Option<With<AnimationPlayer>>, Option<&Parent>)>,
|
parents: &Query<(Has<AnimationPlayer>, Option<&Parent>)>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let Some(mut current) = player_parent.map(Parent::get) else {
|
let Some(mut current) = player_parent.map(Parent::get) else {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
loop {
|
loop {
|
||||||
let Ok((maybe_player, parent)) = parents.get(current) else {
|
let Ok((has_player, parent)) = parents.get(current) else {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
if maybe_player.is_some() {
|
if has_player {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if let Some(parent) = parent {
|
if let Some(parent) = parent {
|
||||||
@ -483,7 +483,7 @@ pub fn animation_player(
|
|||||||
names: Query<&Name>,
|
names: Query<&Name>,
|
||||||
transforms: Query<&mut Transform>,
|
transforms: Query<&mut Transform>,
|
||||||
morphs: Query<&mut MorphWeights>,
|
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)>,
|
mut animation_players: Query<(Entity, Option<&Parent>, &mut AnimationPlayer)>,
|
||||||
) {
|
) {
|
||||||
animation_players
|
animation_players
|
||||||
@ -515,7 +515,7 @@ fn run_animation_player(
|
|||||||
transforms: &Query<&mut Transform>,
|
transforms: &Query<&mut Transform>,
|
||||||
morphs: &Query<&mut MorphWeights>,
|
morphs: &Query<&mut MorphWeights>,
|
||||||
maybe_parent: Option<&Parent>,
|
maybe_parent: Option<&Parent>,
|
||||||
parents: &Query<(Option<With<AnimationPlayer>>, Option<&Parent>)>,
|
parents: &Query<(Has<AnimationPlayer>, Option<&Parent>)>,
|
||||||
children: &Query<&Children>,
|
children: &Query<&Children>,
|
||||||
) {
|
) {
|
||||||
let paused = player.paused;
|
let paused = player.paused;
|
||||||
@ -601,7 +601,7 @@ fn apply_animation(
|
|||||||
transforms: &Query<&mut Transform>,
|
transforms: &Query<&mut Transform>,
|
||||||
morphs: &Query<&mut MorphWeights>,
|
morphs: &Query<&mut MorphWeights>,
|
||||||
maybe_parent: Option<&Parent>,
|
maybe_parent: Option<&Parent>,
|
||||||
parents: &Query<(Option<With<AnimationPlayer>>, Option<&Parent>)>,
|
parents: &Query<(Has<AnimationPlayer>, Option<&Parent>)>,
|
||||||
children: &Query<&Children>,
|
children: &Query<&Children>,
|
||||||
) {
|
) {
|
||||||
if let Some(animation_clip) = animations.get(&animation.animation_clip) {
|
if let Some(animation_clip) = animations.get(&animation.animation_clip) {
|
||||||
|
@ -256,8 +256,8 @@ pub fn extract_meshes(
|
|||||||
&GlobalTransform,
|
&GlobalTransform,
|
||||||
Option<&PreviousGlobalTransform>,
|
Option<&PreviousGlobalTransform>,
|
||||||
&Handle<Mesh>,
|
&Handle<Mesh>,
|
||||||
Option<With<NotShadowReceiver>>,
|
Has<NotShadowReceiver>,
|
||||||
Option<With<NotShadowCaster>>,
|
Has<NotShadowCaster>,
|
||||||
Has<NoAutomaticBatching>,
|
Has<NoAutomaticBatching>,
|
||||||
)>,
|
)>,
|
||||||
>,
|
>,
|
||||||
@ -278,7 +278,7 @@ pub fn extract_meshes(
|
|||||||
}
|
}
|
||||||
let transform = transform.affine();
|
let transform = transform.affine();
|
||||||
let previous_transform = previous_transform.map(|t| t.0).unwrap_or(transform);
|
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()
|
MeshFlags::empty()
|
||||||
} else {
|
} else {
|
||||||
MeshFlags::SHADOW_RECEIVER
|
MeshFlags::SHADOW_RECEIVER
|
||||||
@ -298,7 +298,7 @@ pub fn extract_meshes(
|
|||||||
RenderMeshInstance {
|
RenderMeshInstance {
|
||||||
mesh_asset_id: handle.id(),
|
mesh_asset_id: handle.id(),
|
||||||
transforms,
|
transforms,
|
||||||
shadow_caster: not_caster.is_none(),
|
shadow_caster: !not_caster,
|
||||||
material_bind_group_id: MaterialBindGroupId::default(),
|
material_bind_group_id: MaterialBindGroupId::default(),
|
||||||
automatic_batching: !no_automatic_batching,
|
automatic_batching: !no_automatic_batching,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user