Skip to content

Commit

Permalink
Merge commit '02bf4efe64f2d10c8063edc760303e67e9b99e19' into meshlet
Browse files Browse the repository at this point in the history
  • Loading branch information
JMS55 committed Jan 24, 2024
2 parents 6e72360 + 02bf4ef commit dc5c57e
Show file tree
Hide file tree
Showing 77 changed files with 2,101 additions and 271 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
CARGO_TERM_COLOR: always
NIGHTLY_TOOLCHAIN: nightly-2024-01-17
NIGHTLY_TOOLCHAIN: nightly

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions assets/scenes/load_scene_example.scn.ron
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
),
},
entities: {
0: (
4294967296: (
components: {
"bevy_transform::components::transform::Transform": (
translation: (
Expand Down Expand Up @@ -34,7 +34,7 @@
),
},
),
1: (
4294967297: (
components: {
"scene::ComponentA": (
x: 3.0,
Expand Down
11 changes: 10 additions & 1 deletion crates/bevy_asset/src/io/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod file_asset;
#[cfg(not(feature = "multi-threaded"))]
mod sync_file_asset;

use bevy_log::error;
#[cfg(feature = "file_watcher")]
pub use file_watcher::*;

Expand Down Expand Up @@ -73,7 +74,15 @@ impl FileAssetWriter {
/// watching for changes.
///
/// See `get_base_path` below.
pub fn new<P: AsRef<Path>>(path: P) -> Self {
pub fn new<P: AsRef<Path> + std::fmt::Debug>(path: P, create_root: bool) -> Self {
if create_root {
if let Err(e) = std::fs::create_dir_all(&path) {
error!(
"Failed to create root directory {:?} for file asset writer: {:?}",
path, e
);
}
}
Self {
root_path: get_base_path().join(path.as_ref()),
}
Expand Down
22 changes: 13 additions & 9 deletions crates/bevy_asset/src/io/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<'a> PartialEq for AssetSourceId<'a> {
#[derive(Default)]
pub struct AssetSourceBuilder {
pub reader: Option<Box<dyn FnMut() -> Box<dyn AssetReader> + Send + Sync>>,
pub writer: Option<Box<dyn FnMut() -> Option<Box<dyn AssetWriter>> + Send + Sync>>,
pub writer: Option<Box<dyn FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync>>,
pub watcher: Option<
Box<
dyn FnMut(crossbeam_channel::Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>>
Expand All @@ -120,7 +120,8 @@ pub struct AssetSourceBuilder {
>,
>,
pub processed_reader: Option<Box<dyn FnMut() -> Box<dyn AssetReader> + Send + Sync>>,
pub processed_writer: Option<Box<dyn FnMut() -> Option<Box<dyn AssetWriter>> + Send + Sync>>,
pub processed_writer:
Option<Box<dyn FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync>>,
pub processed_watcher: Option<
Box<
dyn FnMut(crossbeam_channel::Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>>
Expand All @@ -142,8 +143,8 @@ impl AssetSourceBuilder {
watch_processed: bool,
) -> Option<AssetSource> {
let reader = self.reader.as_mut()?();
let writer = self.writer.as_mut().and_then(|w| w());
let processed_writer = self.processed_writer.as_mut().and_then(|w| w());
let writer = self.writer.as_mut().and_then(|w| w(false));
let processed_writer = self.processed_writer.as_mut().and_then(|w| w(true));
let mut source = AssetSource {
id: id.clone(),
reader,
Expand Down Expand Up @@ -200,7 +201,7 @@ impl AssetSourceBuilder {
/// Will use the given `writer` function to construct unprocessed [`AssetWriter`] instances.
pub fn with_writer(
mut self,
writer: impl FnMut() -> Option<Box<dyn AssetWriter>> + Send + Sync + 'static,
writer: impl FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync + 'static,
) -> Self {
self.writer = Some(Box::new(writer));
self
Expand Down Expand Up @@ -230,7 +231,7 @@ impl AssetSourceBuilder {
/// Will use the given `writer` function to construct processed [`AssetWriter`] instances.
pub fn with_processed_writer(
mut self,
writer: impl FnMut() -> Option<Box<dyn AssetWriter>> + Send + Sync + 'static,
writer: impl FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync + 'static,
) -> Self {
self.processed_writer = Some(Box::new(writer));
self
Expand Down Expand Up @@ -443,10 +444,13 @@ impl AssetSource {
/// the asset root. This will return [`None`] if this platform does not support writing assets by default.
pub fn get_default_writer(
_path: String,
) -> impl FnMut() -> Option<Box<dyn AssetWriter>> + Send + Sync {
move || {
) -> impl FnMut(bool) -> Option<Box<dyn AssetWriter>> + Send + Sync {
move |_create_root: bool| {
#[cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))]
return Some(Box::new(super::file::FileAssetWriter::new(&_path)));
return Some(Box::new(super::file::FileAssetWriter::new(
&_path,
_create_root,
)));
#[cfg(any(target_arch = "wasm32", target_os = "android"))]
return None;
}
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ impl Plugin for AssetPlugin {
UpdateAssets,
TrackAssets.after(handle_internal_asset_events),
)
.add_systems(UpdateAssets, handle_internal_asset_events);
.add_systems(UpdateAssets, handle_internal_asset_events)
.register_type::<AssetPath>();

let mut order = app.world.resource_mut::<MainScheduleOrder>();
order.insert_after(First, UpdateAssets);
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl AssetServer {
self.load_internal(None, path, false, None).await
}

/// Load an asset without knowing it's type. The method returns a handle to a [`LoadedUntypedAsset`].
/// Load an asset without knowing its type. The method returns a handle to a [`LoadedUntypedAsset`].
///
/// Once the [`LoadedUntypedAsset`] is loaded, an untyped handle for the requested path can be
/// retrieved from it.
Expand Down
6 changes: 5 additions & 1 deletion crates/bevy_core/src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ use std::{
ops::Deref,
};

#[cfg(feature = "serialize")]
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};

/// Component used to identify an entity. Stores a hash for faster comparisons.
///
/// The hash is eagerly re-computed upon each update to the name.
Expand All @@ -19,8 +22,9 @@ use std::{
/// used instead as the default unique identifier.
#[derive(Reflect, Component, Clone)]
#[reflect(Component, Default, Debug)]
#[cfg_attr(feature = "serialize", reflect(Serialize, Deserialize))]
pub struct Name {
hash: u64, // TODO: Shouldn't be serialized
hash: u64, // Won't be serialized (see: `bevy_core::serde` module)
name: Cow<'static, str>,
}

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/bloom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Plugin for BloomPlugin {
#[derive(Default)]
struct BloomNode;
impl ViewNode for BloomNode {
type ViewData = (
type ViewQuery = (
&'static ExtractedCamera,
&'static ViewTarget,
&'static BloomTexture,
Expand All @@ -140,7 +140,7 @@ impl ViewNode for BloomNode {
bloom_settings,
upsampling_pipeline_ids,
downsampling_pipeline_ids,
): QueryItem<Self::ViewData>,
): QueryItem<Self::ViewQuery>,
world: &World,
) -> Result<(), NodeRunError> {
let downsampling_pipeline_res = world.resource::<BloomDownsamplingPipeline>();
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_core_pipeline/src/bloom/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ pub enum BloomCompositeMode {
}

impl ExtractComponent for BloomSettings {
type Data = (&'static Self, &'static Camera);
type QueryData = (&'static Self, &'static Camera);

type Filter = ();
type QueryFilter = ();
type Out = (Self, BloomUniforms);

fn extract_component((settings, camera): QueryItem<'_, Self::Data>) -> Option<Self::Out> {
fn extract_component((settings, camera): QueryItem<'_, Self::QueryData>) -> Option<Self::Out> {
match (
camera.physical_viewport_rect(),
camera.physical_viewport_size(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ pub struct CASUniform {
}

impl ExtractComponent for ContrastAdaptiveSharpeningSettings {
type Data = &'static Self;
type Filter = With<Camera>;
type QueryData = &'static Self;
type QueryFilter = With<Camera>;
type Out = (DenoiseCAS, CASUniform);

fn extract_component(item: QueryItem<Self::Data>) -> Option<Self::Out> {
fn extract_component(item: QueryItem<Self::QueryData>) -> Option<Self::Out> {
if !item.enabled || item.sharpening_strength == 0.0 {
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::AlphaMask3d;
#[derive(Default)]
pub struct MainOpaquePass3dNode;
impl ViewNode for MainOpaquePass3dNode {
type ViewData = (
type ViewQuery = (
&'static ExtractedCamera,
&'static RenderPhase<Opaque3d>,
&'static RenderPhase<AlphaMask3d>,
Expand All @@ -44,7 +44,7 @@ impl ViewNode for MainOpaquePass3dNode {
skybox_pipeline,
skybox_bind_group,
view_uniform_offset,
): QueryItem<Self::ViewData>,
): QueryItem<Self::ViewQuery>,
world: &World,
) -> Result<(), NodeRunError> {
// Run the opaque pass, sorted front-to-back
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::ops::Range;
pub struct MainTransmissivePass3dNode;

impl ViewNode for MainTransmissivePass3dNode {
type ViewData = (
type ViewQuery = (
&'static ExtractedCamera,
&'static Camera3d,
&'static RenderPhase<Transmissive3d>,
Expand All @@ -32,7 +32,7 @@ impl ViewNode for MainTransmissivePass3dNode {
graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(camera, camera_3d, transmissive_phase, target, transmission, depth): QueryItem<
Self::ViewData,
Self::ViewQuery,
>,
world: &World,
) -> Result<(), NodeRunError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use bevy_utils::tracing::info_span;
pub struct MainTransparentPass3dNode;

impl ViewNode for MainTransparentPass3dNode {
type ViewData = (
type ViewQuery = (
&'static ExtractedCamera,
&'static RenderPhase<Transparent3d>,
&'static ViewTarget,
Expand All @@ -26,7 +26,7 @@ impl ViewNode for MainTransparentPass3dNode {
&self,
graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(camera, transparent_phase, target, depth): QueryItem<Self::ViewData>,
(camera, transparent_phase, target, depth): QueryItem<Self::ViewQuery>,
world: &World,
) -> Result<(), NodeRunError> {
let view_entity = graph.view_entity();
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl CopyDeferredLightingIdNode {
}

impl ViewNode for CopyDeferredLightingIdNode {
type ViewData = (
type ViewQuery = (
&'static ViewTarget,
&'static ViewPrepassTextures,
&'static DeferredLightingIdDepthTexture,
Expand All @@ -72,7 +72,7 @@ impl ViewNode for CopyDeferredLightingIdNode {
_graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(_view_target, view_prepass_textures, deferred_lighting_id_depth_texture): QueryItem<
Self::ViewData,
Self::ViewQuery,
>,
world: &World,
) -> Result<(), NodeRunError> {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/deferred/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use super::{AlphaMask3dDeferred, Opaque3dDeferred};
pub struct DeferredGBufferPrepassNode;

impl ViewNode for DeferredGBufferPrepassNode {
type ViewData = (
type ViewQuery = (
&'static ExtractedCamera,
&'static RenderPhase<Opaque3dDeferred>,
&'static RenderPhase<AlphaMask3dDeferred>,
Expand All @@ -43,7 +43,7 @@ impl ViewNode for DeferredGBufferPrepassNode {
alpha_mask_deferred_phase,
view_depth_texture,
view_prepass_textures,
): QueryItem<Self::ViewData>,
): QueryItem<Self::ViewQuery>,
world: &World,
) -> Result<(), NodeRunError> {
let view_entity = graph.view_entity();
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/fxaa/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct FxaaNode {
}

impl ViewNode for FxaaNode {
type ViewData = (
type ViewQuery = (
&'static ViewTarget,
&'static CameraFxaaPipeline,
&'static Fxaa,
Expand All @@ -30,7 +30,7 @@ impl ViewNode for FxaaNode {
&self,
_graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(target, pipeline, fxaa): QueryItem<Self::ViewData>,
(target, pipeline, fxaa): QueryItem<Self::ViewQuery>,
world: &World,
) -> Result<(), NodeRunError> {
let pipeline_cache = world.resource::<PipelineCache>();
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/prepass/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::{AlphaMask3dPrepass, DeferredPrepass, Opaque3dPrepass, ViewPrepassTex
pub struct PrepassNode;

impl ViewNode for PrepassNode {
type ViewData = (
type ViewQuery = (
&'static ExtractedCamera,
&'static RenderPhase<Opaque3dPrepass>,
&'static RenderPhase<AlphaMask3dPrepass>,
Expand All @@ -42,7 +42,7 @@ impl ViewNode for PrepassNode {
view_depth_texture,
view_prepass_textures,
deferred_prepass,
): QueryItem<Self::ViewData>,
): QueryItem<Self::ViewQuery>,
world: &World,
) -> Result<(), NodeRunError> {
let view_entity = graph.view_entity();
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_core_pipeline/src/skybox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ pub struct Skybox {
}

impl ExtractComponent for Skybox {
type Data = (&'static Self, Option<&'static ExposureSettings>);
type Filter = ();
type QueryData = (&'static Self, Option<&'static ExposureSettings>);
type QueryFilter = ();
type Out = (Self, SkyboxUniforms);

fn extract_component(
(skybox, exposure_settings): QueryItem<'_, Self::Data>,
(skybox, exposure_settings): QueryItem<'_, Self::QueryData>,
) -> Option<Self::Out> {
let exposure = exposure_settings
.map(|e| e.exposure())
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/taa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl Default for TemporalAntiAliasSettings {
pub struct TemporalAntiAliasNode;

impl ViewNode for TemporalAntiAliasNode {
type ViewData = (
type ViewQuery = (
&'static ExtractedCamera,
&'static ViewTarget,
&'static TemporalAntiAliasHistoryTextures,
Expand All @@ -181,7 +181,7 @@ impl ViewNode for TemporalAntiAliasNode {
_graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(camera, view_target, taa_history_textures, prepass_textures, taa_pipeline_id): QueryItem<
Self::ViewData,
Self::ViewQuery,
>,
world: &World,
) -> Result<(), NodeRunError> {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/tonemapping/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct TonemappingNode {
}

impl ViewNode for TonemappingNode {
type ViewData = (
type ViewQuery = (
&'static ViewUniformOffset,
&'static ViewTarget,
&'static ViewTonemappingPipeline,
Expand All @@ -36,7 +36,7 @@ impl ViewNode for TonemappingNode {
_graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(view_uniform_offset, target, view_tonemapping_pipeline, tonemapping): QueryItem<
Self::ViewData,
Self::ViewQuery,
>,
world: &World,
) -> Result<(), NodeRunError> {
Expand Down
Loading

0 comments on commit dc5c57e

Please sign in to comment.