Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cf3df98
Update to 0.14.0-rc.2
ChristopherBiscardi Jun 7, 2024
2bdc9f1
RenderAssets<Image> is now RenderAssets<GpuImage>
ChristopherBiscardi Jun 7, 2024
a92a680
FloatOrd is now in bevy_math
ChristopherBiscardi Jun 7, 2024
29f5818
convert Transparent2d::dynamic_offset to extra_index
ChristopherBiscardi Jun 7, 2024
d234b18
RenderPhase<Transparent2d> -> ViewSortedRenderPhases<Transparent2d>
ChristopherBiscardi Jun 7, 2024
b6fe345
get_sub_app_mut is now an Option
ChristopherBiscardi Jun 7, 2024
484e7c7
GpuImage::size f32 -> u32 via UVec2
ChristopherBiscardi Jun 7, 2024
684be42
GpuMesh::primitive_topology -> key_bits/BaseMeshPipeline
ChristopherBiscardi Jun 7, 2024
31e330e
RenderChunk2d::prepare requires &mut MeshVertexBufferLayouts now
ChristopherBiscardi Jun 7, 2024
ad615dc
into_linear_f32 -> color.0.linear().to_f32_array(),
ChristopherBiscardi Jun 7, 2024
4b14a61
Must specify type of VisibleEntities when accessing
ChristopherBiscardi Jun 7, 2024
3a11d99
app.world access is functions now
ChristopherBiscardi Jun 7, 2024
b679927
We don't need `World::cell`, and it doesn't exist anymore
ChristopherBiscardi Jun 7, 2024
1386dc2
examples error out unless this bevy bug is addressed with these featu…
ChristopherBiscardi Jun 7, 2024
1b087f4
check_visibility is required for the entity that is renderable
ChristopherBiscardi Jun 7, 2024
692d560
view.view_proj -> view.clip_from_world
ChristopherBiscardi Jun 7, 2024
5a58689
color changes to make tests runnable
ChristopherBiscardi Jun 7, 2024
82d74cf
clippy fix
ChristopherBiscardi Jun 7, 2024
e1a2a55
Update Cargo.toml
ChristopherBiscardi Jun 7, 2024
2ba45da
Update Cargo.toml
ChristopherBiscardi Jun 7, 2024
ff87555
final clippy fixes
ChristopherBiscardi Jun 7, 2024
2d22476
Update Cargo.toml
ChristopherBiscardi Jun 7, 2024
03158fe
Simplify async loading in ldtk/tiled helpers
rparrett Jun 8, 2024
d1d6438
remove second allow lint
ChristopherBiscardi Jun 11, 2024
0600b0b
Merge pull request #1 from rparrett/bevy-0.14-async-assets
ChristopherBiscardi Jun 11, 2024
92fca8f
rc.3 bump
ChristopherBiscardi Jun 18, 2024
9b26ae5
bump version for major release
ChristopherBiscardi Jul 4, 2024
ef20700
remove unused features
ChristopherBiscardi Jul 5, 2024
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
14 changes: 8 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bevy_ecs_tilemap"
description = "A tilemap rendering plugin for bevy which is more ECS friendly by having an entity per tile."
version = "0.12.0"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bevy_ecs_tilemap 13 never released to crates.io, so I moved this to 14 because I think versions track bevy versions?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the pattern in recent releases is a coincidence.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change the version to anything relevant. It seems like the Bevy project is hoping people will release rc candidates, although I don't know if anyone with publish access has the time for that at the moment for this crate.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think StarArawn generally handles release prep himself.

version = "0.14.0"
authors = ["John Mitchell"]
homepage = "https://github.com/StarArawn/bevy_ecs_tilemap"
repository = "https://github.com/StarArawn/bevy_ecs_tilemap"
Expand All @@ -16,7 +16,7 @@ render = []
serde = ["dep:serde"]

