Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ jobs:
run: cargo check --target wasm32-unknown-unknown

build-wasm-atomics:
if: ${{ false }} # Disabled temporarily due to https://github.com/rust-lang/rust/issues/145101
runs-on: ubuntu-latest
timeout-minutes: 30
needs: build
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ allow_attributes = "warn"
allow_attributes_without_reason = "warn"

[workspace.lints.rust]
# Strictly temporary until encase fixes dead code generation from ShaderType macros
dead_code = "allow"
missing_docs = "warn"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
unsafe_code = "deny"
Expand Down Expand Up @@ -118,6 +120,8 @@ allow_attributes = "warn"
allow_attributes_without_reason = "warn"

[lints.rust]
# Strictly temporary until encase fixes dead code generation from ShaderType macros
dead_code = "allow"
missing_docs = "warn"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
unsafe_code = "deny"
Expand Down
10 changes: 5 additions & 5 deletions crates/bevy_animation/src/animation_curves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub trait AnimatableProperty: Send + Sync + 'static {

/// The [`EvaluatorId`] used to look up the [`AnimationCurveEvaluator`] for this [`AnimatableProperty`].
/// For a given animated property, this ID should always be the same to allow things like animation blending to occur.
fn evaluator_id(&self) -> EvaluatorId;
fn evaluator_id(&self) -> EvaluatorId<'_>;
}

/// A [`Component`] field that can be animated, defined by a function that reads the component and returns
Expand Down Expand Up @@ -236,7 +236,7 @@ where
Ok((self.func)(c.into_inner()))
}

fn evaluator_id(&self) -> EvaluatorId {
fn evaluator_id(&self) -> EvaluatorId<'_> {
EvaluatorId::ComponentField(&self.evaluator_id)
}
}
Expand Down Expand Up @@ -357,7 +357,7 @@ where
self.curve.domain()
}

fn evaluator_id(&self) -> EvaluatorId {
fn evaluator_id(&self) -> EvaluatorId<'_> {
self.property.evaluator_id()
}

Expand Down Expand Up @@ -476,7 +476,7 @@ where
self.0.domain()
}

fn evaluator_id(&self) -> EvaluatorId {
fn evaluator_id(&self) -> EvaluatorId<'_> {
EvaluatorId::Type(TypeId::of::<WeightsCurveEvaluator>())
}

Expand Down Expand Up @@ -768,7 +768,7 @@ pub trait AnimationCurve: Debug + Send + Sync + 'static {
///
/// This must match the type returned by [`Self::create_evaluator`]. It must
/// be a single type that doesn't depend on the type of the curve.
fn evaluator_id(&self) -> EvaluatorId;
fn evaluator_id(&self) -> EvaluatorId<'_>;

/// Returns a newly-instantiated [`AnimationCurveEvaluator`] for use with
/// this curve.
Expand Down
44 changes: 21 additions & 23 deletions crates/bevy_animation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ struct CurrentEvaluators {
}

