From cf3df98e2efa94a8bc2f43fe3c501def291a6e21 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Thu, 6 Jun 2024 21:59:31 -0700 Subject: [PATCH 01/27] Update to 0.14.0-rc.2 * [12997](https://github.com/bevyengine/bevy/pull/12997): rename `multi-threaded` to `multi_threaded` --- Cargo.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0377fa68..9afb99b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" +version = "0.14.0" authors = ["John Mitchell"] homepage = "https://github.com/StarArawn/bevy_ecs_tilemap" repository = "https://github.com/StarArawn/bevy_ecs_tilemap" @@ -16,7 +16,7 @@ render = [] serde = ["dep:serde"] [dependencies] -bevy = { version = "0.13", default-features = false, features = [ +bevy = { version = "0.14.0-rc.2", default-features = false, features = [ "bevy_core_pipeline", "bevy_render", "bevy_asset", @@ -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-rc.2" default-features = false features = [ "bevy_core_pipeline", @@ -47,11 +47,11 @@ features = [ "bevy_text", "bevy_sprite", #"file_watcher", - "multi-threaded", + "multi_threaded", ] [target.'cfg(unix)'.dev-dependencies.bevy] -version = "0.13" +version = "0.14.0-rc.2" default-features = false features = [ "bevy_core_pipeline", @@ -63,7 +63,7 @@ features = [ "x11", "bevy_text", "bevy_sprite", - "multi-threaded", + "multi_threaded", ] From 2bdc9f13f61df85179ee664248e327b8153295a3 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Thu, 6 Jun 2024 22:06:38 -0700 Subject: [PATCH 02/27] RenderAssets is now RenderAssets Implemented in [12827](https://github.com/bevyengine/bevy/pull/12827) --- src/render/material.rs | 10 +++++----- src/render/mod.rs | 4 +++- src/render/texture_array_cache.rs | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/render/material.rs b/src/render/material.rs index ada567c9..002294e7 100644 --- a/src/render/material.rs +++ b/src/render/material.rs @@ -13,7 +13,7 @@ use bevy::{ ShaderRef, SpecializedRenderPipeline, SpecializedRenderPipelines, }, renderer::RenderDevice, - texture::FallbackImage, + texture::{FallbackImage, GpuImage}, view::{ExtractedView, ViewUniforms, VisibleEntities}, Extract, Render, RenderApp, RenderSet, }, @@ -303,7 +303,7 @@ fn prepare_materials_tilemap( mut extracted_assets: ResMut>, mut render_materials: ResMut>, render_device: Res, - images: Res>, + images: Res>, fallback_image: Res, pipeline: Res>, ) { @@ -350,7 +350,7 @@ fn prepare_materials_tilemap( fn prepare_material_tilemap( material: &M, render_device: &RenderDevice, - images: &RenderAssets, + images: &RenderAssets, fallback_image: &FallbackImage, pipeline: &MaterialTilemapPipeline, ) -> Result, AsBindGroupError> { @@ -378,7 +378,7 @@ pub fn queue_material_tilemap_meshes( ), pipeline_cache: Res, view_uniforms: Res, - gpu_images: Res>, + gpu_images: Res>, msaa: Res, globals_buffer: Res, (standard_tilemap_meshes, materials): ( @@ -489,7 +489,7 @@ pub fn bind_material_tilemap_meshes( render_device: Res, tilemap_pipeline: Res, view_uniforms: Res, - gpu_images: Res>, + gpu_images: Res>, globals_buffer: Res, mut image_bind_groups: ResMut, (standard_tilemap_meshes, materials): (Query<(&ChunkId, &TilemapId)>, Query<&Handle>), diff --git a/src/render/mod.rs b/src/render/mod.rs index 4b41c3a0..cabf1313 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -15,6 +15,8 @@ use bevy::{ #[cfg(not(feature = "atlas"))] use bevy::render::renderer::RenderDevice; +#[cfg(not(feature = "atlas"))] +use bevy::render::texture::GpuImage; use crate::tiles::{TilePos, TileStorage}; use crate::{ @@ -319,7 +321,7 @@ fn prepare_textures( render_device: Res, mut texture_array_cache: ResMut, extracted_tilemap_textures: Query<&ExtractedTilemapTexture>, - render_images: Res>, + render_images: Res>, ) { for extracted_texture in extracted_tilemap_textures.iter() { texture_array_cache.add_extracted_texture(extracted_texture); diff --git a/src/render/texture_array_cache.rs b/src/render/texture_array_cache.rs index 270a7385..08f33e6a 100644 --- a/src/render/texture_array_cache.rs +++ b/src/render/texture_array_cache.rs @@ -137,7 +137,7 @@ impl TextureArrayCache { pub fn prepare( &mut self, render_device: &RenderDevice, - render_images: &Res>, + render_images: &Res>, ) { let prepare_queue = self.prepare_queue.drain().collect::>(); for texture in prepare_queue.iter() { @@ -228,7 +228,7 @@ impl TextureArrayCache { &mut self, render_device: &RenderDevice, render_queue: &RenderQueue, - render_images: &Res>, + render_images: &Res>, ) { let queue_queue = self.queue_queue.drain().collect::>(); From a92a680ed5fbbdbc2245c2b969b71a26dc577f8e Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Thu, 6 Jun 2024 22:08:30 -0700 Subject: [PATCH 03/27] FloatOrd is now in bevy_math implemented in [12732](https://github.com/bevyengine/bevy/pull/12732) --- src/render/material.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/render/material.rs b/src/render/material.rs index 002294e7..a44c968e 100644 --- a/src/render/material.rs +++ b/src/render/material.rs @@ -1,5 +1,6 @@ use bevy::{ core_pipeline::core_2d::Transparent2d, + math::FloatOrd, prelude::*, reflect::TypePath, render::{ @@ -17,7 +18,7 @@ use bevy::{ view::{ExtractedView, ViewUniforms, VisibleEntities}, Extract, Render, RenderApp, RenderSet, }, - utils::{FloatOrd, HashMap, HashSet}, + utils::{HashMap, HashSet}, }; use std::{hash::Hash, marker::PhantomData}; From 29f5818e86ddd4b52744426ab5f5154a8951d7d5 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Thu, 6 Jun 2024 23:32:11 -0700 Subject: [PATCH 04/27] convert Transparent2d::dynamic_offset to extra_index [12889](https://github.com/bevyengine/bevy/pull/12889) Gpu Frustum Culling removed the dynamic_offset of Transparent2d and it became `extra_index` with the special value `PhaseItemExtraIndex::NONE`, which indicates the `None` that was here previously --- src/render/material.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/material.rs b/src/render/material.rs index a44c968e..da9f4156 100644 --- a/src/render/material.rs +++ b/src/render/material.rs @@ -7,7 +7,7 @@ use bevy::{ extract_component::ExtractComponentPlugin, globals::GlobalsBuffer, render_asset::RenderAssets, - render_phase::{AddRenderCommand, DrawFunctions, RenderPhase}, + render_phase::{AddRenderCommand, DrawFunctions, PhaseItemExtraIndex, RenderPhase}, render_resource::{ AsBindGroup, AsBindGroupError, BindGroup, BindGroupEntry, BindGroupLayout, BindingResource, OwnedBindingResource, PipelineCache, RenderPipelineDescriptor, @@ -476,7 +476,7 @@ pub fn queue_material_tilemap_meshes( pipeline: pipeline_id, sort_key: FloatOrd(z), batch_range: 0..1, - dynamic_offset: None, + extra_index: PhaseItemExtraIndex::NONE, }); } } From d234b18200107a2af10492ec926fe6de7e5eb3a1 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 00:10:18 -0700 Subject: [PATCH 05/27] RenderPhase -> ViewSortedRenderPhases [12453](https://github.com/StarArawn/bevy_ecs_tilemap/pull/bevyengine/bevy#12453): Render phases are now binned or sorted. Following the changes in the `mesh2d_manual` [example](https://github.com/bevyengine/bevy/blob/ecdd1624f302c5f71aaed95b0984cbbecf8880b7/examples/2d/mesh2d_manual.rs#L357-L358): use the `ViewSortedRenderPhases` resource. --- src/render/material.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/render/material.rs b/src/render/material.rs index da9f4156..249f0ba8 100644 --- a/src/render/material.rs +++ b/src/render/material.rs @@ -7,7 +7,9 @@ use bevy::{ extract_component::ExtractComponentPlugin, globals::GlobalsBuffer, render_asset::RenderAssets, - render_phase::{AddRenderCommand, DrawFunctions, PhaseItemExtraIndex, RenderPhase}, + render_phase::{ + AddRenderCommand, DrawFunctions, PhaseItemExtraIndex, ViewSortedRenderPhases, + }, render_resource::{ AsBindGroup, AsBindGroupError, BindGroup, BindGroupEntry, BindGroupLayout, BindingResource, OwnedBindingResource, PipelineCache, RenderPipelineDescriptor, @@ -386,16 +388,13 @@ pub fn queue_material_tilemap_meshes( Query<(Entity, &ChunkId, &Transform, &TilemapId)>, Query<&Handle>, ), - mut views: Query<( - &ExtractedView, - &VisibleEntities, - &mut RenderPhase, - )>, + mut views: Query<(Entity, &ExtractedView, &VisibleEntities)>, render_materials: Res>, #[cfg(not(feature = "atlas"))] (mut texture_array_cache, render_queue): ( ResMut, Res, ), + mut transparent_render_phases: ResMut>, ) where M::Data: PartialEq + Eq + Hash + Clone, { @@ -410,7 +409,11 @@ pub fn queue_material_tilemap_meshes( return; } - for (view, visible_entities, mut transparent_phase) in views.iter_mut() { + for (view_entity, view, visible_entities) in views.iter_mut() { + let Some(transparent_phase) = transparent_render_phases.get_mut(&view_entity) else { + continue; + }; + let draw_tilemap = transparent_2d_draw_functions .read() .get_id::>() From b6fe345ee7380b916fad577132e60ea622aeb58d Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 00:16:07 -0700 Subject: [PATCH 06/27] get_sub_app_mut is now an Option in [9202](https://github.com/StarArawn/bevy_ecs_tilemap/pull/bevyengine/bevy/pull/9202) SubApp access has changed --- src/render/material.rs | 2 +- src/render/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/render/material.rs b/src/render/material.rs index 249f0ba8..26b96bdb 100644 --- a/src/render/material.rs +++ b/src/render/material.rs @@ -116,7 +116,7 @@ where } fn finish(&self, app: &mut App) { - if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { + if let Some(render_app) = app.get_sub_app_mut(RenderApp) { render_app .add_render_command::>() .init_resource::>() diff --git a/src/render/mod.rs b/src/render/mod.rs index cabf1313..1ace3003 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -212,8 +212,8 @@ impl Plugin for TilemapRenderingPlugin { ); let render_app = match app.get_sub_app_mut(RenderApp) { - Ok(render_app) => render_app, - Err(_) => return, + Some(render_app) => render_app, + None => return, }; render_app.init_resource::(); From 484e7c7b0fe05c4073e41c52407189ab04fad2e4 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 00:22:57 -0700 Subject: [PATCH 07/27] GpuImage::size f32 -> u32 via UVec2 [11698](https://github.com/bevyengine/bevy/pull/11698) changed `GpuImage::size` to `UVec2`. Right above this, `Extent3d` does the same thing, so I'm taking a small leap and assuming can `as`. --- src/render/texture_array_cache.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/render/texture_array_cache.rs b/src/render/texture_array_cache.rs index 08f33e6a..aaabd1d4 100644 --- a/src/render/texture_array_cache.rs +++ b/src/render/texture_array_cache.rs @@ -3,7 +3,7 @@ use crate::{TilemapSpacing, TilemapTexture, TilemapTextureSize, TilemapTileSize} use bevy::asset::Assets; use bevy::prelude::Resource; use bevy::{ - prelude::{Image, Res}, + prelude::{Image, Res, UVec2}, render::{ render_asset::RenderAssets, render_resource::{ @@ -205,7 +205,10 @@ impl TextureArrayCache { texture: gpu_texture, sampler, texture_view, - size: tile_size.into(), + size: UVec2 { + x: tile_size.x as u32, + y: tile_size.y as u32, + }, mip_level_count, }; From 684be42ddd9843d96990892619a12f1c097e06b7 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 00:32:33 -0700 Subject: [PATCH 08/27] GpuMesh::primitive_topology -> key_bits/BaseMeshPipeline [12791](https://github.com/bevyengine/bevy/pull/12791) the `primitive_topology` field on `GpuMesh` was removed in favor of `key_bits` which can be constructed using `BaseMeshPipeline::from_primitive_topology` --- src/render/chunk.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/render/chunk.rs b/src/render/chunk.rs index e8f86d1f..2ec9119c 100644 --- a/src/render/chunk.rs +++ b/src/render/chunk.rs @@ -1,9 +1,9 @@ use std::hash::{Hash, Hasher}; -use bevy::math::Mat4; use bevy::prelude::{InheritedVisibility, Resource, Transform}; -use bevy::render::primitives::Aabb; use bevy::render::render_asset::RenderAssetUsages; +use bevy::render::{mesh::BaseMeshPipelineKey, primitives::Aabb}; +use bevy::{math::Mat4, render::mesh::PrimitiveTopology}; use bevy::{ math::{UVec2, UVec3, UVec4, Vec2, Vec3Swizzles, Vec4, Vec4Swizzles}, prelude::{Component, Entity, GlobalTransform, Mesh, Vec3}, @@ -451,7 +451,9 @@ impl RenderChunk2d { buffer_info, morph_targets: None, layout: mesh_vertex_buffer_layout, - primitive_topology: bevy::render::render_resource::PrimitiveTopology::TriangleList, + key_bits: BaseMeshPipelineKey::from_primitive_topology( + PrimitiveTopology::TriangleList, + ), }); self.dirty_mesh = false; } From 31e330e9601ae65b771141a4857016232bdee63a Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 00:41:38 -0700 Subject: [PATCH 09/27] RenderChunk2d::prepare requires &mut MeshVertexBufferLayouts now [12216](https://github.com/bevyengine/bevy/pull/12216) introduced an argument `&mut MeshVertexBufferLayouts` to `get_mesh_vertex_buffer_layout`, which bevy_ecs_tilemap calls in `RenderChunk2d::prepare` --- src/render/chunk.rs | 15 ++++++++++++--- src/render/prepare.rs | 5 +++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/render/chunk.rs b/src/render/chunk.rs index 2ec9119c..2013d64c 100644 --- a/src/render/chunk.rs +++ b/src/render/chunk.rs @@ -1,6 +1,5 @@ use std::hash::{Hash, Hasher}; -use bevy::prelude::{InheritedVisibility, Resource, Transform}; use bevy::render::render_asset::RenderAssetUsages; use bevy::render::{mesh::BaseMeshPipelineKey, primitives::Aabb}; use bevy::{math::Mat4, render::mesh::PrimitiveTopology}; @@ -14,6 +13,10 @@ use bevy::{ }, utils::HashMap, }; +use bevy::{ + prelude::{InheritedVisibility, Resource, Transform}, + render::mesh::MeshVertexBufferLayouts, +}; use crate::prelude::helpers::transform::{chunk_aabb, chunk_index_to_world_space}; use crate::render::extract::ExtractedFrustum; @@ -355,7 +358,11 @@ impl RenderChunk2d { } } - pub fn prepare(&mut self, device: &RenderDevice) { + pub fn prepare( + &mut self, + device: &RenderDevice, + mut mesh_vertex_buffer_layouts: &mut MeshVertexBufferLayouts, + ) { if self.dirty_mesh { let size = ((self.size_in_tiles.x * self.size_in_tiles.y) * 4) as usize; let mut positions: Vec<[f32; 4]> = Vec::with_capacity(size); @@ -444,7 +451,9 @@ impl RenderChunk2d { } }); - let mesh_vertex_buffer_layout = self.mesh.get_mesh_vertex_buffer_layout(); + let mesh_vertex_buffer_layout = self + .mesh + .get_mesh_vertex_buffer_layout(&mut mesh_vertex_buffer_layouts); self.gpu_mesh = Some(GpuMesh { vertex_buffer, vertex_count: self.mesh.count_vertices() as u32, diff --git a/src/render/prepare.rs b/src/render/prepare.rs index 24b307e8..afdb602f 100644 --- a/src/render/prepare.rs +++ b/src/render/prepare.rs @@ -9,8 +9,8 @@ use crate::render::extract::ExtractedFrustum; use crate::{ prelude::TilemapGridSize, render::RenderChunkSize, render::SecondsSinceStartup, FrustumCulling, }; -use bevy::log::trace; use bevy::prelude::{InheritedVisibility, Resource}; +use bevy::{log::trace, render::mesh::MeshVertexBufferLayouts}; use bevy::{ math::{Mat4, UVec4}, prelude::{Commands, Component, Entity, GlobalTransform, Query, Res, ResMut, Vec2}, @@ -63,6 +63,7 @@ pub(crate) fn prepare( render_device: Res, render_queue: Res, seconds_since_startup: Res, + mut mesh_vertex_buffer_layouts: ResMut, ) { for tile in extracted_tiles.iter() { // First if the tile position has changed remove the tile from the old location. @@ -188,7 +189,7 @@ pub(crate) fn prepare( } trace!("Preparing chunk: {:?}", chunk.get_index()); - chunk.prepare(&render_device); + chunk.prepare(&render_device, &mut mesh_vertex_buffer_layouts); let mut chunk_uniform: TilemapUniformData = chunk.into(); chunk_uniform.time = **seconds_since_startup; From ad615dcec4a8b6e0fa29e85306af2e8e3ddc9935 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 00:46:45 -0700 Subject: [PATCH 10/27] into_linear_f32 -> color.0.linear().to_f32_array(), [12163](https://github.com/bevyengine/bevy/pull/12163) bevy_color was created and Color handling has changed. Specifically Color::as_linear_rgba_f32 has been removed. LinearRgba is now its own type that can be accessed via [`linear()`](https://docs.rs/bevy/0.14.0-rc.2/bevy/color/enum.Color.html#method.linear) and then converted. --- src/render/extract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/extract.rs b/src/render/extract.rs index 24166d47..f87d1828 100644 --- a/src/render/extract.rs +++ b/src/render/extract.rs @@ -282,7 +282,7 @@ pub fn extract( visible: visible.0, position, texture, - color: color.0.as_linear_rgba_f32(), + color: color.0.linear().to_f32_array(), }; let data = tilemap_query.get(tilemap_id.0).unwrap(); From 4b14a61c1ef4e45dfb21aa4694881ac8e9f66748 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 01:02:23 -0700 Subject: [PATCH 11/27] Must specify type of VisibleEntities when accessing [12582](https://github.com/bevyengine/bevy/pull/12582) divided `VisibleEntities` into separate lists. So now we have to specify which kind of entity we want. I think we want the Mesh here, and I think we can get rid of the `.index` calls on Entity since Entity [already compares bits](https://docs.rs/bevy_ecs/0.14.0-rc.2/src/bevy_ecs/entity/mod.rs.html#173) for optimized codegen purposes. Waiting to do that until the other changes are in though so as to not change functionality until post-upgrade. --- src/render/material.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/render/material.rs b/src/render/material.rs index 26b96bdb..d44d801b 100644 --- a/src/render/material.rs +++ b/src/render/material.rs @@ -17,7 +17,7 @@ use bevy::{ }, renderer::RenderDevice, texture::{FallbackImage, GpuImage}, - view::{ExtractedView, ViewUniforms, VisibleEntities}, + view::{ExtractedView, ViewUniforms, VisibleEntities, WithMesh}, Extract, Render, RenderApp, RenderSet, }, utils::{HashMap, HashSet}, @@ -421,8 +421,7 @@ pub fn queue_material_tilemap_meshes( for (entity, chunk_id, transform, tilemap_id) in standard_tilemap_meshes.iter() { if !visible_entities - .entities - .iter() + .iter::() .any(|&entity| entity.index() == tilemap_id.0.index()) { continue; @@ -539,8 +538,7 @@ pub fn bind_material_tilemap_meshes( for (chunk_id, tilemap_id) in standard_tilemap_meshes.iter() { if !visible_entities - .entities - .iter() + .iter::() .any(|&entity| entity.index() == tilemap_id.0.index()) { continue; From 3a11d99af7cbe5a7ab505d2b4b3a3d7a114de488 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 01:14:40 -0700 Subject: [PATCH 12/27] app.world access is functions now - [9202](https://github.com/bevyengine/bevy/pull/9202) changed world access to functions. [relevent line](https://github.com/bevyengine/bevy/pull/9202/files#diff-b2fba3a0c86e496085ce7f0e3f1de5960cb754c7d215ed0f087aa556e529f97fR640) - This also surfaced [12655](https://github.com/bevyengine/bevy/pull/12655) which removed `Into>` for `Handle`. using a reference or .id() is the solution here. --- src/render/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/mod.rs b/src/render/mod.rs index 1ace3003..09549f88 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -112,10 +112,10 @@ impl Plugin for TilemapRenderingPlugin { app.add_plugins(MaterialTilemapPlugin::::default()); - app.world + app.world_mut() .resource_mut::>() .insert( - Handle::::default(), + Handle::::default().id(), StandardTilemapMaterial::default(), ); } From b679927f33fcb9b5d7028f28794cf7257eb37a94 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 01:18:03 -0700 Subject: [PATCH 13/27] We don't need `World::cell`, and it doesn't exist anymore In [12551](https://github.com/bevyengine/bevy/pull/12551) `WorldCell` was removed. ...but it turns out we don't need it or its replacement anyway. --- src/render/pipeline.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/render/pipeline.rs b/src/render/pipeline.rs index facc8e07..09ec40bb 100644 --- a/src/render/pipeline.rs +++ b/src/render/pipeline.rs @@ -32,7 +32,6 @@ pub struct TilemapPipeline { impl FromWorld for TilemapPipeline { fn from_world(world: &mut World) -> Self { - let world = world.cell(); let render_device = world.get_resource::().unwrap(); let view_layout = render_device.create_bind_group_layout( From 1386dc22bcdd678f71201852935a31070de55fbe Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 01:33:06 -0700 Subject: [PATCH 14/27] examples error out unless this bevy bug is addressed with these features being added https://github.com/bevyengine/bevy/issues/13728 --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 9afb99b9..07cc051f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,6 +48,8 @@ features = [ "bevy_sprite", #"file_watcher", "multi_threaded", + "zstd", + "bevy_pbr", ] [target.'cfg(unix)'.dev-dependencies.bevy] From 1b087f45b80a19e93482e366d5e2041c423fbfa1 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 11:18:53 -0700 Subject: [PATCH 15/27] check_visibility is required for the entity that is renderable As a result of [12582](https://github.com/bevyengine/bevy/pull/12582) `check_visibility` must be implemented for the "renderable" tilemap entities. Doing this is trivial by taking advantage of the existing `check_visibility` type arguments, which accept a [`QF: QueryFilter + 'static`](https://docs.rs/bevy/0.14.0-rc.2/bevy/render/view/fn.check_visibility.html). The same `QueryFilter`` is used when checking `VisibleEntities`. I've chosen `With, With, With)>; ``` --- src/render/material.rs | 8 ++++---- src/render/mod.rs | 13 ++++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/render/material.rs b/src/render/material.rs index d44d801b..c2d14141 100644 --- a/src/render/material.rs +++ b/src/render/material.rs @@ -17,7 +17,7 @@ use bevy::{ }, renderer::RenderDevice, texture::{FallbackImage, GpuImage}, - view::{ExtractedView, ViewUniforms, VisibleEntities, WithMesh}, + view::{ExtractedView, ViewUniforms, VisibleEntities}, Extract, Render, RenderApp, RenderSet, }, utils::{HashMap, HashSet}, @@ -27,7 +27,7 @@ use std::{hash::Hash, marker::PhantomData}; #[cfg(not(feature = "atlas"))] use bevy::render::renderer::RenderQueue; -use crate::prelude::TilemapId; +use crate::prelude::{TilemapId, TilemapRenderSettings}; use super::{ chunk::{ChunkId, RenderChunk2dStorage}, @@ -421,7 +421,7 @@ pub fn queue_material_tilemap_meshes( for (entity, chunk_id, transform, tilemap_id) in standard_tilemap_meshes.iter() { if !visible_entities - .iter::() + .iter::>() .any(|&entity| entity.index() == tilemap_id.0.index()) { continue; @@ -538,7 +538,7 @@ pub fn bind_material_tilemap_meshes( for (chunk_id, tilemap_id) in standard_tilemap_meshes.iter() { if !visible_entities - .iter::() + .iter::>() .any(|&entity| entity.index() == tilemap_id.0.index()) { continue; diff --git a/src/render/mod.rs b/src/render/mod.rs index 09549f88..f24e8c55 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -9,6 +9,7 @@ use bevy::{ render_phase::AddRenderCommand, render_resource::{FilterMode, SpecializedRenderPipelines, VertexFormat}, texture::ImageSamplerDescriptor, + view::{check_visibility, VisibilitySystems}, Render, RenderApp, RenderSet, }, }; @@ -18,7 +19,10 @@ use bevy::render::renderer::RenderDevice; #[cfg(not(feature = "atlas"))] use bevy::render::texture::GpuImage; -use crate::tiles::{TilePos, TileStorage}; +use crate::{ + prelude::TilemapRenderSettings, + tiles::{TilePos, TileStorage}, +}; use crate::{ prelude::TilemapTexture, render::{ @@ -211,6 +215,13 @@ impl Plugin for TilemapRenderingPlugin { Shader::from_wgsl ); + app.add_systems( + PostUpdate, + (check_visibility::>) + .in_set(VisibilitySystems::CheckVisibility) + .after(VisibilitySystems::CalculateBounds), + ); + let render_app = match app.get_sub_app_mut(RenderApp) { Some(render_app) => render_app, None => return, From 692d56063d42060a13b6755304813885654ff48c Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 11:24:58 -0700 Subject: [PATCH 16/27] view.view_proj -> view.clip_from_world [13289](https://github.com/bevyengine/bevy/pull/13489) introduced matrix naming changes, including `view_proj` which becomes `clip_from_world` --- src/render/shaders/tilemap_vertex.wgsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/shaders/tilemap_vertex.wgsl b/src/render/shaders/tilemap_vertex.wgsl index d4eb3c09..3771fc88 100644 --- a/src/render/shaders/tilemap_vertex.wgsl +++ b/src/render/shaders/tilemap_vertex.wgsl @@ -130,7 +130,7 @@ fn vertex(vertex_input: VertexInput) -> MeshVertexOutput { out.uv = atlas_uvs[vertex_input.v_index % 4u]; out.tile_id = i32(texture_index); // out.uv = out.uv + 1e-5; - out.position = view.view_proj * mesh_data.world_position; + out.position = view.clip_from_world * mesh_data.world_position; out.color = vertex_input.color; out.storage_position = vec2(vertex_input.position.xy); return out; From 5a58689c1192df53f1f67cc888dfb524adfd7501 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 11:48:53 -0700 Subject: [PATCH 17/27] color changes to make tests runnable --- examples/hex_neighbors.rs | 8 ++++---- examples/hex_neighbors_radius_chunks.rs | 6 +++--- examples/mouse_to_tile.rs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/hex_neighbors.rs b/examples/hex_neighbors.rs index c3c8ccb5..9aa2f1bd 100644 --- a/examples/hex_neighbors.rs +++ b/examples/hex_neighbors.rs @@ -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; @@ -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); } @@ -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); } @@ -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); } diff --git a/examples/hex_neighbors_radius_chunks.rs b/examples/hex_neighbors_radius_chunks.rs index 96dd4579..fad33261 100644 --- a/examples/hex_neighbors_radius_chunks.rs +++ b/examples/hex_neighbors_radius_chunks.rs @@ -1,4 +1,4 @@ -use bevy::{math::Vec4Swizzles, prelude::*}; +use bevy::{color::palettes, math::Vec4Swizzles, prelude::*}; use bevy_ecs_tilemap::{helpers::hex_grid::offset::*, prelude::*}; mod helpers; use helpers::camera::movement as camera_movement; @@ -430,7 +430,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); } @@ -511,7 +511,7 @@ fn highlight_neighbor_labels( 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); } diff --git a/examples/mouse_to_tile.rs b/examples/mouse_to_tile.rs index ac432501..9ea13ec2 100644 --- a/examples/mouse_to_tile.rs +++ b/examples/mouse_to_tile.rs @@ -1,4 +1,4 @@ -use bevy::math::Vec4Swizzles; +use bevy::{color::palettes, math::Vec4Swizzles}; use bevy::{ecs::system::Resource, prelude::*}; use bevy_ecs_tilemap::prelude::*; mod helpers; @@ -360,7 +360,7 @@ fn highlight_tile_labels( 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(HighlightedLabel); } From 82d74cf6a9ee85885b3a447506d7200d176a3ed6 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 11:52:46 -0700 Subject: [PATCH 18/27] clippy fix --- src/render/chunk.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/chunk.rs b/src/render/chunk.rs index 2013d64c..93319f58 100644 --- a/src/render/chunk.rs +++ b/src/render/chunk.rs @@ -361,7 +361,7 @@ impl RenderChunk2d { pub fn prepare( &mut self, device: &RenderDevice, - mut mesh_vertex_buffer_layouts: &mut MeshVertexBufferLayouts, + mesh_vertex_buffer_layouts: &mut MeshVertexBufferLayouts, ) { if self.dirty_mesh { let size = ((self.size_in_tiles.x * self.size_in_tiles.y) * 4) as usize; @@ -453,7 +453,7 @@ impl RenderChunk2d { let mesh_vertex_buffer_layout = self .mesh - .get_mesh_vertex_buffer_layout(&mut mesh_vertex_buffer_layouts); + .get_mesh_vertex_buffer_layout(mesh_vertex_buffer_layouts); self.gpu_mesh = Some(GpuMesh { vertex_buffer, vertex_count: self.mesh.count_vertices() as u32, From e1a2a556efdb2ed883a19a0334aa3c8769a5215d Mon Sep 17 00:00:00 2001 From: Chris Biscardi Date: Fri, 7 Jun 2024 13:15:33 -0700 Subject: [PATCH 19/27] Update Cargo.toml Co-authored-by: Rob Parrett --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 07cc051f..f5747e30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,6 +48,7 @@ features = [ "bevy_sprite", #"file_watcher", "multi_threaded", + "webgl2", "zstd", "bevy_pbr", ] From 2ba45dabed958dd988d6d8911924b289e8ac85ba Mon Sep 17 00:00:00 2001 From: Chris Biscardi Date: Fri, 7 Jun 2024 13:15:50 -0700 Subject: [PATCH 20/27] Update Cargo.toml Co-authored-by: Rob Parrett --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index f5747e30..ecef60e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,6 +67,7 @@ features = [ "bevy_text", "bevy_sprite", "multi_threaded", + "webgl2", ] From ff87555a7a894057cc12b9cde73b5bb7ca462323 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Fri, 7 Jun 2024 13:27:11 -0700 Subject: [PATCH 21/27] final clippy fixes --- examples/colors.rs | 8 ++++---- examples/helpers/ldtk.rs | 1 + examples/helpers/tiled.rs | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/colors.rs b/examples/colors.rs index 95548281..6b33e878 100644 --- a/examples/colors.rs +++ b/examples/colors.rs @@ -29,7 +29,7 @@ fn startup(mut commands: Commands, asset_server: Res) { 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, @@ -42,7 +42,7 @@ fn startup(mut commands: Commands, asset_server: Res) { 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, @@ -55,7 +55,7 @@ fn startup(mut commands: Commands, asset_server: Res) { 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, @@ -68,7 +68,7 @@ fn startup(mut commands: Commands, asset_server: Res) { 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, diff --git a/examples/helpers/ldtk.rs b/examples/helpers/ldtk.rs index d3125c3d..1a526207 100644 --- a/examples/helpers/ldtk.rs +++ b/examples/helpers/ldtk.rs @@ -62,6 +62,7 @@ impl AssetLoader for LdtkLoader { type Settings = (); type Error = LdtkAssetLoaderError; + #[allow(refining_impl_trait)] fn load<'a>( &'a self, reader: &'a mut Reader, diff --git a/examples/helpers/tiled.rs b/examples/helpers/tiled.rs index e36f9a1a..f4427c21 100644 --- a/examples/helpers/tiled.rs +++ b/examples/helpers/tiled.rs @@ -104,6 +104,7 @@ impl AssetLoader for TiledLoader { type Settings = (); type Error = TiledAssetLoaderError; + #[allow(refining_impl_trait)] fn load<'a>( &'a self, reader: &'a mut Reader, From 2d22476e059e455315cf200db5c52ab07037b757 Mon Sep 17 00:00:00 2001 From: Chris Biscardi Date: Fri, 7 Jun 2024 16:58:08 -0700 Subject: [PATCH 22/27] Update Cargo.toml Co-authored-by: Rob Parrett --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index ecef60e6..74133a41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,7 @@ features = [ #"file_watcher", "multi_threaded", "webgl2", + # TODO Remove these before release. See https://github.com/bevyengine/bevy/issues/13728 "zstd", "bevy_pbr", ] From 03158fed28799fb68fac927c0f648be4f67301c3 Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Fri, 7 Jun 2024 18:29:30 -0700 Subject: [PATCH 23/27] Simplify async loading in ldtk/tiled helpers See Bevy #12550 --- examples/helpers/ldtk.rs | 70 +++++++++--------- examples/helpers/tiled.rs | 149 +++++++++++++++++++------------------- 2 files changed, 106 insertions(+), 113 deletions(-) diff --git a/examples/helpers/ldtk.rs b/examples/helpers/ldtk.rs index 1a526207..e515ed01 100644 --- a/examples/helpers/ldtk.rs +++ b/examples/helpers/ldtk.rs @@ -14,7 +14,6 @@ use bevy::{ use bevy::{ asset::{AssetLoader, AssetPath, LoadContext}, prelude::*, - utils::BoxedFuture, }; use bevy_ecs_tilemap::map::TilemapType; @@ -62,46 +61,43 @@ impl AssetLoader for LdtkLoader { type Settings = (); type Error = LdtkAssetLoaderError; - #[allow(refining_impl_trait)] - 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> { - 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 { + 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] { diff --git a/examples/helpers/tiled.rs b/examples/helpers/tiled.rs index f4427c21..85b0e0a8 100644 --- a/examples/helpers/tiled.rs +++ b/examples/helpers/tiled.rs @@ -25,7 +25,7 @@ use bevy::{ Res, Transform, Update, }, reflect::TypePath, - utils::{BoxedFuture, HashMap}, + utils::HashMap, }; use bevy_ecs_tilemap::prelude::*; @@ -105,90 +105,87 @@ impl AssetLoader for TiledLoader { type Error = TiledAssetLoaderError; #[allow(refining_impl_trait)] - 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> { - 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 { + 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> = 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 = - 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> = 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 = 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 = 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 = 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] { From d1d64387c4e798bac33c14278244fcadef37300e Mon Sep 17 00:00:00 2001 From: Chris Biscardi Date: Mon, 10 Jun 2024 20:18:24 -0700 Subject: [PATCH 24/27] remove second allow lint --- examples/helpers/tiled.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/helpers/tiled.rs b/examples/helpers/tiled.rs index 85b0e0a8..4e5172ff 100644 --- a/examples/helpers/tiled.rs +++ b/examples/helpers/tiled.rs @@ -104,7 +104,6 @@ impl AssetLoader for TiledLoader { type Settings = (); type Error = TiledAssetLoaderError; - #[allow(refining_impl_trait)] async fn load<'a>( &'a self, reader: &'a mut Reader<'_>, From 92fca8fc0b61dc73cc2e51e857879cd407f4fa6f Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Mon, 17 Jun 2024 17:12:20 -0700 Subject: [PATCH 25/27] rc.3 bump --- Cargo.toml | 6 +++--- src/render/extract.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 74133a41..2eaaf9dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ render = [] serde = ["dep:serde"] [dependencies] -bevy = { version = "0.14.0-rc.2", default-features = false, features = [ +bevy = { version = "0.14.0-rc.3", default-features = false, features = [ "bevy_core_pipeline", "bevy_render", "bevy_asset", @@ -35,7 +35,7 @@ tiled = { version = "0.11.0", default-features = false } thiserror = { version = "1.0" } [dev-dependencies.bevy] -version = "0.14.0-rc.2" +version = "0.14.0-rc.3" default-features = false features = [ "bevy_core_pipeline", @@ -55,7 +55,7 @@ features = [ ] [target.'cfg(unix)'.dev-dependencies.bevy] -version = "0.14.0-rc.2" +version = "0.14.0-rc.3" default-features = false features = [ "bevy_core_pipeline", diff --git a/src/render/extract.rs b/src/render/extract.rs index f87d1828..06fd69a6 100644 --- a/src/render/extract.rs +++ b/src/render/extract.rs @@ -282,7 +282,7 @@ pub fn extract( visible: visible.0, position, texture, - color: color.0.linear().to_f32_array(), + color: color.0.to_linear().to_f32_array(), }; let data = tilemap_query.get(tilemap_id.0).unwrap(); From 9b26ae5a187c65c9e2b572887bdfb7f5d35a4792 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Thu, 4 Jul 2024 09:23:25 -0700 Subject: [PATCH 26/27] bump version for major release --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2eaaf9dc..d5cf3b33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ render = [] serde = ["dep:serde"] [dependencies] -bevy = { version = "0.14.0-rc.3", default-features = false, features = [ +bevy = { version = "0.14.0", default-features = false, features = [ "bevy_core_pipeline", "bevy_render", "bevy_asset", @@ -35,7 +35,7 @@ tiled = { version = "0.11.0", default-features = false } thiserror = { version = "1.0" } [dev-dependencies.bevy] -version = "0.14.0-rc.3" +version = "0.14.0" default-features = false features = [ "bevy_core_pipeline", @@ -55,7 +55,7 @@ features = [ ] [target.'cfg(unix)'.dev-dependencies.bevy] -version = "0.14.0-rc.3" +version = "0.14.0" default-features = false features = [ "bevy_core_pipeline", From ef207001b0943f9041a3012599b226f0480e5de6 Mon Sep 17 00:00:00 2001 From: Christopher Biscardi Date: Thu, 4 Jul 2024 20:35:05 -0700 Subject: [PATCH 27/27] remove unused features --- Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d5cf3b33..1dd8dc01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,9 +49,6 @@ features = [ #"file_watcher", "multi_threaded", "webgl2", - # TODO Remove these before release. See https://github.com/bevyengine/bevy/issues/13728 - "zstd", - "bevy_pbr", ] [target.'cfg(unix)'.dev-dependencies.bevy]