|
1 | | -use crate::error::{ProcessingError, Result}; |
2 | | -use bevy::asset::io::embedded::GetAssetServer; |
3 | | -use bevy::asset::{RenderAssetUsages, handle_internal_asset_events, LoadState}; |
4 | | -use bevy::ecs::entity::EntityHashMap; |
5 | | -use bevy::ecs::system::{RunSystemOnce, SystemState}; |
6 | | -use bevy::prelude::*; |
7 | | -use bevy::render::render_asset::{AssetExtractionSystems, RenderAssets}; |
8 | | -use bevy::render::render_resource::{ |
9 | | - Buffer, BufferDescriptor, BufferUsages, CommandEncoderDescriptor, Extent3d, MapMode, PollType, |
10 | | - TexelCopyBufferInfo, TexelCopyBufferLayout, Texture, TextureDimension, TextureFormat, |
| 1 | +use std::path::PathBuf; |
| 2 | + |
| 3 | +use bevy::{ |
| 4 | + asset::{ |
| 5 | + LoadState, RenderAssetUsages, handle_internal_asset_events, io::embedded::GetAssetServer, |
| 6 | + }, |
| 7 | + ecs::{ |
| 8 | + entity::EntityHashMap, |
| 9 | + system::{RunSystemOnce, SystemState}, |
| 10 | + }, |
| 11 | + prelude::*, |
| 12 | + render::{ |
| 13 | + Extract, ExtractSchedule, MainWorld, |
| 14 | + render_asset::{AssetExtractionSystems, RenderAssets}, |
| 15 | + render_resource::{ |
| 16 | + Buffer, BufferDescriptor, BufferUsages, CommandEncoderDescriptor, Extent3d, MapMode, |
| 17 | + PollType, TexelCopyBufferInfo, TexelCopyBufferLayout, Texture, TextureDimension, |
| 18 | + TextureFormat, |
| 19 | + }, |
| 20 | + renderer::{RenderDevice, RenderQueue}, |
| 21 | + texture::GpuImage, |
| 22 | + }, |
11 | 23 | }; |
12 | | -use bevy::render::renderer::{RenderDevice, RenderQueue}; |
13 | | -use bevy::render::texture::GpuImage; |
14 | | -use bevy::render::{Extract, ExtractSchedule, MainWorld}; |
15 | 24 | use half::f16; |
16 | | -use std::path::PathBuf; |
| 25 | + |
| 26 | +use crate::error::{ProcessingError, Result}; |
17 | 27 |
|
18 | 28 | pub struct PImagePlugin; |
19 | 29 |
|
@@ -101,18 +111,14 @@ pub fn create( |
101 | 111 | } |
102 | 112 |
|
103 | 113 | pub fn load(world: &mut World, path: PathBuf) -> Result<Entity> { |
104 | | - fn load_inner( |
105 | | - In(path): In<PathBuf>, |
106 | | - world: &mut World, |
107 | | - ) -> Result<Entity> { |
| 114 | + fn load_inner(In(path): In<PathBuf>, world: &mut World) -> Result<Entity> { |
108 | 115 | let handle = world.get_asset_server().load(path); |
109 | 116 | while let LoadState::Loading = world.get_asset_server().load_state(&handle) { |
110 | 117 | world |
111 | 118 | .run_system_once(handle_internal_asset_events) |
112 | 119 | .expect("Failed to run internal asset events system"); |
113 | 120 | } |
114 | | - let images = world |
115 | | - .resource::<Assets<Image>>(); |
| 121 | + let images = world.resource::<Assets<Image>>(); |
116 | 122 | let image = images |
117 | 123 | .get(&handle) |
118 | 124 | .ok_or_else(|| ProcessingError::ImageNotFound)?; |
@@ -308,4 +314,3 @@ pub fn destroy(world: &mut World, entity: Entity) -> Result<()> { |
308 | 314 | .run_system_cached_with(destroy_inner, entity) |
309 | 315 | .expect("Failed to run destroy system") |
310 | 316 | } |
311 | | - |
|
0 commit comments