Rename AssetStorage to Assets

This commit is contained in:
Carter Anderson 2020-05-13 16:42:27 -07:00
parent b58db0749e
commit 70f122b92a
30 changed files with 138 additions and 138 deletions

View file

@ -10,15 +10,15 @@ pub enum AssetEvent<T> {
Created { handle: Handle<T> }, Created { handle: Handle<T> },
} }
pub struct AssetStorage<T> { pub struct Assets<T> {
assets: HashMap<HandleId, T>, assets: HashMap<HandleId, T>,
names: HashMap<String, Handle<T>>, names: HashMap<String, Handle<T>>,
events: Events<AssetEvent<T>>, events: Events<AssetEvent<T>>,
} }
impl<T> Default for AssetStorage<T> { impl<T> Default for Assets<T> {
fn default() -> Self { fn default() -> Self {
AssetStorage { Assets {
assets: HashMap::default(), assets: HashMap::default(),
names: HashMap::default(), names: HashMap::default(),
events: Events::default(), events: Events::default(),
@ -26,7 +26,7 @@ impl<T> Default for AssetStorage<T> {
} }
} }
impl<T> AssetStorage<T> { impl<T> Assets<T> {
pub fn get_named(&mut self, name: &str) -> Option<Handle<T>> { pub fn get_named(&mut self, name: &str) -> Option<Handle<T>> {
self.names.get(name).map(|handle| *handle) self.names.get(name).map(|handle| *handle)
} }
@ -77,9 +77,9 @@ impl<T> AssetStorage<T> {
pub fn asset_event_system( pub fn asset_event_system(
mut events: ResourceMut<Events<AssetEvent<T>>>, mut events: ResourceMut<Events<AssetEvent<T>>>,
mut storage: ResourceMut<AssetStorage<T>>, mut assets: ResourceMut<Assets<T>>,
) { ) {
events.extend(storage.events.drain()) events.extend(assets.events.drain())
} }
} }
@ -104,10 +104,10 @@ impl AddAsset for AppBuilder {
where where
T: Send + Sync + 'static, T: Send + Sync + 'static,
{ {
self.init_resource::<AssetStorage<T>>() self.init_resource::<Assets<T>>()
.add_system_to_stage( .add_system_to_stage(
stage::EVENT_UPDATE, stage::EVENT_UPDATE,
AssetStorage::<T>::asset_event_system.system(), Assets::<T>::asset_event_system.system(),
) )
.add_event::<AssetEvent<T>>() .add_event::<AssetEvent<T>>()
} }

View file

@ -1,5 +1,5 @@
use crate::{material::StandardMaterial, nodes::LightsNode, pipelines::build_forward_pipeline}; use crate::{material::StandardMaterial, nodes::LightsNode, pipelines::build_forward_pipeline};
use bevy_asset::AssetStorage; use bevy_asset::Assets;
use bevy_render::{ use bevy_render::{
base_render_graph, base_render_graph,
draw_target::AssignedMeshesDrawTarget, draw_target::AssignedMeshesDrawTarget,
@ -36,9 +36,9 @@ impl ForwardPbrRenderGraphBuilder for RenderGraph {
resources, resources,
); );
self.add_system_node_named(node::LIGHTS, LightsNode::new(10), resources); self.add_system_node_named(node::LIGHTS, LightsNode::new(10), resources);
let mut shaders = resources.get_mut::<AssetStorage<Shader>>().unwrap(); let mut shaders = resources.get_mut::<Assets<Shader>>().unwrap();
let mut pipelines = resources let mut pipelines = resources
.get_mut::<AssetStorage<PipelineDescriptor>>() .get_mut::<Assets<PipelineDescriptor>>()
.unwrap(); .unwrap();
{ {
let main_pass: &mut PassNode = self let main_pass: &mut PassNode = self

View file

@ -1,4 +1,4 @@
use bevy_asset::AssetStorage; use bevy_asset::Assets;
use bevy_render::{ use bevy_render::{
pipeline::{ pipeline::{
state_descriptors::{ state_descriptors::{
@ -12,7 +12,7 @@ use bevy_render::{
texture::TextureFormat, texture::TextureFormat,
}; };
pub fn build_forward_pipeline(shaders: &mut AssetStorage<Shader>) -> PipelineDescriptor { pub fn build_forward_pipeline(shaders: &mut Assets<Shader>) -> PipelineDescriptor {
PipelineDescriptor { PipelineDescriptor {
rasterization_state: Some(RasterizationStateDescriptor { rasterization_state: Some(RasterizationStateDescriptor {
front_face: FrontFace::Ccw, front_face: FrontFace::Ccw,

View file

@ -8,7 +8,7 @@ use crate::{
shader::AsUniforms, shader::AsUniforms,
Renderable, Vertex, Renderable, Vertex,
}; };
use bevy_asset::{AssetStorage, Handle}; use bevy_asset::{Assets, Handle};
use glam::*; use glam::*;
use legion::prelude::*; use legion::prelude::*;
use std::borrow::Cow; use std::borrow::Cow;
@ -312,7 +312,7 @@ pub mod shape {
pub fn mesh_specializer_system() -> Box<dyn Schedulable> { pub fn mesh_specializer_system() -> Box<dyn Schedulable> {
SystemBuilder::new("mesh_specializer") SystemBuilder::new("mesh_specializer")
.read_resource::<AssetStorage<Mesh>>() .read_resource::<Assets<Mesh>>()
.with_query( .with_query(
<(Read<Handle<Mesh>>, Write<Renderable>)>::query() <(Read<Handle<Mesh>>, Write<Renderable>)>::query()
.filter(changed::<Handle<Mesh>>() | changed::<Renderable>()), .filter(changed::<Handle<Mesh>>() | changed::<Renderable>()),
@ -333,7 +333,7 @@ fn setup_mesh_resource(
render_resource_assignments: &mut RenderResourceAssignments, render_resource_assignments: &mut RenderResourceAssignments,
vertex_buffer_descriptor: &VertexBufferDescriptor, vertex_buffer_descriptor: &VertexBufferDescriptor,
handle: Handle<Mesh>, handle: Handle<Mesh>,
meshes: &AssetStorage<Mesh>, meshes: &Assets<Mesh>,
) { ) {
log::trace!("setup mesh for {:?}", render_resource_assignments.id); log::trace!("setup mesh for {:?}", render_resource_assignments.id);
let index_format = IndexFormat::Uint16; let index_format = IndexFormat::Uint16;
@ -381,7 +381,7 @@ pub fn mesh_resource_provider_system(resources: &mut Resources) -> Box<dyn Sched
vertex_buffer_descriptors.set(vertex_buffer_descriptor.clone()); vertex_buffer_descriptors.set(vertex_buffer_descriptor.clone());
SystemBuilder::new("mesh_resource_provider") SystemBuilder::new("mesh_resource_provider")
.read_resource::<RenderResources>() .read_resource::<RenderResources>()
.read_resource::<AssetStorage<Mesh>>() .read_resource::<Assets<Mesh>>()
.with_query(<(Read<Handle<Mesh>>, Write<Renderable>)>::query()) .with_query(<(Read<Handle<Mesh>>, Write<Renderable>)>::query())
.build( .build(
move |_, world, (render_resource_context, meshes /* asset_batchers*/), query| { move |_, world, (render_resource_context, meshes /* asset_batchers*/), query| {

View file

@ -11,7 +11,7 @@ use crate::{
shader::{Shader, ShaderStages}, shader::{Shader, ShaderStages},
texture::TextureFormat, texture::TextureFormat,
}; };
use bevy_asset::AssetStorage; use bevy_asset::Assets;
// TODO: consider removing this in favor of Option<Layout> // TODO: consider removing this in favor of Option<Layout>
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -145,7 +145,7 @@ impl PipelineDescriptor {
/// render resource. /// render resource.
pub fn reflect_layout( pub fn reflect_layout(
&mut self, &mut self,
shaders: &AssetStorage<Shader>, shaders: &Assets<Shader>,
bevy_conventions: bool, bevy_conventions: bool,
vertex_buffer_descriptors: Option<&VertexBufferDescriptors>, vertex_buffer_descriptors: Option<&VertexBufferDescriptors>,
render_resource_assignments: Option<&RenderResourceAssignments>, render_resource_assignments: Option<&RenderResourceAssignments>,

View file

@ -4,7 +4,7 @@ use crate::{
shader::{Shader, ShaderSource}, shader::{Shader, ShaderSource},
Renderable, Renderable,
}; };
use bevy_asset::{AssetStorage, Handle}; use bevy_asset::{Assets, Handle};
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use legion::prelude::*; use legion::prelude::*;
@ -34,7 +34,7 @@ pub struct PipelineCompiler {
impl PipelineCompiler { impl PipelineCompiler {
fn compile_shader( fn compile_shader(
&mut self, &mut self,
shader_storage: &mut AssetStorage<Shader>, shaders: &mut Assets<Shader>,
shader_handle: &Handle<Shader>, shader_handle: &Handle<Shader>,
shader_specialization: &ShaderSpecialization, shader_specialization: &ShaderSpecialization,
) -> Handle<Shader> { ) -> Handle<Shader> {
@ -43,7 +43,7 @@ impl PipelineCompiler {
.entry(*shader_handle) .entry(*shader_handle)
.or_insert_with(|| Vec::new()); .or_insert_with(|| Vec::new());
let shader = shader_storage.get(shader_handle).unwrap(); let shader = shaders.get(shader_handle).unwrap();
// don't produce new shader if the input source is already spirv // don't produce new shader if the input source is already spirv
if let ShaderSource::Spirv(_) = shader.source { if let ShaderSource::Spirv(_) = shader.source {
@ -67,7 +67,7 @@ impl PipelineCompiler {
.cloned() .cloned()
.collect::<Vec<String>>(); .collect::<Vec<String>>();
let compiled_shader = shader.get_spirv_shader(Some(&shader_def_vec)); let compiled_shader = shader.get_spirv_shader(Some(&shader_def_vec));
let compiled_handle = shader_storage.add(compiled_shader); let compiled_handle = shaders.add(compiled_shader);
compiled_shaders.push((shader_specialization.clone(), compiled_handle)); compiled_shaders.push((shader_specialization.clone(), compiled_handle));
compiled_handle compiled_handle
} }
@ -76,7 +76,7 @@ impl PipelineCompiler {
fn compile_pipeline( fn compile_pipeline(
&mut self, &mut self,
vertex_buffer_descriptors: &VertexBufferDescriptors, vertex_buffer_descriptors: &VertexBufferDescriptors,
shaders: &mut AssetStorage<Shader>, shaders: &mut Assets<Shader>,
pipeline_descriptor: &PipelineDescriptor, pipeline_descriptor: &PipelineDescriptor,
render_resource_assignments: &RenderResourceAssignments, render_resource_assignments: &RenderResourceAssignments,
) -> PipelineDescriptor { ) -> PipelineDescriptor {
@ -120,12 +120,12 @@ impl PipelineCompiler {
&mut self, &mut self,
vertex_buffer_descriptors: &VertexBufferDescriptors, vertex_buffer_descriptors: &VertexBufferDescriptors,
shader_pipeline_assignments: &mut PipelineAssignments, shader_pipeline_assignments: &mut PipelineAssignments,
pipeline_storage: &mut AssetStorage<PipelineDescriptor>, pipelines: &mut Assets<PipelineDescriptor>,
shader_storage: &mut AssetStorage<Shader>, shaders: &mut Assets<Shader>,
pipelines: &[Handle<PipelineDescriptor>], pipeline_handles: &[Handle<PipelineDescriptor>],
render_resource_assignments: &RenderResourceAssignments, render_resource_assignments: &RenderResourceAssignments,
) { ) {
for pipeline_handle in pipelines.iter() { for pipeline_handle in pipeline_handles.iter() {
if let None = self.pipeline_source_to_compiled.get(pipeline_handle) { if let None = self.pipeline_source_to_compiled.get(pipeline_handle) {
self.pipeline_source_to_compiled self.pipeline_source_to_compiled
.insert(*pipeline_handle, Vec::new()); .insert(*pipeline_handle, Vec::new());
@ -141,14 +141,14 @@ impl PipelineCompiler {
}) { }) {
*macroed_pipeline_handle *macroed_pipeline_handle
} else { } else {
let pipeline_descriptor = pipeline_storage.get(pipeline_handle).unwrap(); let pipeline_descriptor = pipelines.get(pipeline_handle).unwrap();
let compiled_pipeline = self.compile_pipeline( let compiled_pipeline = self.compile_pipeline(
vertex_buffer_descriptors, vertex_buffer_descriptors,
shader_storage, shaders,
pipeline_descriptor, pipeline_descriptor,
render_resource_assignments, render_resource_assignments,
); );
let compiled_pipeline_handle = pipeline_storage.add(compiled_pipeline); let compiled_pipeline_handle = pipelines.add(compiled_pipeline);
let macro_pipelines = self let macro_pipelines = self
.pipeline_source_to_compiled .pipeline_source_to_compiled
@ -211,10 +211,10 @@ pub fn update_shader_assignments(world: &mut World, resources: &Resources) {
{ {
let mut shader_pipeline_assignments = resources.get_mut::<PipelineAssignments>().unwrap(); let mut shader_pipeline_assignments = resources.get_mut::<PipelineAssignments>().unwrap();
let mut pipeline_compiler = resources.get_mut::<PipelineCompiler>().unwrap(); let mut pipeline_compiler = resources.get_mut::<PipelineCompiler>().unwrap();
let mut shader_storage = resources.get_mut::<AssetStorage<Shader>>().unwrap(); let mut shaders = resources.get_mut::<Assets<Shader>>().unwrap();
let vertex_buffer_descriptors = resources.get::<VertexBufferDescriptors>().unwrap(); let vertex_buffer_descriptors = resources.get::<VertexBufferDescriptors>().unwrap();
let mut pipeline_descriptor_storage = resources let mut pipeline_descriptor_storage = resources
.get_mut::<AssetStorage<PipelineDescriptor>>() .get_mut::<Assets<PipelineDescriptor>>()
.unwrap(); .unwrap();
// reset assignments so they are updated every frame // reset assignments so they are updated every frame
@ -231,7 +231,7 @@ pub fn update_shader_assignments(world: &mut World, resources: &Resources) {
&vertex_buffer_descriptors, &vertex_buffer_descriptors,
&mut shader_pipeline_assignments, &mut shader_pipeline_assignments,
&mut pipeline_descriptor_storage, &mut pipeline_descriptor_storage,
&mut shader_storage, &mut shaders,
&renderable.pipelines, &renderable.pipelines,
&renderable.render_resource_assignments, &renderable.render_resource_assignments,
); );

View file

@ -7,7 +7,7 @@ use crate::{
renderer::RenderContext, renderer::RenderContext,
shader::{FieldBindType, Shader}, shader::{FieldBindType, Shader},
}; };
use bevy_asset::{AssetStorage, Handle}; use bevy_asset::{Assets, Handle};
use legion::prelude::*; use legion::prelude::*;
pub struct PassNode { pub struct PassNode {
@ -77,7 +77,7 @@ impl Node for PassNode {
_output: &mut ResourceSlots, _output: &mut ResourceSlots,
) { ) {
let pipeline_compiler = resources.get::<PipelineCompiler>().unwrap(); let pipeline_compiler = resources.get::<PipelineCompiler>().unwrap();
let pipeline_storage = resources.get::<AssetStorage<PipelineDescriptor>>().unwrap(); let pipelines = resources.get::<Assets<PipelineDescriptor>>().unwrap();
for (i, color_attachment) in self.descriptor.color_attachments.iter_mut().enumerate() { for (i, color_attachment) in self.descriptor.color_attachments.iter_mut().enumerate() {
if let Some(input_index) = self.color_attachment_input_indices[i] { if let Some(input_index) = self.color_attachment_input_indices[i] {
@ -94,14 +94,14 @@ impl Node for PassNode {
.attachment = TextureAttachment::RenderResource(input.get(input_index).unwrap()); .attachment = TextureAttachment::RenderResource(input.get(input_index).unwrap());
} }
let shader_storage = resources.get::<AssetStorage<Shader>>().unwrap(); let shaders = resources.get::<Assets<Shader>>().unwrap();
for (pipeline_handle, draw_targets) in self.pipelines.iter_mut() { for (pipeline_handle, draw_targets) in self.pipelines.iter_mut() {
if let Some(compiled_pipelines_iter) = if let Some(compiled_pipelines_iter) =
pipeline_compiler.iter_compiled_pipelines(*pipeline_handle) pipeline_compiler.iter_compiled_pipelines(*pipeline_handle)
{ {
for compiled_pipeline_handle in compiled_pipelines_iter { for compiled_pipeline_handle in compiled_pipelines_iter {
let compiled_pipeline_descriptor = let compiled_pipeline_descriptor =
pipeline_storage.get(compiled_pipeline_handle).unwrap(); pipelines.get(compiled_pipeline_handle).unwrap();
let pipeline_layout = compiled_pipeline_descriptor.get_layout().unwrap(); let pipeline_layout = compiled_pipeline_descriptor.get_layout().unwrap();
{ {
@ -117,7 +117,7 @@ impl Node for PassNode {
render_context.resources().create_render_pipeline( render_context.resources().create_render_pipeline(
*compiled_pipeline_handle, *compiled_pipeline_handle,
&compiled_pipeline_descriptor, &compiled_pipeline_descriptor,
&shader_storage, &shaders,
); );
for draw_target in draw_targets.iter_mut() { for draw_target in draw_targets.iter_mut() {
draw_target.setup( draw_target.setup(
@ -143,7 +143,7 @@ impl Node for PassNode {
{ {
for compiled_pipeline_handle in compiled_pipelines_iter { for compiled_pipeline_handle in compiled_pipelines_iter {
let compiled_pipeline_descriptor = let compiled_pipeline_descriptor =
pipeline_storage.get(compiled_pipeline_handle).unwrap(); pipelines.get(compiled_pipeline_handle).unwrap();
render_pass.set_pipeline(*compiled_pipeline_handle); render_pass.set_pipeline(*compiled_pipeline_handle);
for draw_target in draw_targets.iter() { for draw_target in draw_targets.iter() {
draw_target.draw( draw_target.draw(

View file

@ -10,7 +10,7 @@ use crate::{
texture, Renderable, texture, Renderable,
}; };
use bevy_asset::{AssetStorage, Handle}; use bevy_asset::{Assets, Handle};
use legion::prelude::*; use legion::prelude::*;
use std::{collections::HashMap, marker::PhantomData}; use std::{collections::HashMap, marker::PhantomData};
use texture::{SamplerDescriptor, Texture, TextureDescriptor}; use texture::{SamplerDescriptor, Texture, TextureDescriptor};
@ -400,7 +400,7 @@ where
"uniform_resource_provider::<{}>", "uniform_resource_provider::<{}>",
std::any::type_name::<T>() std::any::type_name::<T>()
)) ))
.read_resource::<AssetStorage<Texture>>() .read_resource::<Assets<Texture>>()
.read_resource::<RenderResources>() .read_resource::<RenderResources>()
// TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same // TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same
.with_query(<(Read<T>, Read<Renderable>)>::query()) .with_query(<(Read<T>, Read<Renderable>)>::query())
@ -555,8 +555,8 @@ where
initialize_vertex_buffer_descriptor::<T>(&mut vertex_buffer_descriptors); initialize_vertex_buffer_descriptor::<T>(&mut vertex_buffer_descriptors);
// TODO: maybe run "update" here // TODO: maybe run "update" here
SystemBuilder::new("uniform_resource_provider") SystemBuilder::new("uniform_resource_provider")
.read_resource::<AssetStorage<T>>() .read_resource::<Assets<T>>()
.read_resource::<AssetStorage<Texture>>() .read_resource::<Assets<Texture>>()
.read_resource::<RenderResources>() .read_resource::<RenderResources>()
// TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same // TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same
.with_query(<(Read<Handle<T>>, Read<Renderable>)>::query()) .with_query(<(Read<Handle<T>>, Read<Renderable>)>::query())
@ -689,7 +689,7 @@ where
fn setup_uniform_texture_resources<T>( fn setup_uniform_texture_resources<T>(
uniforms: &T, uniforms: &T,
command_queue: &mut CommandQueue, command_queue: &mut CommandQueue,
texture_storage: &AssetStorage<Texture>, textures: &Assets<Texture>,
render_resource_context: &dyn RenderResourceContext, render_resource_context: &dyn RenderResourceContext,
render_resource_assignments: &mut RenderResourceAssignments, render_resource_assignments: &mut RenderResourceAssignments,
) where ) where
@ -712,7 +712,7 @@ fn setup_uniform_texture_resources<T>(
.unwrap(), .unwrap(),
), ),
None => { None => {
let texture = texture_storage.get(&texture_handle).unwrap(); let texture = textures.get(&texture_handle).unwrap();
let texture_descriptor: TextureDescriptor = texture.into(); let texture_descriptor: TextureDescriptor = texture.into();
let texture_resource = let texture_resource =

View file

@ -7,7 +7,7 @@ use crate::{
shader::Shader, shader::Shader,
texture::{SamplerDescriptor, TextureDescriptor}, texture::{SamplerDescriptor, TextureDescriptor},
}; };
use bevy_asset::{AssetStorage, Handle, HandleUntyped}; use bevy_asset::{Assets, Handle, HandleUntyped};
use bevy_window::{Window, WindowId}; use bevy_window::{Window, WindowId};
use std::{ use std::{
collections::HashMap, collections::HashMap,
@ -68,7 +68,7 @@ impl RenderResourceContext for HeadlessRenderResourceContext {
fn create_shader_module( fn create_shader_module(
&self, &self,
_shader_handle: Handle<Shader>, _shader_handle: Handle<Shader>,
_shader_storage: &AssetStorage<Shader>, _shaders: &Assets<Shader>,
) { ) {
} }
fn remove_buffer(&self, resource: RenderResource) { fn remove_buffer(&self, resource: RenderResource) {
@ -113,7 +113,7 @@ impl RenderResourceContext for HeadlessRenderResourceContext {
&self, &self,
_pipeline_handle: Handle<PipelineDescriptor>, _pipeline_handle: Handle<PipelineDescriptor>,
_pipeline_descriptor: &PipelineDescriptor, _pipeline_descriptor: &PipelineDescriptor,
_shader_storage: &AssetStorage<Shader>, _shaders: &Assets<Shader>,
) { ) {
} }
fn create_bind_group( fn create_bind_group(

View file

@ -6,7 +6,7 @@ use crate::{
shader::Shader, shader::Shader,
texture::{SamplerDescriptor, TextureDescriptor}, texture::{SamplerDescriptor, TextureDescriptor},
}; };
use bevy_asset::{AssetStorage, Handle, HandleUntyped}; use bevy_asset::{Assets, Handle, HandleUntyped};
use bevy_window::{Window, WindowId}; use bevy_window::{Window, WindowId};
use downcast_rs::{impl_downcast, Downcast}; use downcast_rs::{impl_downcast, Downcast};
@ -43,7 +43,7 @@ pub trait RenderResourceContext: Downcast + Send + Sync + 'static {
fn create_shader_module( fn create_shader_module(
&self, &self,
shader_handle: Handle<Shader>, shader_handle: Handle<Shader>,
shader_storage: &AssetStorage<Shader>, shaders: &Assets<Shader>,
); );
fn create_shader_module_from_source( fn create_shader_module_from_source(
&self, &self,
@ -73,7 +73,7 @@ pub trait RenderResourceContext: Downcast + Send + Sync + 'static {
&self, &self,
pipeline_handle: Handle<PipelineDescriptor>, pipeline_handle: Handle<PipelineDescriptor>,
pipeline_descriptor: &PipelineDescriptor, pipeline_descriptor: &PipelineDescriptor,
shader_storage: &AssetStorage<Shader>, shaders: &Assets<Shader>,
); );
fn create_bind_group( fn create_bind_group(
&self, &self,

View file

@ -5,7 +5,7 @@ use crate::{
Renderable, Renderable,
}; };
use bevy_asset::{AssetStorage, Handle}; use bevy_asset::{Assets, Handle};
use bevy_core::bytes::GetBytes; use bevy_core::bytes::GetBytes;
use legion::prelude::*; use legion::prelude::*;
@ -34,7 +34,7 @@ where
} }
pub fn asset_handle_shader_def_system<T>( pub fn asset_handle_shader_def_system<T>(
asset_storage: Resource<AssetStorage<T>>, assets: Resource<Assets<T>>,
asset_handle: Ref<Handle<T>>, asset_handle: Ref<Handle<T>>,
mut renderable: RefMut<Renderable>, mut renderable: RefMut<Renderable>,
) where ) where
@ -44,7 +44,7 @@ pub fn asset_handle_shader_def_system<T>(
return; return;
} }
let uniforms = asset_storage.get(&asset_handle).unwrap(); let uniforms = assets.get(&asset_handle).unwrap();
if let Some(shader_defs) = uniforms.get_shader_defs() { if let Some(shader_defs) = uniforms.get_shader_defs() {
renderable renderable
.render_resource_assignments .render_resource_assignments

View file

@ -18,7 +18,7 @@ pub use sprite::*;
pub use ui_update_system::*; pub use ui_update_system::*;
use bevy_app::{stage, AppBuilder, AppPlugin}; use bevy_app::{stage, AppBuilder, AppPlugin};
use bevy_asset::{AddAsset, AssetStorage, Handle}; use bevy_asset::{AddAsset, Assets, Handle};
use bevy_render::{ use bevy_render::{
mesh::{shape::Quad, Mesh}, mesh::{shape::Quad, Mesh},
render_graph::RenderGraph, render_graph::RenderGraph,
@ -47,7 +47,7 @@ impl AppPlugin for UiPlugin {
let mut render_graph = resources.get_mut::<RenderGraph>().unwrap(); let mut render_graph = resources.get_mut::<RenderGraph>().unwrap();
render_graph.add_ui_graph(resources); render_graph.add_ui_graph(resources);
let mut meshes = resources.get_mut::<AssetStorage<Mesh>>().unwrap(); let mut meshes = resources.get_mut::<Assets<Mesh>>().unwrap();
meshes.add_with_handle( meshes.add_with_handle(
QUAD_HANDLE, QUAD_HANDLE,
Mesh::from(Quad { Mesh::from(Quad {
@ -55,7 +55,7 @@ impl AppPlugin for UiPlugin {
}), }),
); );
let mut color_materials = resources.get_mut::<AssetStorage<ColorMaterial>>().unwrap(); let mut color_materials = resources.get_mut::<Assets<ColorMaterial>>().unwrap();
color_materials.add_default(ColorMaterial::default()); color_materials.add_default(ColorMaterial::default());
} }
} }

View file

@ -1,5 +1,5 @@
use crate::{ColorMaterial, Rect}; use crate::{ColorMaterial, Rect};
use bevy_asset::{AssetStorage, Handle}; use bevy_asset::{Assets, Handle};
use bevy_render::{ use bevy_render::{
base_render_graph, base_render_graph,
draw_target::AssignedMeshesDrawTarget, draw_target::AssignedMeshesDrawTarget,
@ -16,7 +16,7 @@ use legion::prelude::Resources;
pub const UI_PIPELINE_HANDLE: Handle<PipelineDescriptor> = pub const UI_PIPELINE_HANDLE: Handle<PipelineDescriptor> =
Handle::from_u128(323432002226399387835192542539754486265); Handle::from_u128(323432002226399387835192542539754486265);
pub fn build_ui_pipeline(shaders: &mut AssetStorage<Shader>) -> PipelineDescriptor { pub fn build_ui_pipeline(shaders: &mut Assets<Shader>) -> PipelineDescriptor {
PipelineDescriptor { PipelineDescriptor {
rasterization_state: Some(RasterizationStateDescriptor { rasterization_state: Some(RasterizationStateDescriptor {
front_face: FrontFace::Ccw, front_face: FrontFace::Ccw,
@ -78,9 +78,9 @@ impl UiRenderGraphBuilder for RenderGraph {
self.add_node_edge("rect", base_render_graph::node::MAIN_PASS) self.add_node_edge("rect", base_render_graph::node::MAIN_PASS)
.unwrap(); .unwrap();
let mut pipelines = resources let mut pipelines = resources
.get_mut::<AssetStorage<PipelineDescriptor>>() .get_mut::<Assets<PipelineDescriptor>>()
.unwrap(); .unwrap();
let mut shaders = resources.get_mut::<AssetStorage<Shader>>().unwrap(); let mut shaders = resources.get_mut::<Assets<Shader>>().unwrap();
pipelines.add_with_handle(UI_PIPELINE_HANDLE, build_ui_pipeline(&mut shaders)); pipelines.add_with_handle(UI_PIPELINE_HANDLE, build_ui_pipeline(&mut shaders));
let main_pass: &mut PassNode = self let main_pass: &mut PassNode = self
.get_node_mut(base_render_graph::node::MAIN_PASS) .get_node_mut(base_render_graph::node::MAIN_PASS)

View file

@ -1,5 +1,5 @@
use crate::{ColorMaterial, Rect}; use crate::{ColorMaterial, Rect};
use bevy_asset::{AssetStorage, Handle}; use bevy_asset::{Assets, Handle};
use bevy_render::texture::Texture; use bevy_render::texture::Texture;
pub use legion::prelude::*; pub use legion::prelude::*;
pub struct Sprite { pub struct Sprite {
@ -14,8 +14,8 @@ impl Default for Sprite {
pub fn sprite_system() -> Box<dyn Schedulable> { pub fn sprite_system() -> Box<dyn Schedulable> {
SystemBuilder::new("sprite_system") SystemBuilder::new("sprite_system")
.read_resource::<AssetStorage<ColorMaterial>>() .read_resource::<Assets<ColorMaterial>>()
.read_resource::<AssetStorage<Texture>>() .read_resource::<Assets<Texture>>()
.with_query( .with_query(
<(Read<Sprite>, Read<Handle<ColorMaterial>>, Write<Rect>)>::query().filter( <(Read<Sprite>, Read<Handle<ColorMaterial>>, Write<Rect>)>::query().filter(
changed::<Sprite>() | changed::<Rect>() | changed::<Handle<ColorMaterial>>(), changed::<Sprite>() | changed::<Rect>() | changed::<Handle<ColorMaterial>>(),

View file

@ -1,4 +1,4 @@
use bevy_asset::AssetStorage; use bevy_asset::Assets;
use bevy_render::{ use bevy_render::{
pipeline::{PipelineAssignments, PipelineCompiler, PipelineDescriptor}, pipeline::{PipelineAssignments, PipelineCompiler, PipelineDescriptor},
render_resource::EntityRenderResourceAssignments, render_resource::EntityRenderResourceAssignments,
@ -8,7 +8,7 @@ use legion::prelude::*;
pub fn render_resource_sets_system() -> Box<dyn Schedulable> { pub fn render_resource_sets_system() -> Box<dyn Schedulable> {
SystemBuilder::new("update_render_resource_sets") SystemBuilder::new("update_render_resource_sets")
.read_resource::<AssetStorage<PipelineDescriptor>>() .read_resource::<Assets<PipelineDescriptor>>()
.read_resource::<PipelineCompiler>() .read_resource::<PipelineCompiler>()
.read_resource::<PipelineAssignments>() .read_resource::<PipelineAssignments>()
.read_resource::<EntityRenderResourceAssignments>() .read_resource::<EntityRenderResourceAssignments>()

View file

@ -3,7 +3,7 @@ use crate::{
WgpuBindGroupInfo, WgpuResources, WgpuBindGroupInfo, WgpuResources,
}; };
use bevy_asset::{AssetStorage, Handle, HandleUntyped}; use bevy_asset::{Assets, Handle, HandleUntyped};
use bevy_render::{ use bevy_render::{
pipeline::{BindGroupDescriptor, PipelineDescriptor}, pipeline::{BindGroupDescriptor, PipelineDescriptor},
render_resource::{ render_resource::{
@ -297,7 +297,7 @@ impl RenderResourceContext for WgpuRenderResourceContext {
fn create_shader_module( fn create_shader_module(
&self, &self,
shader_handle: Handle<Shader>, shader_handle: Handle<Shader>,
shader_storage: &AssetStorage<Shader>, shaders: &Assets<Shader>,
) { ) {
if self if self
.resources .resources
@ -309,7 +309,7 @@ impl RenderResourceContext for WgpuRenderResourceContext {
{ {
return; return;
} }
let shader = shader_storage.get(&shader_handle).unwrap(); let shader = shaders.get(&shader_handle).unwrap();
self.create_shader_module_from_source(shader_handle, shader); self.create_shader_module_from_source(shader_handle, shader);
} }
@ -374,7 +374,7 @@ impl RenderResourceContext for WgpuRenderResourceContext {
&self, &self,
pipeline_handle: Handle<PipelineDescriptor>, pipeline_handle: Handle<PipelineDescriptor>,
pipeline_descriptor: &PipelineDescriptor, pipeline_descriptor: &PipelineDescriptor,
shaders: &AssetStorage<Shader>, shaders: &Assets<Shader>,
) { ) {
if self if self
.resources .resources

View file

@ -8,11 +8,11 @@ fn main() {
} }
fn setup(world: &mut World, resources: &mut Resources) { fn setup(world: &mut World, resources: &mut Resources) {
let mut texture_storage = resources.get_mut::<AssetStorage<Texture>>().unwrap(); let mut textures = resources.get_mut::<Assets<Texture>>().unwrap();
let texture_path = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/branding/icon.png"); let texture_path = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/branding/icon.png");
let texture = Texture::load(TextureType::Png(texture_path.to_string())); let texture = Texture::load(TextureType::Png(texture_path.to_string()));
let texture_handle = texture_storage.add(texture); let texture_handle = textures.add(texture);
let mut color_materials = resources.get_mut::<AssetStorage<ColorMaterial>>().unwrap(); let mut color_materials = resources.get_mut::<Assets<ColorMaterial>>().unwrap();
world world
.build() .build()

View file

@ -11,14 +11,14 @@ fn setup(world: &mut World, resources: &mut Resources) {
// load the mesh // load the mesh
let model_path = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/models/Monkey.gltf"); let model_path = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/models/Monkey.gltf");
let mesh = gltf::load_gltf(&model_path).unwrap().unwrap(); let mesh = gltf::load_gltf(&model_path).unwrap().unwrap();
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap(); let mut meshes = resources.get_mut::<Assets<Mesh>>().unwrap();
let mesh_handle = mesh_storage.add(mesh); let mesh_handle = meshes.add(mesh);
// create a material for the mesh // create a material for the mesh
let mut material_storage = resources let mut materials = resources
.get_mut::<AssetStorage<StandardMaterial>>() .get_mut::<Assets<StandardMaterial>>()
.unwrap(); .unwrap();
let material_handle = material_storage.add(StandardMaterial { let material_handle = materials.add(StandardMaterial {
albedo: Color::rgb(0.5, 0.4, 0.3), albedo: Color::rgb(0.5, 0.4, 0.3),
..Default::default() ..Default::default()
}); });

View file

@ -17,12 +17,12 @@ fn rotator_system(time: Resource<Time>, _rotator: RefMut<Rotator>, mut rotation:
/// set up a simple scene with a "parent" cube and a "child" cube /// set up a simple scene with a "parent" cube and a "child" cube
fn setup(world: &mut World, resources: &mut Resources) { fn setup(world: &mut World, resources: &mut Resources) {
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap(); let mut meshes = resources.get_mut::<Assets<Mesh>>().unwrap();
let mut material_storage = resources let mut material_storage = resources
.get_mut::<AssetStorage<StandardMaterial>>() .get_mut::<Assets<StandardMaterial>>()
.unwrap(); .unwrap();
let cube_handle = mesh_storage.add(Mesh::from(shape::Cube)); let cube_handle = meshes.add(Mesh::from(shape::Cube));
let cube_material_handle = material_storage.add(StandardMaterial { let cube_material_handle = material_storage.add(StandardMaterial {
albedo: Color::rgb(0.5, 0.4, 0.3), albedo: Color::rgb(0.5, 0.4, 0.3),
..Default::default() ..Default::default()

View file

@ -10,19 +10,19 @@ fn main() {
/// set up a simple scene /// set up a simple scene
fn setup(world: &mut World, resources: &mut Resources) { fn setup(world: &mut World, resources: &mut Resources) {
// create a cube and a plane mesh // create a cube and a plane mesh
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap(); let mut meshes = resources.get_mut::<Assets<Mesh>>().unwrap();
let cube_handle = mesh_storage.add(Mesh::from(shape::Cube)); let cube_handle = meshes.add(Mesh::from(shape::Cube));
let plane_handle = mesh_storage.add(Mesh::from(shape::Plane { size: 10.0 })); let plane_handle = meshes.add(Mesh::from(shape::Plane { size: 10.0 }));
// create materials for our cube and plane // create materials for our cube and plane
let mut material_storage = resources let mut materials = resources
.get_mut::<AssetStorage<StandardMaterial>>() .get_mut::<Assets<StandardMaterial>>()
.unwrap(); .unwrap();
let cube_material_handle = material_storage.add(StandardMaterial { let cube_material_handle = materials.add(StandardMaterial {
albedo: Color::rgb(0.5, 0.4, 0.3), albedo: Color::rgb(0.5, 0.4, 0.3),
..Default::default() ..Default::default()
}); });
let plane_material_handle = material_storage.add(StandardMaterial { let plane_material_handle = materials.add(StandardMaterial {
albedo: Color::rgb(0.1, 0.2, 0.1), albedo: Color::rgb(0.1, 0.2, 0.1),
..Default::default() ..Default::default()
}); });

View file

@ -16,7 +16,7 @@ fn main() {
fn move_system( fn move_system(
time: Resource<Time>, time: Resource<Time>,
mut materials: ResourceMut<AssetStorage<StandardMaterial>>, mut materials: ResourceMut<Assets<StandardMaterial>>,
mut translation: RefMut<Translation>, mut translation: RefMut<Translation>,
material_handle: Ref<Handle<StandardMaterial>>, material_handle: Ref<Handle<StandardMaterial>>,
) { ) {
@ -26,17 +26,17 @@ fn move_system(
} }
fn setup(world: &mut World, resources: &mut Resources) { fn setup(world: &mut World, resources: &mut Resources) {
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap(); let mut meshes = resources.get_mut::<Assets<Mesh>>().unwrap();
let mut material_storage = resources let mut materials = resources
.get_mut::<AssetStorage<StandardMaterial>>() .get_mut::<Assets<StandardMaterial>>()
.unwrap(); .unwrap();
let cube_handle = mesh_storage.add(Mesh::from(shape::Cube)); let cube_handle = meshes.add(Mesh::from(shape::Cube));
let plane_handle = mesh_storage.add(Mesh::from(shape::Plane { size: 10.0 })); let plane_handle = meshes.add(Mesh::from(shape::Plane { size: 10.0 }));
let cube_material_handle = material_storage.add(StandardMaterial { let cube_material_handle = materials.add(StandardMaterial {
albedo: Color::rgb(0.5, 0.4, 0.3), albedo: Color::rgb(0.5, 0.4, 0.3),
..Default::default() ..Default::default()
}); });
let plane_material_handle = material_storage.add(StandardMaterial { let plane_material_handle = materials.add(StandardMaterial {
albedo: Color::rgb(0.1, 0.2, 0.1), albedo: Color::rgb(0.1, 0.2, 0.1),
..Default::default() ..Default::default()
}); });
@ -73,7 +73,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
let mut rng = StdRng::from_entropy(); let mut rng = StdRng::from_entropy();
for _ in 0..10000 { for _ in 0..10000 {
let spawned_material_handle = material_storage.add(StandardMaterial { let spawned_material_handle = materials.add(StandardMaterial {
albedo: Color::rgb( albedo: Color::rgb(
rng.gen_range(0.0, 1.0), rng.gen_range(0.0, 1.0),
rng.gen_range(0.0, 1.0), rng.gen_range(0.0, 1.0),

View file

@ -10,35 +10,35 @@ fn main() {
/// sets up a scene with textured entities /// sets up a scene with textured entities
fn setup(world: &mut World, resources: &mut Resources) { fn setup(world: &mut World, resources: &mut Resources) {
// load a texture // load a texture
let mut texture_storage = resources.get_mut::<AssetStorage<Texture>>().unwrap(); let mut textures = resources.get_mut::<Assets<Texture>>().unwrap();
let texture_path = concat!( let texture_path = concat!(
env!("CARGO_MANIFEST_DIR"), env!("CARGO_MANIFEST_DIR"),
"/assets/branding/bevy_logo_dark_big.png" "/assets/branding/bevy_logo_dark_big.png"
); );
let texture = Texture::load(TextureType::Png(texture_path.to_string())); let texture = Texture::load(TextureType::Png(texture_path.to_string()));
let aspect = texture.aspect(); let aspect = texture.aspect();
let texture_handle = texture_storage.add(texture); let texture_handle = textures.add(texture);
// create a new quad mesh. this is what we will apply the texture to // create a new quad mesh. this is what we will apply the texture to
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap(); let mut meshes = resources.get_mut::<Assets<Mesh>>().unwrap();
let quad_width = 8.0; let quad_width = 8.0;
let quad_handle = mesh_storage.add(Mesh::from(shape::Quad { let quad_handle = meshes.add(Mesh::from(shape::Quad {
size: Vec2::new(quad_width, quad_width * aspect), size: Vec2::new(quad_width, quad_width * aspect),
})); }));
// create materials that use our new texture // create materials that use our new texture
let mut material_storage = resources let mut materials = resources
.get_mut::<AssetStorage<StandardMaterial>>() .get_mut::<Assets<StandardMaterial>>()
.unwrap(); .unwrap();
// this material renders the texture normally // this material renders the texture normally
let material_handle = material_storage.add(StandardMaterial { let material_handle = materials.add(StandardMaterial {
albedo_texture: Some(texture_handle), albedo_texture: Some(texture_handle),
..Default::default() ..Default::default()
}); });
// this material modulates the texture to make it red // this material modulates the texture to make it red
let modulated_material_handle = material_storage.add(StandardMaterial { let modulated_material_handle = materials.add(StandardMaterial {
albedo: Color::rgba(1.0, 0.0, 0.0, 0.5), albedo: Color::rgba(1.0, 0.0, 0.0, 0.5),
albedo_texture: Some(texture_handle), albedo_texture: Some(texture_handle),
..Default::default() ..Default::default()

View file

@ -10,12 +10,12 @@ impl AppPlugin for ExamplePlugin {
} }
pub fn setup(world: &mut World, resources: &mut Resources) { pub fn setup(world: &mut World, resources: &mut Resources) {
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap(); let mut meshes = resources.get_mut::<Assets<Mesh>>().unwrap();
let mut material_storage = resources let mut materials = resources
.get_mut::<AssetStorage<StandardMaterial>>() .get_mut::<Assets<StandardMaterial>>()
.unwrap(); .unwrap();
let cube_handle = mesh_storage.add(Mesh::from(shape::Cube)); let cube_handle = meshes.add(Mesh::from(shape::Cube));
let cube_material_handle = material_storage.add(StandardMaterial { let cube_material_handle = materials.add(StandardMaterial {
albedo: Color::rgb(0.5, 0.4, 0.3), albedo: Color::rgb(0.5, 0.4, 0.3),
..Default::default() ..Default::default()
}); });

View file

@ -64,12 +64,12 @@ fn move_system(
/// creates a simple scene /// creates a simple scene
fn setup(world: &mut World, resources: &mut Resources) { fn setup(world: &mut World, resources: &mut Resources) {
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap(); let mut meshes = resources.get_mut::<Assets<Mesh>>().unwrap();
let mut material_storage = resources let mut materials = resources
.get_mut::<AssetStorage<StandardMaterial>>() .get_mut::<Assets<StandardMaterial>>()
.unwrap(); .unwrap();
let cube_handle = mesh_storage.add(Mesh::from(shape::Cube)); let cube_handle = meshes.add(Mesh::from(shape::Cube));
let cube_material_handle = material_storage.add(StandardMaterial { let cube_material_handle = materials.add(StandardMaterial {
albedo: Color::rgb(0.5, 0.4, 0.3), albedo: Color::rgb(0.5, 0.4, 0.3),
..Default::default() ..Default::default()
}); });

View file

@ -17,9 +17,9 @@ fn setup(world: &mut World, resources: &mut Resources) {
// create new shader pipeline and add to main pass in Render Graph // create new shader pipeline and add to main pass in Render Graph
let pipeline_handle = { let pipeline_handle = {
let mut pipelines = resources let mut pipelines = resources
.get_mut::<AssetStorage<PipelineDescriptor>>() .get_mut::<Assets<PipelineDescriptor>>()
.unwrap(); .unwrap();
let mut shaders = resources.get_mut::<AssetStorage<Shader>>().unwrap(); let mut shaders = resources.get_mut::<Assets<Shader>>().unwrap();
let pipeline_handle = pipelines.add(PipelineDescriptor::default_config(ShaderStages { let pipeline_handle = pipelines.add(PipelineDescriptor::default_config(ShaderStages {
vertex: shaders.add(Shader::from_glsl( vertex: shaders.add(Shader::from_glsl(
@ -67,13 +67,13 @@ fn setup(world: &mut World, resources: &mut Resources) {
}; };
// create materials // create materials
let mut material_storage = resources.get_mut::<AssetStorage<MyMaterial>>().unwrap(); let mut materials = resources.get_mut::<Assets<MyMaterial>>().unwrap();
let material = material_storage.add(MyMaterial { let material = materials.add(MyMaterial {
color: Color::rgb(0.0, 0.8, 0.0), color: Color::rgb(0.0, 0.8, 0.0),
}); });
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap(); let mut meshes = resources.get_mut::<Assets<Mesh>>().unwrap();
let cube_handle = mesh_storage.add(Mesh::from(shape::Cube)); let cube_handle = meshes.add(Mesh::from(shape::Cube));
world world
.build() .build()

View file

@ -23,9 +23,9 @@ fn setup(world: &mut World, resources: &mut Resources) {
// create new shader pipeline and add to main pass in Render Graph // create new shader pipeline and add to main pass in Render Graph
let pipeline_handle = { let pipeline_handle = {
let mut pipelines = resources let mut pipelines = resources
.get_mut::<AssetStorage<PipelineDescriptor>>() .get_mut::<Assets<PipelineDescriptor>>()
.unwrap(); .unwrap();
let mut shaders = resources.get_mut::<AssetStorage<Shader>>().unwrap(); let mut shaders = resources.get_mut::<Assets<Shader>>().unwrap();
let pipeline_handle = pipelines.add(PipelineDescriptor::default_config(ShaderStages { let pipeline_handle = pipelines.add(PipelineDescriptor::default_config(ShaderStages {
vertex: shaders.add(Shader::from_glsl( vertex: shaders.add(Shader::from_glsl(
@ -77,19 +77,19 @@ fn setup(world: &mut World, resources: &mut Resources) {
}; };
// create materials // create materials
let mut material_storage = resources.get_mut::<AssetStorage<MyMaterial>>().unwrap(); let mut materials = resources.get_mut::<Assets<MyMaterial>>().unwrap();
let green_material = material_storage.add(MyMaterial { let green_material = materials.add(MyMaterial {
color: Color::rgb(0.0, 0.8, 0.0), color: Color::rgb(0.0, 0.8, 0.0),
always_red: false, always_red: false,
}); });
let red_material = material_storage.add(MyMaterial { let red_material = materials.add(MyMaterial {
color: Color::rgb(0.0, 0.0, 0.0), color: Color::rgb(0.0, 0.0, 0.0),
always_red: true, always_red: true,
}); });
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap(); let mut meshes = resources.get_mut::<Assets<Mesh>>().unwrap();
let cube_handle = mesh_storage.add(Mesh::from(shape::Cube)); let cube_handle = meshes.add(Mesh::from(shape::Cube));
world world
.build() .build()

View file

@ -9,7 +9,7 @@ fn main() {
} }
fn setup(world: &mut World, resources: &mut Resources) { fn setup(world: &mut World, resources: &mut Resources) {
let mut texture_storage = resources.get_mut::<AssetStorage<Texture>>().unwrap(); let mut textures = resources.get_mut::<Assets<Texture>>().unwrap();
let font_path = concat!( let font_path = concat!(
env!("CARGO_MANIFEST_DIR"), env!("CARGO_MANIFEST_DIR"),
"/assets/fonts/FiraSans-Bold.ttf" "/assets/fonts/FiraSans-Bold.ttf"
@ -22,8 +22,8 @@ fn setup(world: &mut World, resources: &mut Resources) {
let texture = font.render_text("Hello from Bevy!", Color::rgba(0.9, 0.9, 0.9, 1.0), 500, 60); let texture = font.render_text("Hello from Bevy!", Color::rgba(0.9, 0.9, 0.9, 1.0), 500, 60);
let half_width = texture.width as f32 / 2.0; let half_width = texture.width as f32 / 2.0;
let half_height = texture.height as f32 / 2.0; let half_height = texture.height as f32 / 2.0;
let texture_handle = texture_storage.add(texture); let texture_handle = textures.add(texture);
let mut color_materials = resources.get_mut::<AssetStorage<ColorMaterial>>().unwrap(); let mut color_materials = resources.get_mut::<Assets<ColorMaterial>>().unwrap();
world world
.build() .build()
// 2d camera // 2d camera

View file

@ -19,16 +19,16 @@ fn setup(world: &mut World, resources: &mut Resources) {
// ..Default::default() // ..Default::default()
// }); // });
let mut texture_storage = resources.get_mut::<AssetStorage<Texture>>().unwrap(); let mut textures = resources.get_mut::<Assets<Texture>>().unwrap();
let texture_path = concat!( let texture_path = concat!(
env!("CARGO_MANIFEST_DIR"), env!("CARGO_MANIFEST_DIR"),
"/assets/branding/bevy_logo_dark_big.png" "/assets/branding/bevy_logo_dark_big.png"
); );
let texture = Texture::load(TextureType::Png(texture_path.to_string())); let texture = Texture::load(TextureType::Png(texture_path.to_string()));
let aspect = texture.aspect(); let aspect = texture.aspect();
let texture_handle = texture_storage.add(texture); let texture_handle = textures.add(texture);
let mut color_materials = resources.get_mut::<AssetStorage<ColorMaterial>>().unwrap(); let mut color_materials = resources.get_mut::<Assets<ColorMaterial>>().unwrap();
let blue_material_handle = color_materials.add(Color::rgb(0.6, 0.6, 1.0).into()); let blue_material_handle = color_materials.add(Color::rgb(0.6, 0.6, 1.0).into());
world world

View file

@ -11,7 +11,7 @@ fn main() {
fn placement_system( fn placement_system(
time: Resource<Time>, time: Resource<Time>,
materials: Resource<AssetStorage<ColorMaterial>>, materials: Resource<Assets<ColorMaterial>>,
mut node: RefMut<Node>, mut node: RefMut<Node>,
material_handle: Ref<Handle<ColorMaterial>>, material_handle: Ref<Handle<ColorMaterial>>,
) { ) {
@ -25,7 +25,7 @@ fn setup(world: &mut World, resources: &mut Resources) {
let mut builder = world.build(); let mut builder = world.build();
builder.add_entity(Camera2dEntity::default()); builder.add_entity(Camera2dEntity::default());
let mut materials = resources.get_mut::<AssetStorage<ColorMaterial>>().unwrap(); let mut materials = resources.get_mut::<Assets<ColorMaterial>>().unwrap();
let mut prev = Vec2::default(); let mut prev = Vec2::default();
let count = 1000; let count = 1000;
for i in 0..count { for i in 0..count {

View file

@ -1,5 +1,5 @@
#[cfg(feature = "asset")] #[cfg(feature = "asset")]
pub use crate::asset::{AddAsset, AssetEvent, AssetStorage, Handle}; pub use crate::asset::{AddAsset, AssetEvent, Assets, Handle};
#[cfg(feature = "core")] #[cfg(feature = "core")]
pub use crate::core::{ pub use crate::core::{
time::Time, time::Time,