Skip to content

Commit

Permalink
Merge branch 'main' into render-asset-generic-over-target
Browse files Browse the repository at this point in the history
  • Loading branch information
superdump committed Apr 2, 2024
2 parents ff6e00d + 8092e2c commit dab44e9
Show file tree
Hide file tree
Showing 71 changed files with 1,018 additions and 430 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
check-compiles:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: ci
needs: test
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@beta
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_color/src/hsla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ mod tests {
use super::*;
use crate::{
color_difference::EuclideanDistance, test_colors::TEST_COLORS, testing::assert_approx_eq,
Srgba,
};

#[test]
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_color/src/hsva.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ mod tests {
use super::*;
use crate::{
color_difference::EuclideanDistance, test_colors::TEST_COLORS, testing::assert_approx_eq,
Srgba,
};

#[test]
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_color/src/hwba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ mod tests {
use super::*;
use crate::{
color_difference::EuclideanDistance, test_colors::TEST_COLORS, testing::assert_approx_eq,
Srgba,
};

#[test]
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_color/src/laba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ mod tests {
use super::*;
use crate::{
color_difference::EuclideanDistance, test_colors::TEST_COLORS, testing::assert_approx_eq,
Srgba,
};

#[test]
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_color/src/lcha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ mod tests {
use super::*;
use crate::{
color_difference::EuclideanDistance, test_colors::TEST_COLORS, testing::assert_approx_eq,
Srgba,
};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_color/src/oklaba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl From<Oklaba> for Xyza {
#[cfg(test)]
mod tests {
use super::*;
use crate::{test_colors::TEST_COLORS, testing::assert_approx_eq, Srgba};
use crate::{test_colors::TEST_COLORS, testing::assert_approx_eq};

#[test]
fn test_to_from_srgba() {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_color/src/oklcha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl From<Oklcha> for Xyza {
#[cfg(test)]
mod tests {
use super::*;
use crate::{test_colors::TEST_COLORS, testing::assert_approx_eq, Srgba};
use crate::{test_colors::TEST_COLORS, testing::assert_approx_eq};

#[test]
fn test_to_from_srgba() {
Expand Down
2 changes: 0 additions & 2 deletions crates/bevy_ecs/src/entity/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ pub type EntityHashSet = hashbrown::HashSet<Entity, EntityHash>;
#[cfg(test)]
mod tests {
use super::*;
#[cfg(feature = "bevy_reflect")]
use bevy_reflect::Reflect;
use static_assertions::assert_impl_all;

// Check that the HashMaps are Clone if the key/values are Clone
Expand Down
2 changes: 0 additions & 2 deletions crates/bevy_ecs/src/query/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ mod tests {
use crate::prelude::*;
use crate::world::FilteredEntityRef;

use super::QueryBuilder;

#[derive(Component, PartialEq, Debug)]
struct A(usize);

Expand Down
5 changes: 5 additions & 0 deletions crates/bevy_ecs/src/removal_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ impl RemovedComponentEvents {
}
}

/// Returns an iterator over components and their entity events.
pub fn iter(&self) -> impl Iterator<Item = (&ComponentId, &Events<RemovedComponentEntity>)> {
self.event_sets.iter()
}

/// Gets the event storage for a given component.
pub fn get(
&self,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ mod tests {
use crate as bevy_ecs;
use crate::component::Component;
use crate::schedule::IntoSystemConfigs;
use crate::schedule::{common_conditions::not, State, States};
use crate::schedule::{State, States};
use crate::system::Local;
use crate::{change_detection::ResMut, schedule::Schedule, world::World};
use bevy_ecs_macros::Event;
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_ecs/src/schedule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod tests {
use std::sync::atomic::{AtomicU32, Ordering};

pub use crate as bevy_ecs;
pub use crate::schedule::{IntoSystemSetConfigs, Schedule, SystemSet};
pub use crate::schedule::{Schedule, SystemSet};
pub use crate::system::{Res, ResMut};
pub use crate::{prelude::World, system::Resource};

Expand Down Expand Up @@ -724,7 +724,6 @@ mod tests {
use super::*;
// Required to make the derive macro behave
use crate as bevy_ecs;
use crate::event::Events;
use crate::prelude::*;

#[derive(Resource)]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/stepping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ impl ScheduleState {
mod tests {
use super::*;
use crate::prelude::*;
use crate::{schedule::ScheduleLabel, world::World};
use crate::schedule::ScheduleLabel;

pub use crate as bevy_ecs;

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1531,9 +1531,9 @@ mod tests {
use super::*;
use crate::{
self as bevy_ecs, // Necessary for the `SystemParam` Derive when used inside `bevy_ecs`.
system::{assert_is_system, Query},
system::assert_is_system,
};
use std::{cell::RefCell, marker::PhantomData};
use std::cell::RefCell;

// Compile test for https://github.com/bevyengine/bevy/pull/2838.
#[test]
Expand Down
79 changes: 75 additions & 4 deletions crates/bevy_input/src/touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,9 @@ impl Touches {
}
TouchPhase::Moved => {
if let Some(mut new_touch) = self.pressed.get(&event.id).cloned() {
new_touch.previous_position = new_touch.position;
new_touch.previous_force = new_touch.force;
// NOTE: This does not update the previous_force / previous_position field;
// they should be updated once per frame, not once per event
// See https://github.com/bevyengine/bevy/issues/12442
new_touch.position = event.position;
new_touch.force = event.force;
self.pressed.insert(event.id, new_touch);
Expand Down Expand Up @@ -427,8 +428,15 @@ pub fn touch_screen_input_system(
touch_state.just_canceled.clear();
}

for event in touch_input_events.read() {
touch_state.process_touch_event(event);
if !touch_input_events.is_empty() {
for touch in touch_state.pressed.values_mut() {
touch.previous_position = touch.position;
touch.previous_force = touch.force;
}

for event in touch_input_events.read() {
touch_state.process_touch_event(event);
}
}
}

Expand Down Expand Up @@ -551,6 +559,69 @@ mod test {
assert_ne!(touch.previous_position, touch.position);
}

// See https://github.com/bevyengine/bevy/issues/12442
#[test]
fn touch_process_multi_event() {
use crate::{touch::TouchPhase, TouchInput, Touches};
use bevy_ecs::entity::Entity;
use bevy_math::Vec2;

let mut touches = Touches::default();

let started_touch_event = TouchInput {
phase: TouchPhase::Started,
position: Vec2::splat(4.0),
window: Entity::PLACEHOLDER,
force: None,
id: 4,
};

let moved_touch_event1 = TouchInput {
phase: TouchPhase::Moved,
position: Vec2::splat(5.0),
window: Entity::PLACEHOLDER,
force: None,
id: started_touch_event.id,
};

let moved_touch_event2 = TouchInput {
phase: TouchPhase::Moved,
position: Vec2::splat(6.0),
window: Entity::PLACEHOLDER,
force: None,
id: started_touch_event.id,
};

// tick 1: touch is started during frame
for touch in touches.pressed.values_mut() {
// update ONCE, at start of frame
touch.previous_position = touch.position;
}
touches.process_touch_event(&started_touch_event);
touches.process_touch_event(&moved_touch_event1);
touches.process_touch_event(&moved_touch_event2);

{
let touch = touches.get_pressed(started_touch_event.id).unwrap();
assert_eq!(touch.previous_position, started_touch_event.position);
assert_eq!(touch.position, moved_touch_event2.position);
}

// tick 2: touch was started before frame
for touch in touches.pressed.values_mut() {
touch.previous_position = touch.position;
}
touches.process_touch_event(&moved_touch_event1);
touches.process_touch_event(&moved_touch_event2);
touches.process_touch_event(&moved_touch_event1);

{
let touch = touches.get_pressed(started_touch_event.id).unwrap();
assert_eq!(touch.previous_position, moved_touch_event2.position);
assert_eq!(touch.position, moved_touch_event1.position);
}
}

#[test]
fn touch_pressed() {
use crate::{touch::TouchPhase, TouchInput, Touches};
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_math/src/aspect_ratio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use crate::Vec2;

/// An `AspectRatio` is the ratio of width to height.
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
pub struct AspectRatio(f32);

impl AspectRatio {
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_math/src/direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,6 @@ impl approx::UlpsEq for Dir3A {
#[cfg(test)]
mod tests {
use super::*;
use crate::InvalidDirectionError;

#[test]
fn dir2_creation() {
Expand Down
Loading

0 comments on commit dab44e9

Please sign in to comment.