Skip to content

Commit

Permalink
More comment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaynus committed Sep 20, 2019
1 parent 799c0d3 commit b5045c0
Showing 3 changed files with 33 additions and 21 deletions.
4 changes: 2 additions & 2 deletions amethyst_tiles/src/lib.rs
Original file line number Diff line number Diff line change
@@ -11,13 +11,13 @@ mod pass;
pub mod iters;
pub mod pod;

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,
};

pub use morton::{MortonEncoder, MortonEncoder2D};

/// Trait to provide generic access to various encoding schemas. All tile storages use this to encode their coordinates
/// and provide different spatial encoding algorithms for efficiency.
pub trait CoordinateEncoder: 'static + Clone + Default + Send + Sync {
7 changes: 6 additions & 1 deletion amethyst_tiles/src/map.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(unused_variables)]

use crate::CoordinateEncoder;
use amethyst_assets::Handle;
use amethyst_assets::{Asset, Handle};
use amethyst_core::{
ecs::{Component, HashMapStorage, World},
math::{Matrix4, Point3, Vector3},
@@ -112,6 +112,11 @@ pub struct TileMap<T: Tile, E: CoordinateEncoder = crate::MortonEncoder2D> {
#[serde(skip)]
pub(crate) encoder: E,
}
impl<T: Tile, E: CoordinateEncoder> Asset for TileMap<T, E> {
const NAME: &'static str = "tiles::map";
type Data = Self;
type HandleStorage = HashMapStorage<Handle<Self>>;
}
impl<T: Tile, E: CoordinateEncoder> Component for TileMap<T, E> {
type Storage = HashMapStorage<Self>;
}
43 changes: 25 additions & 18 deletions amethyst_tiles/src/pass.rs
Original file line number Diff line number Diff line change
@@ -241,21 +241,29 @@ impl<B: Backend, T: Tile, E: CoordinateEncoder, Z: DrawTiles2DBounds> RenderGrou
let tile = tile_map.get(&coord).unwrap();
if let Some(sprite_number) = tile.sprite(coord, world) {
let (batch_data, texture) = {
let sprite_sheet = sprite_sheet_storage
.get(tile_map.sprite_sheet.as_ref().unwrap())?;
if !tex_storage.contains(&sprite_sheet.texture) {
return None;
if let Some(sprite_sheet_handle) = tile_map.sprite_sheet.as_ref() {
if let Some(sprite_sheet) =
sprite_sheet_storage.get(sprite_sheet_handle)
{
if !tex_storage.contains(&sprite_sheet.texture) {
return None;
}

let color = tile.tint(coord, world);

TileArgs::from_data(
&tex_storage,
&sprite_sheet,
sprite_number,
Some(&TintComponent(tile.tint(coord, world))),
&coord,
)
} else {
None
}
} else {
None
}

let color = tile.tint(coord, world);

TileArgs::from_data(
&tex_storage,
&sprite_sheet,
sprite_number,
Some(&TintComponent(tile.tint(coord, world))),
&coord,
)
}?;

let (tex_id, this_changed) = textures_ref.insert(
@@ -266,10 +274,9 @@ impl<B: Backend, T: Tile, E: CoordinateEncoder, Z: DrawTiles2DBounds> RenderGrou
)?;
changed = changed || this_changed;

Some((tex_id, batch_data))
} else {
None
return Some((tex_id, batch_data));
}
None
})
.for_each_group(|tex_id, batch_data| {
sprites_ref.insert(tex_id, batch_data.drain(..))
@@ -361,7 +368,7 @@ fn build_tiles_pipeline<B: Backend>(
)])
.with_depth_test(pso::DepthTest::On {
fun: pso::Comparison::Less,
write: true,
write: false,
}),
)
.build(factory, None);

0 comments on commit b5045c0

Please sign in to comment.