[dependencies]
bevy = { version = "0.13", default-features = false, features = [
bevy = { version = "0.14.0", default-features = false, features = [
"bevy_core_pipeline",
"bevy_render",
"bevy_asset",
Expand All @@ -35,7 +35,7 @@ tiled = { version = "0.11.0", default-features = false }
thiserror = { version = "1.0" }

[dev-dependencies.bevy]
version = "0.13"
version = "0.14.0"
default-features = false
features = [
"bevy_core_pipeline",
Expand All @@ -47,11 +47,12 @@ features = [
"bevy_text",
"bevy_sprite",
#"file_watcher",
"multi-threaded",
"multi_threaded",
"webgl2",
]

[target.'cfg(unix)'.dev-dependencies.bevy]
version = "0.13"
version = "0.14.0"
default-features = false
features = [
"bevy_core_pipeline",
Expand All @@ -63,7 +64,8 @@ features = [
"x11",
"bevy_text",
"bevy_sprite",
"multi-threaded",
"multi_threaded",
"webgl2",
]


Expand Down
8 changes: 4 additions & 4 deletions examples/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
TileTextureIndex(5),
TilePos { x: 0, y: 0 },
quadrant_size,
Color::rgba(1.0, 0.0, 0.0, 1.0),
Color::srgba(1.0, 0.0, 0.0, 1.0),
tilemap_id,
&mut commands,
&mut tile_storage,
Expand All @@ -42,7 +42,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
y: 0,
},
quadrant_size,
Color::rgba(0.0, 1.0, 0.0, 1.0),
Color::srgba(0.0, 1.0, 0.0, 1.0),
tilemap_id,
&mut commands,
&mut tile_storage,
Expand All @@ -55,7 +55,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
y: QUADRANT_SIDE_LENGTH,
},
quadrant_size,
Color::rgba(0.0, 0.0, 1.0, 1.0),
Color::srgba(0.0, 0.0, 1.0, 1.0),
tilemap_id,
&mut commands,
&mut tile_storage,
Expand All @@ -68,7 +68,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
y: QUADRANT_SIDE_LENGTH,
},
quadrant_size,
Color::rgba(1.0, 1.0, 0.0, 1.0),
Color::srgba(1.0, 1.0, 0.0, 1.0),
tilemap_id,
&mut commands,
&mut tile_storage,
Expand Down
69 changes: 33 additions & 36 deletions examples/helpers/ldtk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use bevy::{
use bevy::{
asset::{AssetLoader, AssetPath, LoadContext},
prelude::*,
utils::BoxedFuture,
};
use bevy_ecs_tilemap::map::TilemapType;

Expand Down Expand Up @@ -62,45 +61,43 @@ impl AssetLoader for LdtkLoader {
type Settings = ();
type Error = LdtkAssetLoaderError;

fn load<'a>(
async fn load<'a>(
&'a self,
reader: &'a mut Reader,
reader: &'a mut Reader<'_>,
_settings: &'a Self::Settings,
load_context: &'a mut LoadContext,
) -> BoxedFuture<'a, Result<LdtkMap, Self::Error>> {
Box::pin(async move {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;

let project: ldtk_rust::Project = serde_json::from_slice(&bytes).map_err(|e| {
std::io::Error::new(
ErrorKind::Other,
format!("Could not read contents of Ldtk map: {e}"),
)
})?;
let dependencies: Vec<(i64, AssetPath)> = project
.defs
.tilesets
.iter()
.filter_map(|tileset| {
tileset.rel_path.as_ref().map(|rel_path| {
(
tileset.uid,
load_context.path().parent().unwrap().join(rel_path).into(),
)
})
load_context: &'a mut LoadContext<'_>,
) -> Result<Self::Asset, Self::Error> {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;

let project: ldtk_rust::Project = serde_json::from_slice(&bytes).map_err(|e| {
std::io::Error::new(
ErrorKind::Other,
format!("Could not read contents of Ldtk map: {e}"),
)
})?;
let dependencies: Vec<(i64, AssetPath)> = project
.defs
.tilesets
.iter()
.filter_map(|tileset| {
tileset.rel_path.as_ref().map(|rel_path| {
(
tileset.uid,
load_context.path().parent().unwrap().join(rel_path).into(),
)
})
.collect();
})
.collect();

let ldtk_map = LdtkMap {
project,
tilesets: dependencies
.iter()
.map(|dep| (dep.0, load_context.load(dep.1.clone())))
.collect(),
};
Ok(ldtk_map)
})
let ldtk_map = LdtkMap {
project,
tilesets: dependencies
.iter()
.map(|dep| (dep.0, load_context.load(dep.1.clone())))
.collect(),
};
Ok(ldtk_map)
}

fn extensions(&self) -> &[&str] {
Expand Down
149 changes: 73 additions & 76 deletions examples/helpers/tiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use bevy::{
Res, Transform, Update,
},
reflect::TypePath,
utils::{BoxedFuture, HashMap},
utils::HashMap,
};
use bevy_ecs_tilemap::prelude::*;

Expand Down Expand Up @@ -104,90 +104,87 @@ impl AssetLoader for TiledLoader {
type Settings = ();
type Error = TiledAssetLoaderError;

fn load<'a>(
async fn load<'a>(
&'a self,
reader: &'a mut Reader,
reader: &'a mut Reader<'_>,
_settings: &'a Self::Settings,
load_context: &'a mut bevy::asset::LoadContext,
) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> {
Box::pin(async move {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;

let mut loader = tiled::Loader::with_cache_and_reader(
tiled::DefaultResourceCache::new(),
BytesResourceReader::new(&bytes),
);
let map = loader.load_tmx_map(load_context.path()).map_err(|e| {
std::io::Error::new(ErrorKind::Other, format!("Could not load TMX map: {e}"))
})?;

let mut tilemap_textures = HashMap::default();
#[cfg(not(feature = "atlas"))]
let mut tile_image_offsets = HashMap::default();

for (tileset_index, tileset) in map.tilesets().iter().enumerate() {
let tilemap_texture = match &tileset.image {
None => {
#[cfg(feature = "atlas")]
{
log::info!("Skipping image collection tileset '{}' which is incompatible with atlas feature", tileset.name);
continue;
}
load_context: &'a mut bevy::asset::LoadContext<'_>,
) -> Result<Self::Asset, Self::Error> {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;

let mut loader = tiled::Loader::with_cache_and_reader(
tiled::DefaultResourceCache::new(),
BytesResourceReader::new(&bytes),
);
let map = loader.load_tmx_map(load_context.path()).map_err(|e| {
std::io::Error::new(ErrorKind::Other, format!("Could not load TMX map: {e}"))
})?;

let mut tilemap_textures = HashMap::default();
#[cfg(not(feature = "atlas"))]
let mut tile_image_offsets = HashMap::default();

for (tileset_index, tileset) in map.tilesets().iter().enumerate() {
let tilemap_texture = match &tileset.image {
None => {
#[cfg(feature = "atlas")]
{
log::info!("Skipping image collection tileset '{}' which is incompatible with atlas feature", tileset.name);
continue;
}

#[cfg(not(feature = "atlas"))]
{
let mut tile_images: Vec<Handle<Image>> = Vec::new();
for (tile_id, tile) in tileset.tiles() {
if let Some(img) = &tile.image {
// The load context path is the TMX file itself. If the file is at the root of the
// assets/ directory structure then the tmx_dir will be empty, which is fine.
let tmx_dir = load_context
.path()
.parent()
.expect("The asset load context was empty.");
let tile_path = tmx_dir.join(&img.source);
let asset_path = AssetPath::from(tile_path);
log::info!("Loading tile image from {asset_path:?} as image ({tileset_index}, {tile_id})");
let texture: Handle<Image> =
load_context.load(asset_path.clone());
tile_image_offsets
.insert((tileset_index, tile_id), tile_images.len() as u32);
tile_images.push(texture.clone());
}
#[cfg(not(feature = "atlas"))]
{
let mut tile_images: Vec<Handle<Image>> = Vec::new();
for (tile_id, tile) in tileset.tiles() {
if let Some(img) = &tile.image {
// The load context path is the TMX file itself. If the file is at the root of the
// assets/ directory structure then the tmx_dir will be empty, which is fine.
let tmx_dir = load_context
.path()
.parent()
.expect("The asset load context was empty.");
let tile_path = tmx_dir.join(&img.source);
let asset_path = AssetPath::from(tile_path);
log::info!("Loading tile image from {asset_path:?} as image ({tileset_index}, {tile_id})");
let texture: Handle<Image> = load_context.load(asset_path.clone());
tile_image_offsets
.insert((tileset_index, tile_id), tile_images.len() as u32);
tile_images.push(texture.clone());
}

TilemapTexture::Vector(tile_images)
}

TilemapTexture::Vector(tile_images)
}
Some(img) => {
// The load context path is the TMX file itself. If the file is at the root of the
// assets/ directory structure then the tmx_dir will be empty, which is fine.
let tmx_dir = load_context
.path()
.parent()
.expect("The asset load context was empty.");
let tile_path = tmx_dir.join(&img.source);
let asset_path = AssetPath::from(tile_path);
let texture: Handle<Image> = load_context.load(asset_path.clone());

TilemapTexture::Single(texture.clone())
}
};
}
Some(img) => {
// The load context path is the TMX file itself. If the file is at the root of the
// assets/ directory structure then the tmx_dir will be empty, which is fine.
let tmx_dir = load_context
.path()
.parent()
.expect("The asset load context was empty.");
let tile_path = tmx_dir.join(&img.source);
let asset_path = AssetPath::from(tile_path);
let texture: Handle<Image> = load_context.load(asset_path.clone());

TilemapTexture::Single(texture.clone())
}
};

tilemap_textures.insert(tileset_index, tilemap_texture);
}
tilemap_textures.insert(tileset_index, tilemap_texture);
}

let asset_map = TiledMap {
map,
tilemap_textures,
#[cfg(not(feature = "atlas"))]
tile_image_offsets,
};
let asset_map = TiledMap {
map,
tilemap_textures,
#[cfg(not(feature = "atlas"))]
tile_image_offsets,
};

log::info!("Loaded map: {}", load_context.path().display());
Ok(asset_map)
})
log::info!("Loaded map: {}", load_context.path().display());
Ok(asset_map)
}

fn extensions(&self) -> &[&str] {
Expand Down
8 changes: 4 additions & 4 deletions examples/hex_neighbors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::math::Vec4Swizzles;
use bevy::prelude::*;
use bevy::{color::palettes, math::Vec4Swizzles};
use bevy_ecs_tilemap::helpers::hex_grid::neighbors::{HexDirection, HexNeighbors};
use bevy_ecs_tilemap::prelude::*;
mod helpers;
Expand Down Expand Up @@ -315,7 +315,7 @@ fn hover_highlight_tile_label(
if let Ok(label) = tile_label_q.get(tile_entity) {
if let Ok(mut tile_text) = text_q.get_mut(label.0) {
for section in tile_text.sections.iter_mut() {
section.style.color = Color::RED;
section.style.color = palettes::tailwind::RED_600.into();
}
commands.entity(tile_entity).insert(Hovered);
}
Expand Down Expand Up @@ -371,7 +371,7 @@ fn highlight_neighbor_label(
if let Ok(label) = tile_label_q.get(tile_entity) {
if let Ok(mut tile_text) = text_q.get_mut(label.0) {
for section in tile_text.sections.iter_mut() {
section.style.color = Color::BLUE;
section.style.color = palettes::tailwind::BLUE_600.into();
}
commands.entity(tile_entity).insert(NeighborHighlight);
}
Expand Down Expand Up @@ -412,7 +412,7 @@ fn highlight_neighbor_label(
if let Ok(label) = tile_label_q.get(tile_entity) {
if let Ok(mut tile_text) = text_q.get_mut(label.0) {
for section in tile_text.sections.iter_mut() {
section.style.color = Color::GREEN;
section.style.color = palettes::tailwind::GREEN_600.into();
}
commands.entity(tile_entity).insert(NeighborHighlight);
}
Expand Down
Loading