Skip to content

Commit

Permalink
Merge branch 'main' into faster-build
Browse files Browse the repository at this point in the history
  • Loading branch information
ezpuzz authored Jan 19, 2021
2 parents 8237a6c + fe775ae commit 60fd220
Show file tree
Hide file tree
Showing 30 changed files with 393 additions and 334 deletions.
1 change: 0 additions & 1 deletion amethyst_assets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ futures-executor = { version = "0.3", default-features = false }
legion-prefab = { version = "0.1", git = "https://github.com/amethyst/prefab", rev = "7c30249f106e6177549e223ca2823eec8ab6c70b" }
prefab-format = { version = "0.1", git = "https://github.com/amethyst/prefab", rev = "7c30249f106e6177549e223ca2823eec8ab6c70b" }
encoding_rs_io = "0.1"
dashmap = "4.0"

[dev-dependencies]
serde_json = "1"
Expand Down
1 change: 0 additions & 1 deletion amethyst_assets/src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ pub trait Format<D: 'static>: DynClone + Send + Sync + 'static {
///
/// If you are implementing `format` yourself, this method will never be used
/// and can be left unimplemented.
///
fn import_simple(&self, _bytes: Vec<u8>) -> Result<D, Error> {
unimplemented!("You must implement either `import_simple` or `import`.")
}
Expand Down
1 change: 0 additions & 1 deletion amethyst_audio/src/source.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Provides structures used to load audio files.
//!
use amethyst_assets::{Asset, AssetStorage, Handle, LoadHandle, ProcessableAsset, ProcessingState};
use amethyst_error::Error;
use type_uuid::TypeUuid;
Expand Down
3 changes: 2 additions & 1 deletion amethyst_core/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ impl Default for LoggerConfig {
/// target = record.target(),
/// message = message,
/// ))
/// }).start();
/// })
/// .start();
/// ```
#[allow(missing_debug_implementations)]
pub struct Logger {
Expand Down
2 changes: 1 addition & 1 deletion amethyst_core/src/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use serde::{Deserialize, Serialize};
/// world.push((Named { name: format!("Entity Number {}", entity_num).into() },));
/// }
/// ```
///
///
/// Accessing a named entity in a system:
/// ```
/// use amethyst::core::Named;
Expand Down
32 changes: 17 additions & 15 deletions amethyst_core/src/system_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,33 @@ use legion::{
///
/// # Examples
/// ```rust
/// use legion::{system, Schedule, World, Resources, SystemBuilder};
/// use amethyst_core::system_ext::pausable;
/// use amethyst_core::ecs::{System, ParallelRunnable};
/// use amethyst_core::dispatcher::DispatcherBuilder;
/// use amethyst_core::{
/// dispatcher::DispatcherBuilder,
/// ecs::{ParallelRunnable, System},
/// system_ext::pausable,
/// };
/// use legion::{system, Resources, Schedule, SystemBuilder, World};
///
/// #[derive(PartialEq)]
/// enum CurrentState {
/// Disabled,
/// Enabled,
/// }
///
///
/// struct TestSystem;
///
/// impl System<'_> for TestSystem{
/// impl System<'_> for TestSystem {
/// fn build(&mut self) -> Box<dyn ParallelRunnable> {
/// Box::new(
/// pausable(SystemBuilder::new("TestSystem")
/// .write_resource::<u32>()
/// .build(move |_commands, _world, resources, _| {
/// **resources += 1;
/// }),
/// CurrentState::Enabled
/// ))
/// }}
/// Box::new(pausable(
/// SystemBuilder::new("TestSystem")
/// .write_resource::<u32>()
/// .build(move |_commands, _world, resources, _| {
/// **resources += 1;
/// }),
/// CurrentState::Enabled,
/// ))
/// }
/// }
///
/// let mut dispatcher = DispatcherBuilder::default()
/// .add_system(Box::new(TestSystem))
Expand Down
9 changes: 3 additions & 6 deletions amethyst_core/src/transform/components/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,13 @@ impl Transform {
/// // No rotation by default
/// assert_eq!(*t.rotation().quaternion(), Quaternion::identity());
/// // look up with up pointing backwards
/// t.face_towards(
/// Vector3::new(0.0, 1.0, 0.0),
/// Vector3::new(0.0, 0.0, 1.0),
/// );
/// t.face_towards(Vector3::new(0.0, 1.0, 0.0), Vector3::new(0.0, 0.0, 1.0));
/// // our rotation should match the angle from straight ahead to straight up
/// let rotation = UnitQuaternion::rotation_between(
/// &Vector3::new(0.0, 1.0, 0.0),
/// &Vector3::new(0.0, 0.0, 1.0),
/// ).unwrap();
/// )
/// .unwrap();
/// assert_eq!(*t.rotation(), rotation);
/// // now if we move forwards by 1.0, we'll end up at the point we are facing
/// // (modulo some floating point error)
Expand Down Expand Up @@ -617,7 +615,6 @@ impl From<Vector3<f32>> for Transform {
/// # use amethyst_core::math::Vector3;
/// let transform = Transform::from(Vector3::new(100.0, 200.0, 300.0));
/// assert_eq!(transform.translation().x, 100.0);
///
impl From<Vector3<f64>> for Transform {
#[inline]
fn from(translation: Vector3<f64>) -> Self {
Expand Down
6 changes: 4 additions & 2 deletions amethyst_error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ impl Error {
/// [`with_context`](trait.ResultExt.html#method.with_context).
///
/// ```rust
/// use amethyst_error::{Error, ResultExt};
/// use std::io;
///
/// use amethyst_error::{Error, ResultExt};
///
/// let e = io::Error::new(io::ErrorKind::Other, "wrapped");
/// let a = Error::new(e);
///
Expand Down Expand Up @@ -281,7 +282,8 @@ impl<'a> Iterator for Causes<'a> {
/// Constructs an `Error` using the standard string interpolation syntax.
///
/// ```rust
/// #[macro_use] extern crate amethyst_error;
/// #[macro_use]
/// extern crate amethyst_error;
///
/// fn main() {
/// let err = format_err!("number: {}", 42);
Expand Down
1 change: 0 additions & 1 deletion amethyst_input/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use crate::{BindingError, Bindings, InputHandler, InputSystem};
/// ## Errors
///
/// No errors returned from this bundle.
///
#[derive(Debug, Default)]
pub struct InputBundle {
bindings: Option<Bindings>,
Expand Down
2 changes: 1 addition & 1 deletion amethyst_rendy/src/formats/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::types::TextureData;
///
/// # Example Usage
/// ```ignore
///
///
/// let loader = res.fetch_mut::<DefaultLoader>();
/// let texture_storage = res.fetch_mut::<AssetStorage<Texture>>();
///
Expand Down
18 changes: 12 additions & 6 deletions amethyst_rendy/src/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,26 @@ mod window {
/// This function takes linear RGBA. You can convert rgba to linear rgba like so:
///
/// ```
/// use amethyst_rendy::palette::Srgba;
/// use amethyst_rendy::{RenderToWindow, rendy::hal::command::ClearColor};
/// use amethyst_rendy::{palette::Srgba, rendy::hal::command::ClearColor, RenderToWindow};
/// use amethyst_window::DisplayConfig;
///
/// let your_red: f32 = 255.;
/// let your_green: f32 = 160.;
/// let your_blue: f32 = 122.;
/// let your_alpha: f32 = 1.0;
///
/// let (r, g, b, a) = Srgba::new(your_red / 255., your_green / 255., your_blue / 255., your_alpha)
/// .into_linear()
/// .into_components();
/// let (r, g, b, a) = Srgba::new(
/// your_red / 255.,
/// your_green / 255.,
/// your_blue / 255.,
/// your_alpha,
/// )
/// .into_linear()
/// .into_components();
///
/// RenderToWindow::from_config(DisplayConfig::default()).with_clear(ClearColor { float32: [r, g, b, a] });
/// RenderToWindow::from_config(DisplayConfig::default()).with_clear(ClearColor {
/// float32: [r, g, b, a],
/// });
/// ```
pub fn with_clear(mut self, clear: impl Into<ClearColor>) -> Self {
self.clear = Some(clear.into());
Expand Down
1 change: 0 additions & 1 deletion amethyst_rendy/src/resources.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! `amethyst` rendering ecs resources
//!
/// The ambient color of a scene
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
Expand Down
10 changes: 2 additions & 8 deletions amethyst_rendy/src/serde_shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
/// ```
/// # use serde::{Serialize, Deserialize};
/// #[derive(Serialize, Deserialize)]
/// struct MyType(
/// #[serde(with="amethyst_rendy::serde_shim::srgb")]
/// pub palette::Srgb
/// );
/// struct MyType(#[serde(with = "amethyst_rendy::serde_shim::srgb")] pub palette::Srgb);
/// ```
pub mod srgb {
use super::*;
Expand All @@ -36,10 +33,7 @@ pub mod srgb {
/// ```
/// # use serde::{Serialize, Deserialize};
/// #[derive(Serialize, Deserialize)]
/// struct MyType(
/// #[serde(with="amethyst_rendy::serde_shim::srgba")]
/// pub palette::Srgba
/// );
/// struct MyType(#[serde(with = "amethyst_rendy::serde_shim::srgba")] pub palette::Srgba);
/// ```
pub mod srgba {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion amethyst_rendy/src/sprite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ use amethyst_assets::{
/// ),
/// ],
/// ))
///}
/// }
/// ```
///
/// Such a spritesheet description can be loaded using a `Loader` by passing it the handle of the corresponding loaded texture.
Expand Down
84 changes: 57 additions & 27 deletions amethyst_tiles/src/iters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ impl<'a> From<&'a Region> for MortonRegion {
}

/// Axis aligned quantized region of space represented in tile coordinates of `u32`. This behaves
/// like a bounding box volume with `min` and `max` coordinates for iteration. This regions limits are *inclusive*,
/// in that it considers both min and max values as being inside the region.
/// like a bounding box volume with `min` and `max` coordinates for iteration. The lower (min) coordinates
/// are inclusive and the upper (max) coordinates are exclusive.
#[derive(Copy, Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Region {
/// The "lower-right" coordinate of this `Region`.
Expand Down Expand Up @@ -107,26 +107,26 @@ impl Region {
#[must_use]
pub fn contains(&self, target: &Point3<u32>) -> bool {
target.x >= self.min.x
&& target.x <= self.max.x
&& target.x < self.max.x
&& target.y >= self.min.y
&& target.y <= self.max.y
&& target.y < self.max.y
&& target.z >= self.min.z
&& target.z <= self.max.z
&& target.z < self.max.z
}

/// Check if this `Region` intersects with the provided `Region`
#[inline]
#[must_use]
pub fn intersects(&self, other: &Self) -> bool {
(self.min.x <= other.max.x && self.max.x >= other.min.x)
&& (self.min.y <= other.max.y && self.max.y >= other.min.y)
&& (self.min.z <= other.max.z && self.max.z >= other.min.z)
(self.min.x < other.max.x && self.max.x > other.min.x)
&& (self.min.y < other.max.y && self.max.y > other.min.y)
&& (self.min.z < other.max.z && self.max.z > other.min.z)
}

/// Calculate the volume of this bounding box volume.
#[must_use]
pub fn volume(&self) -> u32 {
(self.max.x - self.min.x) * (self.max.y - self.min.y) * ((self.max.z - self.min.z) + 1)
(self.max.x - self.min.x) * (self.max.y - self.min.y) * (self.max.z - self.min.z)
}

/// Create a linear iterator across this region.
Expand Down Expand Up @@ -181,22 +181,18 @@ impl Iterator for RegionLinearIter {
fn next(&mut self) -> Option<Self::Item> {
let ret = self.track;

if self.track.z > self.region.max.z {
if self.track.z >= self.region.max.z {
return None;
}

self.track.x += 1;
if self.track.x >= self.region.max.x {
self.track.y += 1;
self.track.x = self.region.min.x;
} else {
self.track.x += 1;
return Some(ret);
}

if self.track.y > self.region.max.y {
self.track.z += 1;

self.track.y = self.region.min.y;
self.track.y += 1;
if self.track.y >= self.region.max.y {
self.track.y = self.region.min.y;
self.track.z += 1;
}
}

Some(ret)
Expand Down Expand Up @@ -236,16 +232,50 @@ mod tests {

// min/max corners
assert!(region.contains(&Point3::new(0, 0, 0)));
assert!(region.contains(&Point3::new(64, 64, 64)));
assert!(region.contains(&Point3::new(63, 63, 63)));
assert!(!region.contains(&Point3::new(64, 64, 64)));

// edges
assert!(region.contains(&Point3::new(64, 0, 0)));
assert!(region.contains(&Point3::new(0, 64, 0)));
assert!(region.contains(&Point3::new(0, 0, 64)));
assert!(region.contains(&Point3::new(63, 0, 0)));
assert!(region.contains(&Point3::new(0, 63, 0)));
assert!(region.contains(&Point3::new(0, 0, 63)));

assert!(region.contains(&Point3::new(64, 64, 0)));
assert!(region.contains(&Point3::new(0, 64, 64)));
assert!(region.contains(&Point3::new(64, 0, 64)));
assert!(region.contains(&Point3::new(63, 63, 0)));
assert!(region.contains(&Point3::new(0, 63, 63)));
assert!(region.contains(&Point3::new(63, 0, 63)));
}

#[test]
fn region_iterator() {
let region = Region::new(Point3::new(10, 20, 30), Point3::new(12, 22, 32));
let expected_points = [
Point3::new(10, 20, 30),
Point3::new(11, 20, 30),
Point3::new(10, 21, 30),
Point3::new(11, 21, 30),
Point3::new(10, 20, 31),
Point3::new(11, 20, 31),
Point3::new(10, 21, 31),
Point3::new(11, 21, 31),
];
let mut count = 0;
for (i, point) in region.into_iter().enumerate() {
count += 1;
assert_eq!(point, expected_points[i]);
}
assert_eq!(count, 8);
}

#[test]
fn region_volume() {
let region = Region::new(Point3::new(0, 0, 0), Point3::new(0, 0, 0));
assert_eq!(region.volume(), 0);
let region = Region::new(Point3::new(10, 20, 30), Point3::new(10, 20, 30));
assert_eq!(region.volume(), 0);
let region = Region::new(Point3::new(10, 10, 10), Point3::new(10, 15, 15));
assert_eq!(region.volume(), 0);
let region = Region::new(Point3::new(10, 10, 10), Point3::new(20, 20, 20));
assert_eq!(region.volume(), 1000);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions amethyst_tiles/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! 2D/3D Tile data structures and functionality.
//!
#![doc(
html_logo_url = "https://amethyst.rs/brand/logo-standard.svg",
Expand All @@ -22,7 +21,8 @@ pub use iters::{MortonRegion, Region};
pub use map::{Map, MapStorage, Tile, TileMap};
pub use morton::{MortonEncoder, MortonEncoder2D};
pub use pass::{
DrawTiles2D, DrawTiles2DBounds, DrawTiles2DBoundsDefault, DrawTiles2DDesc, RenderTiles2D,
DrawTiles2D, DrawTiles2DBounds, DrawTiles2DBoundsCameraCulling, DrawTiles2DBoundsDefault,
DrawTiles2DDesc, RenderTiles2D,
};

/// Trait to provide generic access to various encoding schemas. All tile storages use this to encode their coordinates
Expand Down
Loading

0 comments on commit 60fd220

Please sign in to comment.