-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Bevy Asset V2 #8624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Bevy Asset V2 #8624
Changes from all commits
Commits
Show all changes
149 commits
Select commit
Hold shift + click to select a range
5151860
Bevy Asset V2
cart e04acbb
Merge remote-tracking branch 'upstream/main' into bevy_asset_v2
cart 00c9d4c
Fix ImageLoader init: make sure it has access to Device
cart d919f15
.imported_assets -> imported_assets
cart a681099
Fix loading multiple sub-assets at the same time (didn't properly ded…
cart 03331b9
Retrieve hash where relevant for read_asset_bytes
cart b8afe10
Don't skip processing assets without loader, Meta constructor, remove…
cart f95d4c0
Nicer path debug
cart c3c8eee
Produce processed state for ignored assets
cart 7241b41
Use "load" for images in GLTF loader (enabling preprocessing), fix Pr…
cart 0fa8e5b
is_srgb setting on ImageLoader. Detect srgb in compressed image saver
cart a4c9cc1
Remove unused import
cart 4ea2b4d
fix build errors
cart b31e2fd
clippy
cart 79a1e71
Merge remote-tracking branch 'upstream/main' into bevy_asset_v2
cart 9041806
Loader settings overrides
cart f6f91b6
Repeatable meta transforms (fixes hot reloading)
cart f31f5a2
Use md5 hash (aHash was a bad choice for a variety of reasons)
cart afaf223
Merge remote-tracking branch 'upstream/main' into bevy_asset_v2
cart 6952197
Remove on_loaded (just an experiment ... this deserves its own design…
cart 2cb8ab0
WASM support
cart b1ed3ee
Update examples readme
cart ec60bc1
Update features
cart 2af337d
Android support
cart f9fe116
Port EXR loader
cart b00264d
Merge remote-tracking branch 'upstream/main' into bevy_asset_v2
cart 36dad96
Merge remote-tracking branch 'upstream/main' into bevy_asset_v2
cart dd3757c
Merge remote-tracking branch 'upstream/main' into bevy_asset_v2
cart 2569180
Document Assets, Events, Handles, LoadedAsset, AssetId, AssetPlugin, …
cart ec7a595
Document loader.rs
cart eddb93d
Document meta
cart db502f0
Document AssetSaver and path.rs
cart 30a9bd7
Make mismatched settings a runtime error instead of a panic
cart 66f7a63
Document AssetServer
cart 28b14d9
Document ProcessorTransactionLog
cart 987ed9e
Document AssetProcessor, Process, LoadAndSave, and more
cart 011c02f
Document the rest of `io`
cart f0f4879
Allow AssetSavers to save labeled assets
cart e4720c1
Formatting tweaks
cart 93c8144
Add public ProcessContext::asset_bytes()
cart ff54e02
Actual Reflect impl for Handle. Support reflect serializing and deser…
cart 22b362a
Enable spawning scenes with strong handles by impling reflect_value f…
cart d389aec
File change event debouncing + delays. Improves change reliability, f…
cart a4e376b
Use RecommendedWatcher instead of INotifyWatcher (#31)
BeastLe9enD b824136
Remove unnecessary serialize / deserialize impls from AssetId
cart 94c30cc
Handle removal and "move back in" file events. Fix blocking on event …
cart 278d56c
Handle rename events in processor
cart 64c06df
Update bevy_asset example meta
cart c75b14f
Check for asset source existence before creating meta files. Handle m…
cart 99c84c1
Fill in remaining events. Add "unrecoverable error" type to transacti…
cart 92b5a9e
Fill in file events that happen on windows and fix broken refactor
cart 5650375
Add docs about transaction log entries
cart 0a44a11
Cleanup empty processed directories
cart 5bcf6ab
Handle remaining process errors and add write helpers
cart 60454e2
Remove processed_dev() from load_gltf example
cart f24cf5d
Use noun form "dependant" when relevant.
cart a32030e
Tweak processor logs
cart fe3f319
Fix "write to destination" bug introduced during refactor
cart fd29fd3
Ignore assets without extensions from inside process_asset
cart c34b4b7
Track and reload "load dependants" when watching for changes in the A…
cart 7bbc4b0
Track and store actual loading and failed dependencies. Stop "hacking…
cart cb80146
AssetDependencyVisitor -> VisitAssetDependencies
cart 0ee1bde
Re-add filesystem_watcher / make watcher optional
cart 5b3f24b
Merge remote-tracking branch 'upstream/main' into bevy_asset_v2
cart 0142d09
Update cargo_features.md
cart e1fed03
Re-add BEVY_ASSET_ROOT env variable
cart ce2b2ef
Add RenderAssets::iter_mut
cart eaba64c
Add a more reasonable loader setting in the loader example
cart 962f849
Add multi-threaded setting in-line with general bevy pattern
cart da58dc9
recycled_queue_receiver doc comment
cart 3d0f76e
Impl Copy for AssetEvent
cart e0533d6
use get_short_name in Handle Debug impl
cart 86dc30d
Fix typed_debug_checked docs and expand them a bit
cart d593092
Document AssetWriter methods
cart 8956519
wasm: also fail on non-200 status codes
cart 2230200
Disable processing in sprite example
cart 16bccf2
not(target = "wasm32") -> not(target_arch = "wasm32")
cart f4a9613
Remove filesystem_watcher from default features (doesn't compile on w…
cart ccc34c9
Improve HttpWasmAssetReader error handling (and refactor)
cart cf1837c
Refactor asset_providers init
cart 901907f
TrackAssets set
cart 6e22b3e
remove duplicate comment
cart 9b421cc
should_load_dependencies
cart aa9b678
Add begin_labeled_asset doc example
cart ef637c5
Fix non-multithreaded non-wasm bevy_asset builds
cart a8f6624
Document AssetPath / labels and link to it from LoadContext
cart 412d819
Fix/improve some AssetPath docs
cart 5558758
interface -> trait
cart 9dca687
Re-enable set_state (signaling issue is fixed)
cart 6f9b0e2
Apply suggestions from code review
cart 2decbd2
Update crates/bevy_asset/src/loader.rs
cart 18acf0b
loop/break instead of while
cart dccd694
Apply suggestions from code review
cart 0f6400c
println -> trace
cart e57bb34
Add syn err for Asset derive on unsupported types
cart 3ba07e8
Clarifying allocator comment
cart 61cd36e
use better phrasing than "global"
cart f8adad8
Check if asset exists before sending modified event.
cart 2040e2d
move dense id iter implementation to DenseAssetStorage
cart 7006cbb
Dedupe debug+display impl. Add link to Handle in docs.
cart cec0fd7
Use internal Ord impl
cart 074ccb7
Improve display impl for UntypedAssetId
cart 95aa10f
InternalAssetHandle -> StrongHandle
cart 6e3d9df
Apply suggestions from code review
cart e308ac5
Simplify AssetEvent::is_X impls
cart 822d554
Replace mismatched doc with useful doc.
cart 670fb0d
Re-add folder loading example
cart aee8128
Remove old panic docs
cart 4b2328f
add "safety" comment
cart 0799fd9
Update crates/bevy_asset/src/server/mod.rs
cart 957077b
Load images as srgb by default
cart 6dec24a
Properly handle invalid generations
cart f99930d
Merge remote-tracking branch 'upstream/main' into bevy_asset_v2
cart 75c1b7d
Merge remote-tracking branch 'upstream/main' into bevy_asset_v2
cart 0ed8579
AssetLoader preregistration and async resolution
cart 531665d
Merge remote-tracking branch 'upstream/main' into bevy_asset_v2
cart 1502bf0
Update cargo_features.md
cart 78d6023
cargo fmt
cart 29ac8b7
fix test imports
cart 1ae9c53
Clippy
cart 65e5aa7
Use async RwLock for file_transaction_lock
cart 6ba6279
More clippy
cart 6ed7029
fix scene_viewer paths
cart 766e15a
Support upgrading AssetId to Handle from AssetServer. Fix animation_p…
cart c89269d
Ignore NotFound error when removing destination directory
cart d5dadf9
Revert AssetProvider refactor as it regressed ability to configure pr…
cart d38a594
Fix doc tests
cart c4ab305
Fix potential for timing error in test
cart 592d7f3
Add toml metadata
cart b9036a5
try fixing a potential test race condition
cart 46f84cc
Revert "fix scene_viewer paths"
cart 11ae5c6
Ok maybe we just need more iterations
cart 657b708
Update and track Assets after First, apply events after PostUpdate (…
cart 93b3595
Merge remote-tracking branch 'upstream/main' into bevy_asset_v2
cart 654faa0
Improve "cannot watch" error message
cart 44ef6d6
Use async_broadcast instead of async_channel for MaybeAssetLoader
cart d0098c3
Better error messages for uninitialized asset types
cart 7b0fbb7
Initialize empty () asset
cart 261c922
Re-export anyhow from bevy_asset
cart c1e7f6f
fix doc
cart b80eb74
fix manual_asset_management test
cart 341e506
Correctly format CANNOT_WATCH_ERROR_MESSAGE
cart ce714f5
Move loader example to top level bevy crate
cart ca328ad
rename processing example file
cart 1e0281d
Add some documentation to the processing example
cart 6f82ef8
print line about hot reloading
cart ecd4155
Update examples readme
cart 4239af1
Fix docs in processing example
cart f636aac
Fix import
cart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "bevy_asset_macros" | ||
version = "0.12.0-dev" | ||
edition = "2021" | ||
description = "Derive implementations for bevy_asset" | ||
homepage = "https://bevyengine.org" | ||
repository = "https://github.com/bevyengine/bevy" | ||
license = "MIT OR Apache-2.0" | ||
keywords = ["bevy"] | ||
|
||
[lib] | ||
proc-macro = true | ||
|
||
[dependencies] | ||
bevy_macro_utils = { path = "../../bevy_macro_utils", version = "0.12.0-dev" } | ||
|
||
syn = "2.0" | ||
proc-macro2 = "1.0" | ||
quote = "1.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use bevy_macro_utils::BevyManifest; | ||
use proc_macro::{Span, TokenStream}; | ||
use quote::quote; | ||
use syn::{parse_macro_input, Data, DeriveInput, Path}; | ||
|
||
pub(crate) fn bevy_asset_path() -> syn::Path { | ||
BevyManifest::default().get_path("bevy_asset") | ||
} | ||
|
||
const DEPENDENCY_ATTRIBUTE: &str = "dependency"; | ||
|
||
#[proc_macro_derive(Asset, attributes(dependency))] | ||
pub fn derive_asset(input: TokenStream) -> TokenStream { | ||
let ast = parse_macro_input!(input as DeriveInput); | ||
let bevy_asset_path: Path = bevy_asset_path(); | ||
|
||
let struct_name = &ast.ident; | ||
let (impl_generics, type_generics, where_clause) = &ast.generics.split_for_impl(); | ||
let dependency_visitor = match derive_dependency_visitor_internal(&ast, &bevy_asset_path) { | ||
Ok(dependency_visitor) => dependency_visitor, | ||
Err(err) => return err.into_compile_error().into(), | ||
}; | ||
|
||
TokenStream::from(quote! { | ||
impl #impl_generics #bevy_asset_path::Asset for #struct_name #type_generics #where_clause { } | ||
#dependency_visitor | ||
}) | ||
} | ||
|
||
#[proc_macro_derive(VisitAssetDependencies, attributes(dependency))] | ||
pub fn derive_asset_dependency_visitor(input: TokenStream) -> TokenStream { | ||
let ast = parse_macro_input!(input as DeriveInput); | ||
let bevy_asset_path: Path = bevy_asset_path(); | ||
match derive_dependency_visitor_internal(&ast, &bevy_asset_path) { | ||
Ok(dependency_visitor) => TokenStream::from(dependency_visitor), | ||
Err(err) => err.into_compile_error().into(), | ||
} | ||
} | ||
|
||
fn derive_dependency_visitor_internal( | ||
ast: &DeriveInput, | ||
bevy_asset_path: &Path, | ||
) -> Result<proc_macro2::TokenStream, syn::Error> { | ||
let mut field_visitors = Vec::new(); | ||
if let Data::Struct(data_struct) = &ast.data { | ||
cart marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for field in data_struct.fields.iter() { | ||
if field | ||
.attrs | ||
.iter() | ||
.any(|a| a.path().is_ident(DEPENDENCY_ATTRIBUTE)) | ||
{ | ||
if let Some(field_ident) = &field.ident { | ||
field_visitors.push(quote! { | ||
#bevy_asset_path::VisitAssetDependencies::visit_dependencies(&self.#field_ident, visit); | ||
}); | ||
} | ||
} | ||
} | ||
} else { | ||
return Err(syn::Error::new( | ||
Span::call_site().into(), | ||
"Asset derive currently only works on structs", | ||
)); | ||
} | ||
|
||
let struct_name = &ast.ident; | ||
let (impl_generics, type_generics, where_clause) = &ast.generics.split_for_impl(); | ||
|
||
Ok(quote! { | ||
impl #impl_generics #bevy_asset_path::VisitAssetDependencies for #struct_name #type_generics #where_clause { | ||
fn visit_dependencies(&self, visit: &mut impl FnMut(#bevy_asset_path::UntypedAssetId)) { | ||
#(#field_visitors)* | ||
} | ||
} | ||
}) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.