impl CurrentEvaluators {
pub(crate) fn keys(&self) -> impl Iterator<Item = EvaluatorId> {
pub(crate) fn keys(&self) -> impl Iterator<Item = EvaluatorId<'_>> {
self.component_properties
.keys()
.map(EvaluatorId::ComponentField)
Expand Down Expand Up @@ -1007,12 +1007,11 @@ pub fn advance_animations(

if let Some(active_animation) = active_animations.get_mut(&node_index) {
// Tick the animation if necessary.
if !active_animation.paused {
if let AnimationNodeType::Clip(ref clip_handle) = node.node_type {
if let Some(clip) = animation_clips.get(clip_handle) {
active_animation.update(delta_seconds, clip.duration);
}
}
if !active_animation.paused
&& let AnimationNodeType::Clip(ref clip_handle) = node.node_type
&& let Some(clip) = animation_clips.get(clip_handle)
{
active_animation.update(delta_seconds, clip.duration);
}
}
}
Expand Down Expand Up @@ -1158,21 +1157,20 @@ pub fn animate_targets(
AnimationEventTarget::Node(target_id),
clip,
active_animation,
) {
if !triggered_events.is_empty() {
par_commands.command_scope(move |mut commands| {
for TimedAnimationEvent { time, event } in
triggered_events.iter()
{
event.trigger(
&mut commands,
entity,
*time,
active_animation.weight,
);
}
});
}
) && !triggered_events.is_empty()
{
par_commands.command_scope(move |mut commands| {
for TimedAnimationEvent { time, event } in
triggered_events.iter()
{
event.trigger(
&mut commands,
entity,
*time,
active_animation.weight,
);
}
});
}
}

Expand Down Expand Up @@ -1462,7 +1460,7 @@ impl<'a> TriggeredEvents<'a> {
self.lower.is_empty() && self.upper.is_empty()
}

fn iter(&self) -> TriggeredEventsIter {
fn iter(&self) -> TriggeredEventsIter<'_> {
match self.direction {
TriggeredEventsDir::Forward => TriggeredEventsIter::Forward(self.lower.iter()),
TriggeredEventsDir::Reverse => TriggeredEventsIter::Reverse(self.lower.iter().rev()),
Expand Down
27 changes: 13 additions & 14 deletions crates/bevy_animation/src/transition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,15 @@ impl AnimationTransitions {
new_animation: AnimationNodeIndex,
transition_duration: Duration,
) -> &'p mut ActiveAnimation {
if let Some(old_animation_index) = self.main_animation.replace(new_animation) {
if let Some(old_animation) = player.animation_mut(old_animation_index) {
if !old_animation.is_paused() {
self.transitions.push(AnimationTransition {
current_weight: old_animation.weight,
weight_decline_per_sec: 1.0 / transition_duration.as_secs_f32(),
animation: old_animation_index,
});
}
}
if let Some(old_animation_index) = self.main_animation.replace(new_animation)
&& let Some(old_animation) = player.animation_mut(old_animation_index)
&& !old_animation.is_paused()
{
self.transitions.push(AnimationTransition {
current_weight: old_animation.weight,
weight_decline_per_sec: 1.0 / transition_duration.as_secs_f32(),
animation: old_animation_index,
});
}

// If already transitioning away from this animation, cancel the transition.
Expand Down Expand Up @@ -135,10 +134,10 @@ pub fn advance_transitions(
remaining_weight -= animation.weight;
}

if let Some(main_animation_index) = animation_transitions.main_animation {
if let Some(ref mut animation) = player.animation_mut(main_animation_index) {
animation.weight = remaining_weight;
}
if let Some(main_animation_index) = animation_transitions.main_animation
&& let Some(ref mut animation) = player.animation_mut(main_animation_index)
{
animation.weight = remaining_weight;
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions crates/bevy_anti_aliasing/src/taa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,16 +350,17 @@ fn extract_taa_settings(mut commands: Commands, mut main_world: ResMut<MainWorld
Option<&mut TemporalAntiAliasing>,
)>();

for (entity, camera, camera_projection, mut taa_settings) in
cameras_3d.iter_mut(&mut main_world)
{
for (entity, camera, camera_projection, taa_settings) in cameras_3d.iter_mut(&mut main_world) {
let has_perspective_projection = matches!(camera_projection, Projection::Perspective(_));
let mut entity_commands = commands
.get_entity(entity)
.expect("Camera entity wasn't synced.");
if taa_settings.is_some() && camera.is_active && has_perspective_projection {
entity_commands.insert(taa_settings.as_deref().unwrap().clone());
taa_settings.as_mut().unwrap().reset = false;
if let Some(mut taa_settings) = taa_settings
&& camera.is_active
&& has_perspective_projection
{
entity_commands.insert(taa_settings.clone());
taa_settings.reset = false;
} else {
entity_commands.remove::<(
TemporalAntiAliasing,
Expand Down
24 changes: 12 additions & 12 deletions crates/bevy_app/src/plugin_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,18 +517,18 @@ impl PluginGroupBuilder {
#[track_caller]
pub fn finish(mut self, app: &mut App) {
for ty in &self.order {
if let Some(entry) = self.plugins.remove(ty) {
if entry.enabled {
debug!("added plugin: {}", entry.plugin.name());
if let Err(AppError::DuplicatePlugin { plugin_name }) =
app.add_boxed_plugin(entry.plugin)
{
panic!(
"Error adding plugin {} in group {}: plugin was already added in application",
plugin_name,
self.group_name
);
}
if let Some(entry) = self.plugins.remove(ty)
&& entry.enabled
{
debug!("added plugin: {}", entry.plugin.name());
if let Err(AppError::DuplicatePlugin { plugin_name }) =
app.add_boxed_plugin(entry.plugin)
{
panic!(
"Error adding plugin {} in group {}: plugin was already added in application",
plugin_name,
self.group_name
);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions crates/bevy_asset/src/io/embedded/embedded_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ impl FilesystemEventHandler for EmbeddedEventHandler {

fn handle(&mut self, absolute_paths: &[PathBuf], event: AssetSourceEvent) {
if self.last_event.as_ref() != Some(&event) {
if let AssetSourceEvent::ModifiedAsset(path) = &event {
if let Ok(file) = File::open(&absolute_paths[0]) {
let mut reader = BufReader::new(file);
let mut buffer = Vec::new();
if let AssetSourceEvent::ModifiedAsset(path) = &event
&& let Ok(file) = File::open(&absolute_paths[0])
{
let mut reader = BufReader::new(file);
let mut buffer = Vec::new();

// Read file into vector.
if reader.read_to_end(&mut buffer).is_ok() {
self.dir.insert_asset(path, buffer);
}
// Read file into vector.
if reader.read_to_end(&mut buffer).is_ok() {
self.dir.insert_asset(path, buffer);
}
}
self.last_event = Some(event.clone());
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_asset/src/io/file/file_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ impl AssetReader for FileAssetReader {
f.ok().and_then(|dir_entry| {
let path = dir_entry.path();
// filter out meta files as they are not considered assets
if let Some(ext) = path.extension().and_then(|e| e.to_str()) {
if ext.eq_ignore_ascii_case("meta") {
return None;
}
if let Some(ext) = path.extension().and_then(|e| e.to_str())
&& ext.eq_ignore_ascii_case("meta")
{
return None;
}
// filter out hidden files. they are not listed by default but are directly targetable
if path
Expand Down
14 changes: 6 additions & 8 deletions crates/bevy_asset/src/io/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,12 @@ impl FileAssetWriter {
/// watching for changes.
pub fn new<P: AsRef<Path> + core::fmt::Debug>(path: P, create_root: bool) -> Self {
let root_path = get_base_path().join(path.as_ref());
if create_root {
if let Err(e) = std::fs::create_dir_all(&root_path) {
error!(
"Failed to create root directory {} for file asset writer: {}",
root_path.display(),
e
);
}
if create_root && let Err(e) = std::fs::create_dir_all(&root_path) {
error!(
"Failed to create root directory {} for file asset writer: {}",
root_path.display(),
e
);
}
Self { root_path }
}
Expand Down
54 changes: 27 additions & 27 deletions crates/bevy_asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1629,37 +1629,37 @@ mod tests {
let loaded_folders = world.resource::<Assets<LoadedFolder>>();
let cool_texts = world.resource::<Assets<CoolText>>();
for event in reader.read(events) {
if let AssetEvent::LoadedWithDependencies { id } = event {
if *id == handle.id() {
let loaded_folder = loaded_folders.get(&handle).unwrap();
let a_handle: Handle<CoolText> =
asset_server.get_handle("text/a.cool.ron").unwrap();
let c_handle: Handle<CoolText> =
asset_server.get_handle("text/c.cool.ron").unwrap();

let mut found_a = false;
let mut found_c = false;
for asset_handle in &loaded_folder.handles {
if asset_handle.id() == a_handle.id().untyped() {
found_a = true;
} else if asset_handle.id() == c_handle.id().untyped() {
found_c = true;
}
if let AssetEvent::LoadedWithDependencies { id } = event
&& *id == handle.id()
{
let loaded_folder = loaded_folders.get(&handle).unwrap();
let a_handle: Handle<CoolText> =
asset_server.get_handle("text/a.cool.ron").unwrap();
let c_handle: Handle<CoolText> =
asset_server.get_handle("text/c.cool.ron").unwrap();

let mut found_a = false;
let mut found_c = false;
for asset_handle in &loaded_folder.handles {
if asset_handle.id() == a_handle.id().untyped() {
found_a = true;
} else if asset_handle.id() == c_handle.id().untyped() {
found_c = true;
}
assert!(found_a);
assert!(found_c);
assert_eq!(loaded_folder.handles.len(), 2);
}
assert!(found_a);
assert!(found_c);
assert_eq!(loaded_folder.handles.len(), 2);

let a_text = cool_texts.get(&a_handle).unwrap();
let b_text = cool_texts.get(&a_text.dependencies[0]).unwrap();
let c_text = cool_texts.get(&c_handle).unwrap();
let a_text = cool_texts.get(&a_handle).unwrap();
let b_text = cool_texts.get(&a_text.dependencies[0]).unwrap();
let c_text = cool_texts.get(&c_handle).unwrap();

assert_eq!("a", a_text.text);
assert_eq!("b", b_text.text);
assert_eq!("c", c_text.text);
assert_eq!("a", a_text.text);
assert_eq!("b", b_text.text);
assert_eq!("c", c_text.text);

return Some(());
}
return Some(());
}
}
None
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ impl<'a> LoadContext<'a> {
/// load_context.add_loaded_labeled_asset(label, loaded_asset);
/// }
/// ```
pub fn begin_labeled_asset(&self) -> LoadContext {
pub fn begin_labeled_asset(&self) -> LoadContext<'_> {
LoadContext::new(
self.asset_server,
self.asset_path.clone(),
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ impl<'a> AssetPath<'a> {
/// Gets the "asset source", if one was defined. If none was defined, the default source
/// will be used.
#[inline]
pub fn source(&self) -> &AssetSourceId {
pub fn source(&self) -> &AssetSourceId<'_> {
&self.source
}

Expand Down
Loading
Loading