-#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
-#[reflect(PartialEq, Serialize, Deserialize, Default)]
+#[derive(Debug, Clone, Copy, PartialEq, Reflect)]
+#[reflect(PartialEq, Default)]
+#[cfg_attr(
+ feature = "serialize",
+ derive(serde::Serialize, serde::Deserialize),
+ reflect(Serialize, Deserialize)
+)]
pub enum Color {
/// A color in the sRGB color space with alpha.
Srgba(Srgba),
diff --git a/crates/bevy_color/src/hsla.rs b/crates/bevy_color/src/hsla.rs
index c9db008940a93..ac7cdf93dabb6 100644
--- a/crates/bevy_color/src/hsla.rs
+++ b/crates/bevy_color/src/hsla.rs
@@ -3,7 +3,6 @@ use crate::{
Xyza,
};
use bevy_reflect::prelude::*;
-use serde::{Deserialize, Serialize};
/// Color in Hue-Saturation-Lightness (HSL) color space with alpha.
/// Further information on this color model can be found on [Wikipedia](https://en.wikipedia.org/wiki/HSL_and_HSV).
@@ -11,8 +10,13 @@ use serde::{Deserialize, Serialize};
///
-#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
-#[reflect(PartialEq, Serialize, Deserialize, Default)]
+#[derive(Debug, Clone, Copy, PartialEq, Reflect)]
+#[reflect(PartialEq, Default)]
+#[cfg_attr(
+ feature = "serialize",
+ derive(serde::Serialize, serde::Deserialize),
+ reflect(Serialize, Deserialize)
+)]
pub struct Hsva {
/// The hue channel. [0.0, 360.0]
pub hue: f32,
diff --git a/crates/bevy_color/src/hwba.rs b/crates/bevy_color/src/hwba.rs
index 01221397804f7..41b4bd06be591 100644
--- a/crates/bevy_color/src/hwba.rs
+++ b/crates/bevy_color/src/hwba.rs
@@ -4,7 +4,6 @@
//! [_HWB - A More Intuitive Hue-Based Color Model_]: https://web.archive.org/web/20240226005220/http://alvyray.com/Papers/CG/HWB_JGTv208.pdf
use crate::{Alpha, ClampColor, Hue, Lcha, LinearRgba, Mix, Srgba, StandardColor, Xyza};
use bevy_reflect::prelude::*;
-use serde::{Deserialize, Serialize};
/// Color in Hue-Whiteness-Blackness (HWB) color space with alpha.
/// Further information on this color model can be found on [Wikipedia](https://en.wikipedia.org/wiki/HWB_color_model).
@@ -12,8 +11,13 @@ use serde::{Deserialize, Serialize};
///
-#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)]
-#[reflect(PartialEq, Serialize, Deserialize, Default)]
+#[derive(Debug, Clone, Copy, PartialEq, Reflect)]
+#[reflect(PartialEq, Default)]
+#[cfg_attr(
+ feature = "serialize",
+ derive(serde::Serialize, serde::Deserialize),
+ reflect(Serialize, Deserialize)
+)]
pub struct Xyza {
/// The x-axis. [0.0, 1.0]
pub x: f32,
diff --git a/crates/bevy_core/Cargo.toml b/crates/bevy_core/Cargo.toml
index 75ccb157ea0ae..d149581ebb93e 100644
--- a/crates/bevy_core/Cargo.toml
+++ b/crates/bevy_core/Cargo.toml
@@ -37,4 +37,5 @@ crossbeam-channel = "0.5.0"
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_core/src/lib.rs b/crates/bevy_core/src/lib.rs
index 8ccd3ee4d9408..610f9e7a24c92 100644
--- a/crates/bevy_core/src/lib.rs
+++ b/crates/bevy_core/src/lib.rs
@@ -1,6 +1,7 @@
-//! This crate provides core functionality for Bevy Engine.
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+//! This crate provides core functionality for Bevy Engine.
+
mod name;
#[cfg(feature = "serialize")]
mod serde;
diff --git a/crates/bevy_core_pipeline/Cargo.toml b/crates/bevy_core_pipeline/Cargo.toml
index e03b93e9d90ae..e6846d0ec161d 100644
--- a/crates/bevy_core_pipeline/Cargo.toml
+++ b/crates/bevy_core_pipeline/Cargo.toml
@@ -42,4 +42,5 @@ nonmax = "0.5"
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_derive/Cargo.toml b/crates/bevy_derive/Cargo.toml
index abf5e47f4bb0e..a936ac773a88c 100644
--- a/crates/bevy_derive/Cargo.toml
+++ b/crates/bevy_derive/Cargo.toml
@@ -19,3 +19,7 @@ syn = { version = "2.0", features = ["full"] }
[lints]
workspace = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
+all-features = true
diff --git a/crates/bevy_derive/src/lib.rs b/crates/bevy_derive/src/lib.rs
index fda825dc161a6..591bd9f7a84a1 100644
--- a/crates/bevy_derive/src/lib.rs
+++ b/crates/bevy_derive/src/lib.rs
@@ -1,5 +1,6 @@
// FIXME(3492): remove once docs are ready
#![allow(missing_docs)]
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
extern crate proc_macro;
diff --git a/crates/bevy_dev_tools/Cargo.toml b/crates/bevy_dev_tools/Cargo.toml
index 62ab2c8fcc8ae..727ba84f80691 100644
--- a/crates/bevy_dev_tools/Cargo.toml
+++ b/crates/bevy_dev_tools/Cargo.toml
@@ -43,4 +43,5 @@ ron = { version = "0.8.0", optional = true }
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_dev_tools/src/lib.rs b/crates/bevy_dev_tools/src/lib.rs
index 8bb9b0b7d2b98..031f627293485 100644
--- a/crates/bevy_dev_tools/src/lib.rs
+++ b/crates/bevy_dev_tools/src/lib.rs
@@ -1,6 +1,7 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! This crate provides additional utilities for the [Bevy game engine](https://bevyengine.org),
//! focused on improving developer experience.
-#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use bevy_app::prelude::*;
diff --git a/crates/bevy_diagnostic/Cargo.toml b/crates/bevy_diagnostic/Cargo.toml
index d82a5f2e52c75..78f1d0bb005fb 100644
--- a/crates/bevy_diagnostic/Cargo.toml
+++ b/crates/bevy_diagnostic/Cargo.toml
@@ -38,4 +38,5 @@ sysinfo = { version = "0.30.0", optional = true, default-features = false }
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_diagnostic/src/lib.rs b/crates/bevy_diagnostic/src/lib.rs
index dc21ec143f1c5..c3ad6427fc638 100644
--- a/crates/bevy_diagnostic/src/lib.rs
+++ b/crates/bevy_diagnostic/src/lib.rs
@@ -19,7 +19,7 @@ pub use entity_count_diagnostics_plugin::EntityCountDiagnosticsPlugin;
pub use frame_time_diagnostics_plugin::FrameTimeDiagnosticsPlugin;
pub use log_diagnostics_plugin::LogDiagnosticsPlugin;
#[cfg(feature = "sysinfo_plugin")]
-pub use system_information_diagnostics_plugin::SystemInformationDiagnosticsPlugin;
+pub use system_information_diagnostics_plugin::{SystemInfo, SystemInformationDiagnosticsPlugin};
use bevy_app::prelude::*;
@@ -28,12 +28,11 @@ use bevy_app::prelude::*;
pub struct DiagnosticsPlugin;
impl Plugin for DiagnosticsPlugin {
- fn build(&self, _app: &mut App) {
+ fn build(&self, app: &mut App) {
+ app.init_resource::();
+
#[cfg(feature = "sysinfo_plugin")]
- _app.init_resource::().add_systems(
- Startup,
- system_information_diagnostics_plugin::internal::log_system_info,
- );
+ app.init_resource::();
}
}
diff --git a/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs
index 0ffe3d479b2af..3709a6d05fd18 100644
--- a/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs
+++ b/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs
@@ -1,5 +1,6 @@
use crate::DiagnosticPath;
use bevy_app::prelude::*;
+use bevy_ecs::system::Resource;
/// Adds a System Information Diagnostic, specifically `cpu_usage` (in %) and `mem_usage` (in %)
///
@@ -24,10 +25,27 @@ impl Plugin for SystemInformationDiagnosticsPlugin {
}
impl SystemInformationDiagnosticsPlugin {
+ /// Total system cpu usage in %
pub const CPU_USAGE: DiagnosticPath = DiagnosticPath::const_new("system/cpu_usage");
+ /// Total system memory usage in %
pub const MEM_USAGE: DiagnosticPath = DiagnosticPath::const_new("system/mem_usage");
}
+/// A resource that stores diagnostic information about the system.
+/// This information can be useful for debugging and profiling purposes.
+///
+/// # See also
+///
+/// [`SystemInformationDiagnosticsPlugin`] for more information.
+#[derive(Debug, Resource)]
+pub struct SystemInfo {
+ pub os: String,
+ pub kernel: String,
+ pub cpu: String,
+ pub core_count: String,
+ pub memory: String,
+}
+
// NOTE: sysinfo fails to compile when using bevy dynamic or on iOS and does nothing on wasm
#[cfg(all(
any(
@@ -45,7 +63,7 @@ pub mod internal {
use crate::{Diagnostic, Diagnostics, DiagnosticsStore};
- use super::SystemInformationDiagnosticsPlugin;
+ use super::{SystemInfo, SystemInformationDiagnosticsPlugin};
const BYTES_TO_GIB: f64 = 1.0 / 1024.0 / 1024.0 / 1024.0;
@@ -87,41 +105,33 @@ pub mod internal {
});
}
- #[derive(Debug)]
- // This is required because the Debug trait doesn't detect it's used when it's only used in a print :(
- #[allow(dead_code)]
- struct SystemInfo {
- os: String,
- kernel: String,
- cpu: String,
- core_count: String,
- memory: String,
- }
-
- pub(crate) fn log_system_info() {
- let sys = System::new_with_specifics(
- RefreshKind::new()
- .with_cpu(CpuRefreshKind::new())
- .with_memory(MemoryRefreshKind::new().with_ram()),
- );
-
- let info = SystemInfo {
- os: System::long_os_version().unwrap_or_else(|| String::from("not available")),
- kernel: System::kernel_version().unwrap_or_else(|| String::from("not available")),
- cpu: sys
- .cpus()
- .first()
- .map(|cpu| cpu.brand().trim().to_string())
- .unwrap_or_else(|| String::from("not available")),
- core_count: sys
- .physical_core_count()
- .map(|x| x.to_string())
- .unwrap_or_else(|| String::from("not available")),
- // Convert from Bytes to GibiBytes since it's probably what people expect most of the time
- memory: format!("{:.1} GiB", sys.total_memory() as f64 * BYTES_TO_GIB),
- };
-
- info!("{:?}", info);
+ impl Default for SystemInfo {
+ fn default() -> Self {
+ let sys = System::new_with_specifics(
+ RefreshKind::new()
+ .with_cpu(CpuRefreshKind::new())
+ .with_memory(MemoryRefreshKind::new().with_ram()),
+ );
+
+ let system_info = SystemInfo {
+ os: System::long_os_version().unwrap_or_else(|| String::from("not available")),
+ kernel: System::kernel_version().unwrap_or_else(|| String::from("not available")),
+ cpu: sys
+ .cpus()
+ .first()
+ .map(|cpu| cpu.brand().trim().to_string())
+ .unwrap_or_else(|| String::from("not available")),
+ core_count: sys
+ .physical_core_count()
+ .map(|x| x.to_string())
+ .unwrap_or_else(|| String::from("not available")),
+ // Convert from Bytes to GibiBytes since it's probably what people expect most of the time
+ memory: format!("{:.1} GiB", sys.total_memory() as f64 * BYTES_TO_GIB),
+ };
+
+ info!("{:?}", system_info);
+ system_info
+ }
}
}
@@ -143,7 +153,16 @@ pub mod internal {
// no-op
}
- pub(crate) fn log_system_info() {
- // no-op
+ impl Default for super::SystemInfo {
+ fn default() -> Self {
+ let unknown = "Unknown".to_string();
+ Self {
+ os: unknown.clone(),
+ kernel: unknown.clone(),
+ cpu: unknown.clone(),
+ core_count: unknown.clone(),
+ memory: unknown.clone(),
+ }
+ }
}
}
diff --git a/crates/bevy_dylib/Cargo.toml b/crates/bevy_dylib/Cargo.toml
index cd6c5c783659c..28535950c0b49 100644
--- a/crates/bevy_dylib/Cargo.toml
+++ b/crates/bevy_dylib/Cargo.toml
@@ -16,3 +16,7 @@ bevy_internal = { path = "../bevy_internal", version = "0.14.0-dev", default-fea
[lints]
workspace = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
+all-features = true
diff --git a/crates/bevy_dylib/src/lib.rs b/crates/bevy_dylib/src/lib.rs
index 9aefb17ace32f..116ba5067b1da 100644
--- a/crates/bevy_dylib/src/lib.rs
+++ b/crates/bevy_dylib/src/lib.rs
@@ -1,4 +1,4 @@
-#![allow(clippy::single_component_path_imports)]
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
//! Forces dynamic linking of Bevy.
//!
@@ -51,4 +51,5 @@
// Force linking of the main bevy crate
#[allow(unused_imports)]
+#[allow(clippy::single_component_path_imports)]
use bevy_internal;
diff --git a/crates/bevy_dynamic_plugin/Cargo.toml b/crates/bevy_dynamic_plugin/Cargo.toml
index 67f22232c2f45..5e7d11754361b 100644
--- a/crates/bevy_dynamic_plugin/Cargo.toml
+++ b/crates/bevy_dynamic_plugin/Cargo.toml
@@ -18,3 +18,7 @@ thiserror = "1.0"
[lints]
workspace = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
+all-features = true
diff --git a/crates/bevy_dynamic_plugin/src/lib.rs b/crates/bevy_dynamic_plugin/src/lib.rs
index 3a620cee1f6be..a675738a45944 100644
--- a/crates/bevy_dynamic_plugin/src/lib.rs
+++ b/crates/bevy_dynamic_plugin/src/lib.rs
@@ -1,3 +1,5 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! Bevy's dynamic plugin loading functionality.
//!
//! This crate allows loading dynamic libraries (`.dylib`, `.so`) that export a single
diff --git a/crates/bevy_ecs/Cargo.toml b/crates/bevy_ecs/Cargo.toml
index 06e099b0059ce..6e54aaf7359a2 100644
--- a/crates/bevy_ecs/Cargo.toml
+++ b/crates/bevy_ecs/Cargo.toml
@@ -51,4 +51,5 @@ path = "examples/change_detection.rs"
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_ecs/macros/Cargo.toml b/crates/bevy_ecs/macros/Cargo.toml
index c9f3a5754c9ce..abc6647a8bc52 100644
--- a/crates/bevy_ecs/macros/Cargo.toml
+++ b/crates/bevy_ecs/macros/Cargo.toml
@@ -17,3 +17,7 @@ proc-macro2 = "1.0"
[lints]
workspace = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
+all-features = true
diff --git a/crates/bevy_ecs/macros/src/lib.rs b/crates/bevy_ecs/macros/src/lib.rs
index 732cd3fd37e08..267969a55ed6b 100644
--- a/crates/bevy_ecs/macros/src/lib.rs
+++ b/crates/bevy_ecs/macros/src/lib.rs
@@ -1,5 +1,6 @@
// FIXME(3492): remove once docs are ready
#![allow(missing_docs)]
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
extern crate proc_macro;
diff --git a/crates/bevy_ecs/src/archetype.rs b/crates/bevy_ecs/src/archetype.rs
index 6ab5bb2d420de..5f6302a2e1628 100644
--- a/crates/bevy_ecs/src/archetype.rs
+++ b/crates/bevy_ecs/src/archetype.rs
@@ -114,7 +114,10 @@ pub(crate) enum ComponentStatus {
}
pub(crate) struct AddBundle {
+ /// The target archetype after the bundle is added to the source archetype
pub archetype_id: ArchetypeId,
+ /// For each component iterated in the same order as the source [`Bundle`](crate::bundle::Bundle),
+ /// indicate if the component is newly added to the target archetype or if it already existed
pub bundle_status: Vec,
}
@@ -285,8 +288,12 @@ impl ArchetypeEntity {
}
}
+/// Internal metadata for an [`Entity`] getting removed from an [`Archetype`].
pub(crate) struct ArchetypeSwapRemoveResult {
+ /// If the [`Entity`] was not the last in the [`Archetype`], it gets removed by swapping it out
+ /// with the last entity in the archetype. In that case, this field contains the swapped entity.
pub(crate) swapped_entity: Option,
+ /// The [`TableRow`] where the removed entity's components are stored.
pub(crate) table_row: TableRow,
}
diff --git a/crates/bevy_ecs/src/bundle.rs b/crates/bevy_ecs/src/bundle.rs
index f3d42a66ef29b..82d9f521868fc 100644
--- a/crates/bevy_ecs/src/bundle.rs
+++ b/crates/bevy_ecs/src/bundle.rs
@@ -977,6 +977,8 @@ impl Bundles {
}
/// Initializes a new [`BundleInfo`] for a statically known type.
+ ///
+ /// Also initializes all the components in the bundle.
pub(crate) fn init_info(
&mut self,
components: &mut Components,
@@ -999,6 +1001,8 @@ impl Bundles {
id
}
+ /// # Safety
+ /// A `BundleInfo` with the given `BundleId` must have been initialized for this instance of `Bundles`.
pub(crate) unsafe fn get_unchecked(&self, id: BundleId) -> &BundleInfo {
self.bundle_infos.get_unchecked(id.0)
}
diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs
index d92029154f1a6..d307de9249206 100644
--- a/crates/bevy_ecs/src/world/entity_ref.rs
+++ b/crates/bevy_ecs/src/world/entity_ref.rs
@@ -1031,22 +1031,25 @@ impl<'w> EntityWorldMut<'w> {
/// Remove the components of `bundle` from `entity`.
///
- /// SAFETY: The components in `bundle_info` must exist.
+ /// SAFETY:
+ /// - A `BundleInfo` with the corresponding `BundleId` must have been initialized.
#[allow(clippy::too_many_arguments)]
unsafe fn remove_bundle(&mut self, bundle: BundleId) -> EntityLocation {
let entity = self.entity;
let world = &mut self.world;
let location = self.location;
+ // SAFETY: the caller guarantees that the BundleInfo for this id has been initialized.
let bundle_info = world.bundles.get_unchecked(bundle);
// SAFETY: `archetype_id` exists because it is referenced in `location` which is valid
- // and components in `bundle_info` must exist due to this functions safety invariants.
+ // and components in `bundle_info` must exist due to this function's safety invariants.
let new_archetype_id = remove_bundle_from_archetype(
&mut world.archetypes,
&mut world.storages,
&world.components,
location.archetype_id,
bundle_info,
+ // components from the bundle that are not present on the entity are ignored
true,
)
.expect("intersections should always return a result");
@@ -1117,8 +1120,7 @@ impl<'w> EntityWorldMut<'w> {
let components = &mut self.world.components;
let bundle_info = self.world.bundles.init_info::(components, storages);
- // SAFETY: Components exist in `bundle_info` because `Bundles::init_info`
- // initializes a: EntityLocation `BundleInfo` containing all components of the bundle type `T`.
+ // SAFETY: the `BundleInfo` is initialized above
self.location = unsafe { self.remove_bundle(bundle_info) };
self
@@ -1144,8 +1146,7 @@ impl<'w> EntityWorldMut<'w> {
.collect::>();
let remove_bundle = self.world.bundles.init_dynamic_info(components, to_remove);
- // SAFETY: Components exist in `remove_bundle` because `Bundles::init_dynamic_info`
- // initializes a `BundleInfo` containing all components in the to_remove Bundle.
+ // SAFETY: the `BundleInfo` for the components to remove is initialized above
self.location = unsafe { self.remove_bundle(remove_bundle) };
self
}
diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs
index 3f87d8026db27..d245df8241930 100644
--- a/crates/bevy_ecs/src/world/mod.rs
+++ b/crates/bevy_ecs/src/world/mod.rs
@@ -18,7 +18,7 @@ pub use spawn_batch::*;
use crate::{
archetype::{ArchetypeComponentId, ArchetypeId, ArchetypeRow, Archetypes},
- bundle::{Bundle, BundleInserter, BundleSpawner, Bundles},
+ bundle::{Bundle, BundleInfo, BundleInserter, BundleSpawner, Bundles},
change_detection::{MutUntyped, TicksMut},
component::{
Component, ComponentDescriptor, ComponentHooks, ComponentId, ComponentInfo, ComponentTicks,
@@ -1836,7 +1836,7 @@ impl World {
}
/// # Panics
- /// panics if `component_id` is not registered in this world
+ /// Panics if `component_id` is not registered in this world
#[inline]
pub(crate) fn initialize_non_send_internal(
&mut self,
@@ -2085,6 +2085,20 @@ impl World {
self.storages.resources.clear();
self.storages.non_send_resources.clear();
}
+
+ /// Initializes all of the components in the given [`Bundle`] and returns both the component
+ /// ids and the bundle id.
+ ///
+ /// This is largely equivalent to calling [`init_component`](Self::init_component) on each
+ /// component in the bundle.
+ #[inline]
+ pub fn init_bundle(&mut self) -> &BundleInfo {
+ let id = self
+ .bundles
+ .init_info::(&mut self.components, &mut self.storages);
+ // SAFETY: We just initialised the bundle so its id should definitely be valid.
+ unsafe { self.bundles.get(id).debug_checked_unwrap() }
+ }
}
impl World {
diff --git a/crates/bevy_encase_derive/Cargo.toml b/crates/bevy_encase_derive/Cargo.toml
index d4b4b0a6ff4f3..ed50b8da959f1 100644
--- a/crates/bevy_encase_derive/Cargo.toml
+++ b/crates/bevy_encase_derive/Cargo.toml
@@ -17,3 +17,7 @@ encase_derive_impl = "0.7"
[lints]
workspace = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
+all-features = true
diff --git a/crates/bevy_encase_derive/src/lib.rs b/crates/bevy_encase_derive/src/lib.rs
index e09bc4b247d1a..1fc888a61c8ae 100644
--- a/crates/bevy_encase_derive/src/lib.rs
+++ b/crates/bevy_encase_derive/src/lib.rs
@@ -1,5 +1,6 @@
// FIXME(3492): remove once docs are ready
#![allow(missing_docs)]
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use bevy_macro_utils::BevyManifest;
use encase_derive_impl::{implement, syn};
diff --git a/crates/bevy_gilrs/Cargo.toml b/crates/bevy_gilrs/Cargo.toml
index bf0bd644abd26..ad98c34040016 100644
--- a/crates/bevy_gilrs/Cargo.toml
+++ b/crates/bevy_gilrs/Cargo.toml
@@ -22,3 +22,7 @@ thiserror = "1.0"
[lints]
workspace = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
+all-features = true
diff --git a/crates/bevy_gilrs/src/lib.rs b/crates/bevy_gilrs/src/lib.rs
index dad8efe744a05..bd1ec09a2ae95 100644
--- a/crates/bevy_gilrs/src/lib.rs
+++ b/crates/bevy_gilrs/src/lib.rs
@@ -1,3 +1,5 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! Systems and type definitions for gamepad handling in Bevy.
//!
//! This crate is built on top of [GilRs](gilrs), a library
diff --git a/crates/bevy_gizmos/Cargo.toml b/crates/bevy_gizmos/Cargo.toml
index 8b5bf14229eba..039151b1612c7 100644
--- a/crates/bevy_gizmos/Cargo.toml
+++ b/crates/bevy_gizmos/Cargo.toml
@@ -34,4 +34,5 @@ bytemuck = "1.0"
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_gizmos/macros/Cargo.toml b/crates/bevy_gizmos/macros/Cargo.toml
index d4cf3e3ad0828..dad07b319cae2 100644
--- a/crates/bevy_gizmos/macros/Cargo.toml
+++ b/crates/bevy_gizmos/macros/Cargo.toml
@@ -11,8 +11,6 @@ keywords = ["bevy"]
[lib]
proc-macro = true
-[lints]
-workspace = true
[dependencies]
bevy_macro_utils = { path = "../../bevy_macro_utils", version = "0.14.0-dev" }
@@ -20,3 +18,10 @@ bevy_macro_utils = { path = "../../bevy_macro_utils", version = "0.14.0-dev" }
syn = "2.0"
proc-macro2 = "1.0"
quote = "1.0"
+
+[lints]
+workspace = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
+all-features = true
diff --git a/crates/bevy_gizmos/macros/src/lib.rs b/crates/bevy_gizmos/macros/src/lib.rs
index eb2c598c90806..adce45a4d0e2a 100644
--- a/crates/bevy_gizmos/macros/src/lib.rs
+++ b/crates/bevy_gizmos/macros/src/lib.rs
@@ -1,3 +1,5 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! Derive implementations for `bevy_gizmos`.
use bevy_macro_utils::BevyManifest;
diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs
index 9163a12bf669a..36d0a5520a61b 100755
--- a/crates/bevy_gizmos/src/lib.rs
+++ b/crates/bevy_gizmos/src/lib.rs
@@ -1,3 +1,5 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! This crate adds an immediate mode drawing api to Bevy for visual debugging.
//!
//! # Example
@@ -13,7 +15,6 @@
//! ```
//!
//! See the documentation on [Gizmos](crate::gizmos::Gizmos) for more examples.
-#![cfg_attr(docsrs, feature(doc_auto_cfg))]
/// System set label for the systems handling the rendering of gizmos.
#[derive(SystemSet, Clone, Debug, Hash, PartialEq, Eq)]
diff --git a/crates/bevy_gltf/Cargo.toml b/crates/bevy_gltf/Cargo.toml
index a7f94ef82d217..3fc387902f2c8 100644
--- a/crates/bevy_gltf/Cargo.toml
+++ b/crates/bevy_gltf/Cargo.toml
@@ -60,4 +60,5 @@ smallvec = "1.11"
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_gltf/src/lib.rs b/crates/bevy_gltf/src/lib.rs
index de4751a69767d..a2fce065df8a9 100644
--- a/crates/bevy_gltf/src/lib.rs
+++ b/crates/bevy_gltf/src/lib.rs
@@ -1,8 +1,9 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! Plugin providing an [`AssetLoader`](bevy_asset::AssetLoader) and type definitions
//! for loading glTF 2.0 (a standard 3D scene definition format) files in Bevy.
//!
//! The [glTF 2.0 specification](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html) defines the format of the glTF files.
-#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#[cfg(feature = "bevy_animation")]
use bevy_animation::AnimationClip;
diff --git a/crates/bevy_hierarchy/Cargo.toml b/crates/bevy_hierarchy/Cargo.toml
index 9262ca8336dcc..74a9b434f3e3a 100644
--- a/crates/bevy_hierarchy/Cargo.toml
+++ b/crates/bevy_hierarchy/Cargo.toml
@@ -31,4 +31,5 @@ smallvec = { version = "1.11", features = ["union", "const_generics"] }
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_hierarchy/src/lib.rs b/crates/bevy_hierarchy/src/lib.rs
index 464acada7ddf1..9ef22a7ab5547 100644
--- a/crates/bevy_hierarchy/src/lib.rs
+++ b/crates/bevy_hierarchy/src/lib.rs
@@ -1,3 +1,5 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! Parent-child relationships for Bevy entities.
//!
//! You should use the tools in this crate
@@ -44,7 +46,6 @@
//! [plugin]: HierarchyPlugin
//! [query extension methods]: HierarchyQueryExt
//! [world]: BuildWorldChildren
-#![cfg_attr(docsrs, feature(doc_auto_cfg))]
mod components;
pub use components::*;
diff --git a/crates/bevy_input/Cargo.toml b/crates/bevy_input/Cargo.toml
index fbad74b9d5f88..d696e208f1fad 100644
--- a/crates/bevy_input/Cargo.toml
+++ b/crates/bevy_input/Cargo.toml
@@ -32,4 +32,5 @@ smol_str = "0.2"
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_input/src/button_input.rs b/crates/bevy_input/src/button_input.rs
index 821281293a07c..d4d4aca2f9b97 100644
--- a/crates/bevy_input/src/button_input.rs
+++ b/crates/bevy_input/src/button_input.rs
@@ -143,12 +143,14 @@ where
self.just_released.extend(self.pressed.drain());
}
- /// Returns `true` if the `input` has just been pressed.
+ /// Returns `true` if the `input` has been pressed during the current frame.
+ ///
+ /// Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_released`].
pub fn just_pressed(&self, input: T) -> bool {
self.just_pressed.contains(&input)
}
- /// Returns `true` if any item in `inputs` has just been pressed.
+ /// Returns `true` if any item in `inputs` has been pressed during the current frame.
pub fn any_just_pressed(&self, inputs: impl IntoIterator) -> bool {
inputs.into_iter().any(|it| self.just_pressed(it))
}
@@ -160,7 +162,9 @@ where
self.just_pressed.remove(&input)
}
- /// Returns `true` if the `input` has just been released.
+ /// Returns `true` if the `input` has been released during the current frame.
+ ///
+ /// Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_pressed`].
pub fn just_released(&self, input: T) -> bool {
self.just_released.contains(&input)
}
@@ -207,11 +211,15 @@ where
}
/// An iterator visiting every just pressed input in arbitrary order.
+ ///
+ /// Note: Returned elements do not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_released`].
pub fn get_just_pressed(&self) -> impl ExactSizeIterator {
self.just_pressed.iter()
}
/// An iterator visiting every just released input in arbitrary order.
+ ///
+ /// Note: Returned elements do not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_pressed`].
pub fn get_just_released(&self) -> impl ExactSizeIterator {
self.just_released.iter()
}
diff --git a/crates/bevy_input/src/lib.rs b/crates/bevy_input/src/lib.rs
index 489e12b2f40bb..f2bd0d5f1e6c2 100644
--- a/crates/bevy_input/src/lib.rs
+++ b/crates/bevy_input/src/lib.rs
@@ -1,9 +1,10 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! Input functionality for the [Bevy game engine](https://bevyengine.org/).
//!
//! # Supported input devices
//!
//! `bevy` currently supports keyboard, mouse, gamepad, and touch inputs.
-#![cfg_attr(docsrs, feature(doc_auto_cfg))]
mod axis;
mod button_input;
diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml
index fc7eb39ff1ae9..1978d2b747038 100644
--- a/crates/bevy_internal/Cargo.toml
+++ b/crates/bevy_internal/Cargo.toml
@@ -73,6 +73,7 @@ serialize = [
"bevy_math/serialize",
"bevy_scene?/serialize",
"bevy_ui?/serialize",
+ "bevy_color?/serialize",
]
multi-threaded = [
"bevy_asset?/multi-threaded",
@@ -207,3 +208,7 @@ bevy_dev_tools = { path = "../bevy_dev_tools", optional = true, version = "0.14.
[lints]
workspace = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
+all-features = true
diff --git a/crates/bevy_internal/src/lib.rs b/crates/bevy_internal/src/lib.rs
index e7a46f246c808..434755f9c124f 100644
--- a/crates/bevy_internal/src/lib.rs
+++ b/crates/bevy_internal/src/lib.rs
@@ -1,3 +1,5 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! This module is separated into its own crate to enable simple dynamic linking for Bevy, and should not be used directly
/// `use bevy::prelude::*;` to import common components, bundles, and plugins.
diff --git a/crates/bevy_log/Cargo.toml b/crates/bevy_log/Cargo.toml
index eaf53d1f6cdeb..33cee7bea4ef5 100644
--- a/crates/bevy_log/Cargo.toml
+++ b/crates/bevy_log/Cargo.toml
@@ -40,4 +40,5 @@ tracing-wasm = "0.2.1"
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs
index b6576acb172d9..b4c9a34f6765e 100644
--- a/crates/bevy_log/src/lib.rs
+++ b/crates/bevy_log/src/lib.rs
@@ -1,3 +1,5 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! This crate provides logging functions and configuration for [Bevy](https://bevyengine.org)
//! apps, and automatically configures platform specific log handlers (i.e. WASM or Android).
//!
@@ -9,7 +11,6 @@
//!
//! For more fine-tuned control over logging behavior, set up the [`LogPlugin`] or
//! `DefaultPlugins` during app initialization.
-#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#[cfg(feature = "trace")]
use std::panic;
diff --git a/crates/bevy_macro_utils/Cargo.toml b/crates/bevy_macro_utils/Cargo.toml
index 6dc67396bb18b..408716edd4f62 100644
--- a/crates/bevy_macro_utils/Cargo.toml
+++ b/crates/bevy_macro_utils/Cargo.toml
@@ -19,3 +19,7 @@ proc-macro2 = "1.0"
[lints]
workspace = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
+all-features = true
diff --git a/crates/bevy_macro_utils/src/lib.rs b/crates/bevy_macro_utils/src/lib.rs
index 443313f8e87bd..535d61a09fc57 100644
--- a/crates/bevy_macro_utils/src/lib.rs
+++ b/crates/bevy_macro_utils/src/lib.rs
@@ -1,4 +1,6 @@
#![deny(unsafe_code)]
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! A collection of helper types and functions for working on macros within the Bevy ecosystem.
extern crate proc_macro;
diff --git a/crates/bevy_math/Cargo.toml b/crates/bevy_math/Cargo.toml
index 3423759ebec8c..28ab5d1cd321b 100644
--- a/crates/bevy_math/Cargo.toml
+++ b/crates/bevy_math/Cargo.toml
@@ -45,4 +45,5 @@ rand = ["dep:rand"]
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_math/src/lib.rs b/crates/bevy_math/src/lib.rs
index 0d76500703818..4698604c8cf34 100644
--- a/crates/bevy_math/src/lib.rs
+++ b/crates/bevy_math/src/lib.rs
@@ -1,9 +1,10 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! Provides math types and functionality for the Bevy game engine.
//!
//! The commonly used types are vectors like [`Vec2`] and [`Vec3`],
//! matrices like [`Mat2`], [`Mat3`] and [`Mat4`] and orientation representations
//! like [`Quat`].
-#![cfg_attr(docsrs, feature(doc_auto_cfg))]
mod affine3;
mod aspect_ratio;
diff --git a/crates/bevy_mikktspace/Cargo.toml b/crates/bevy_mikktspace/Cargo.toml
index 78f66e821a82e..9119e80a83ab6 100644
--- a/crates/bevy_mikktspace/Cargo.toml
+++ b/crates/bevy_mikktspace/Cargo.toml
@@ -22,3 +22,7 @@ name = "generate"
[lints]
workspace = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
+all-features = true
diff --git a/crates/bevy_mikktspace/src/lib.rs b/crates/bevy_mikktspace/src/lib.rs
index cbf2c0c7ad833..5f37ab2effb8a 100644
--- a/crates/bevy_mikktspace/src/lib.rs
+++ b/crates/bevy_mikktspace/src/lib.rs
@@ -6,6 +6,7 @@
)]
// FIXME(3492): remove once docs are ready
#![allow(missing_docs)]
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use glam::{Vec2, Vec3};
diff --git a/crates/bevy_panic_handler/Cargo.toml b/crates/bevy_panic_handler/Cargo.toml
index 24b96de3c2a4a..5a99d2bd338be 100644
--- a/crates/bevy_panic_handler/Cargo.toml
+++ b/crates/bevy_panic_handler/Cargo.toml
@@ -20,4 +20,5 @@ console_error_panic_hook = "0.1.6"
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_panic_handler/src/lib.rs b/crates/bevy_panic_handler/src/lib.rs
index 8e3705980de62..dec5c000a7413 100644
--- a/crates/bevy_panic_handler/src/lib.rs
+++ b/crates/bevy_panic_handler/src/lib.rs
@@ -1,3 +1,5 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! This crate provides panic handlers for [Bevy](https://bevyengine.org)
//! apps, and automatically configures platform specifics (i.e. WASM or Android).
//!
@@ -5,7 +7,6 @@
//!
//! For more fine-tuned control over panic behavior, disable the [`PanicHandlerPlugin`] or
//! `DefaultPlugins` during app initialization.
-#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use bevy_app::{App, Plugin};
diff --git a/crates/bevy_pbr/Cargo.toml b/crates/bevy_pbr/Cargo.toml
index 0b148fc2729bd..3bf23e9123d9c 100644
--- a/crates/bevy_pbr/Cargo.toml
+++ b/crates/bevy_pbr/Cargo.toml
@@ -46,4 +46,5 @@ nonmax = "0.5"
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_pbr/src/light/directional_light.rs b/crates/bevy_pbr/src/light/directional_light.rs
new file mode 100644
index 0000000000000..9c74971ca15a5
--- /dev/null
+++ b/crates/bevy_pbr/src/light/directional_light.rs
@@ -0,0 +1,83 @@
+use super::*;
+
+/// A Directional light.
+///
+/// Directional lights don't exist in reality but they are a good
+/// approximation for light sources VERY far away, like the sun or
+/// the moon.
+///
+/// The light shines along the forward direction of the entity's transform. With a default transform
+/// this would be along the negative-Z axis.
+///
+/// Valid values for `illuminance` are:
+///
+/// | Illuminance (lux) | Surfaces illuminated by |
+/// |-------------------|------------------------------------------------|
+/// | 0.0001 | Moonless, overcast night sky (starlight) |
+/// | 0.002 | Moonless clear night sky with airglow |
+/// | 0.05–0.3 | Full moon on a clear night |
+/// | 3.4 | Dark limit of civil twilight under a clear sky |
+/// | 20–50 | Public areas with dark surroundings |
+/// | 50 | Family living room lights |
+/// | 80 | Office building hallway/toilet lighting |
+/// | 100 | Very dark overcast day |
+/// | 150 | Train station platforms |
+/// | 320–500 | Office lighting |
+/// | 400 | Sunrise or sunset on a clear day. |
+/// | 1000 | Overcast day; typical TV studio lighting |
+/// | 10,000–25,000 | Full daylight (not direct sun) |
+/// | 32,000–100,000 | Direct sunlight |
+///
+/// Source: [Wikipedia](https://en.wikipedia.org/wiki/Lux)
+///
+/// ## Shadows
+///
+/// To enable shadows, set the `shadows_enabled` property to `true`.
+///
+/// Shadows are produced via [cascaded shadow maps](https://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf).
+///
+/// To modify the cascade set up, such as the number of cascades or the maximum shadow distance,
+/// change the [`CascadeShadowConfig`] component of the [`DirectionalLightBundle`].
+///
+/// To control the resolution of the shadow maps, use the [`DirectionalLightShadowMap`] resource:
+///
+/// ```
+/// # use bevy_app::prelude::*;
+/// # use bevy_pbr::DirectionalLightShadowMap;
+/// App::new()
+/// .insert_resource(DirectionalLightShadowMap { size: 2048 });
+/// ```
+#[derive(Component, Debug, Clone, Reflect)]
+#[reflect(Component, Default)]
+pub struct DirectionalLight {
+ pub color: Color,
+ /// Illuminance in lux (lumens per square meter), representing the amount of
+ /// light projected onto surfaces by this light source. Lux is used here
+ /// instead of lumens because a directional light illuminates all surfaces
+ /// more-or-less the same way (depending on the angle of incidence). Lumens
+ /// can only be specified for light sources which emit light from a specific
+ /// area.
+ pub illuminance: f32,
+ pub shadows_enabled: bool,
+ pub shadow_depth_bias: f32,
+ /// A bias applied along the direction of the fragment's surface normal. It is scaled to the
+ /// shadow map's texel size so that it is automatically adjusted to the orthographic projection.
+ pub shadow_normal_bias: f32,
+}
+
+impl Default for DirectionalLight {
+ fn default() -> Self {
+ DirectionalLight {
+ color: Color::WHITE,
+ illuminance: light_consts::lux::AMBIENT_DAYLIGHT,
+ shadows_enabled: false,
+ shadow_depth_bias: Self::DEFAULT_SHADOW_DEPTH_BIAS,
+ shadow_normal_bias: Self::DEFAULT_SHADOW_NORMAL_BIAS,
+ }
+ }
+}
+
+impl DirectionalLight {
+ pub const DEFAULT_SHADOW_DEPTH_BIAS: f32 = 0.02;
+ pub const DEFAULT_SHADOW_NORMAL_BIAS: f32 = 1.8;
+}
diff --git a/crates/bevy_pbr/src/light/mod.rs b/crates/bevy_pbr/src/light/mod.rs
index 5d6be4fcf48d3..c73dcaf525b2d 100644
--- a/crates/bevy_pbr/src/light/mod.rs
+++ b/crates/bevy_pbr/src/light/mod.rs
@@ -22,6 +22,12 @@ use crate::*;
mod ambient_light;
pub use ambient_light::AmbientLight;
+mod point_light;
+pub use point_light::PointLight;
+mod spot_light;
+pub use spot_light::SpotLight;
+mod directional_light;
+pub use directional_light::DirectionalLight;
/// Constants for operating with the light units: lumens, and lux.
pub mod light_consts {
@@ -80,61 +86,6 @@ pub mod light_consts {
}
}
-/// A light that emits light in all directions from a central point.
-///
-/// Real-world values for `intensity` (luminous power in lumens) based on the electrical power
-/// consumption of the type of real-world light are:
-///
-/// | Luminous Power (lumen) (i.e. the intensity member) | Incandescent non-halogen (Watts) | Incandescent halogen (Watts) | Compact fluorescent (Watts) | LED (Watts |
-/// |------|-----|----|--------|-------|
-/// | 200 | 25 | | 3-5 | 3 |
-/// | 450 | 40 | 29 | 9-11 | 5-8 |
-/// | 800 | 60 | | 13-15 | 8-12 |
-/// | 1100 | 75 | 53 | 18-20 | 10-16 |
-/// | 1600 | 100 | 72 | 24-28 | 14-17 |
-/// | 2400 | 150 | | 30-52 | 24-30 |
-/// | 3100 | 200 | | 49-75 | 32 |
-/// | 4000 | 300 | | 75-100 | 40.5 |
-///
-/// Source: [Wikipedia](https://en.wikipedia.org/wiki/Lumen_(unit)#Lighting)
-#[derive(Component, Debug, Clone, Copy, Reflect)]
-#[reflect(Component, Default)]
-pub struct PointLight {
- pub color: Color,
- /// Luminous power in lumens, representing the amount of light emitted by this source in all directions.
- pub intensity: f32,
- pub range: f32,
- pub radius: f32,
- pub shadows_enabled: bool,
- pub shadow_depth_bias: f32,
- /// A bias applied along the direction of the fragment's surface normal. It is scaled to the
- /// shadow map's texel size so that it can be small close to the camera and gets larger further
- /// away.
- pub shadow_normal_bias: f32,
-}
-
-impl Default for PointLight {
- fn default() -> Self {
- PointLight {
- color: Color::WHITE,
- // 1,000,000 lumens is a very large "cinema light" capable of registering brightly at Bevy's
- // default "very overcast day" exposure level. For "indoor lighting" with a lower exposure,
- // this would be way too bright.
- intensity: 1_000_000.0,
- range: 20.0,
- radius: 0.0,
- shadows_enabled: false,
- shadow_depth_bias: Self::DEFAULT_SHADOW_DEPTH_BIAS,
- shadow_normal_bias: Self::DEFAULT_SHADOW_NORMAL_BIAS,
- }
- }
-}
-
-impl PointLight {
- pub const DEFAULT_SHADOW_DEPTH_BIAS: f32 = 0.02;
- pub const DEFAULT_SHADOW_NORMAL_BIAS: f32 = 0.6;
-}
-
#[derive(Resource, Clone, Debug, Reflect)]
#[reflect(Resource)]
pub struct PointLightShadowMap {
@@ -147,144 +98,6 @@ impl Default for PointLightShadowMap {
}
}
-/// A light that emits light in a given direction from a central point.
-/// Behaves like a point light in a perfectly absorbent housing that
-/// shines light only in a given direction. The direction is taken from
-/// the transform, and can be specified with [`Transform::looking_at`](Transform::looking_at).
-#[derive(Component, Debug, Clone, Copy, Reflect)]
-#[reflect(Component, Default)]
-pub struct SpotLight {
- pub color: Color,
- /// Luminous power in lumens, representing the amount of light emitted by this source in all directions.
- pub intensity: f32,
- pub range: f32,
- pub radius: f32,
- pub shadows_enabled: bool,
- pub shadow_depth_bias: f32,
- /// A bias applied along the direction of the fragment's surface normal. It is scaled to the
- /// shadow map's texel size so that it can be small close to the camera and gets larger further
- /// away.
- pub shadow_normal_bias: f32,
- /// Angle defining the distance from the spot light direction to the outer limit
- /// of the light's cone of effect.
- /// `outer_angle` should be < `PI / 2.0`.
- /// `PI / 2.0` defines a hemispherical spot light, but shadows become very blocky as the angle
- /// approaches this limit.
- pub outer_angle: f32,
- /// Angle defining the distance from the spot light direction to the inner limit
- /// of the light's cone of effect.
- /// Light is attenuated from `inner_angle` to `outer_angle` to give a smooth falloff.
- /// `inner_angle` should be <= `outer_angle`
- pub inner_angle: f32,
-}
-
-impl SpotLight {
- pub const DEFAULT_SHADOW_DEPTH_BIAS: f32 = 0.02;
- pub const DEFAULT_SHADOW_NORMAL_BIAS: f32 = 1.8;
-}
-
-impl Default for SpotLight {
- fn default() -> Self {
- // a quarter arc attenuating from the center
- Self {
- color: Color::WHITE,
- // 1,000,000 lumens is a very large "cinema light" capable of registering brightly at Bevy's
- // default "very overcast day" exposure level. For "indoor lighting" with a lower exposure,
- // this would be way too bright.
- intensity: 1_000_000.0,
- range: 20.0,
- radius: 0.0,
- shadows_enabled: false,
- shadow_depth_bias: Self::DEFAULT_SHADOW_DEPTH_BIAS,
- shadow_normal_bias: Self::DEFAULT_SHADOW_NORMAL_BIAS,
- inner_angle: 0.0,
- outer_angle: std::f32::consts::FRAC_PI_4,
- }
- }
-}
-
-/// A Directional light.
-///
-/// Directional lights don't exist in reality but they are a good
-/// approximation for light sources VERY far away, like the sun or
-/// the moon.
-///
-/// The light shines along the forward direction of the entity's transform. With a default transform
-/// this would be along the negative-Z axis.
-///
-/// Valid values for `illuminance` are:
-///
-/// | Illuminance (lux) | Surfaces illuminated by |
-/// |-------------------|------------------------------------------------|
-/// | 0.0001 | Moonless, overcast night sky (starlight) |
-/// | 0.002 | Moonless clear night sky with airglow |
-/// | 0.05–0.3 | Full moon on a clear night |
-/// | 3.4 | Dark limit of civil twilight under a clear sky |
-/// | 20–50 | Public areas with dark surroundings |
-/// | 50 | Family living room lights |
-/// | 80 | Office building hallway/toilet lighting |
-/// | 100 | Very dark overcast day |
-/// | 150 | Train station platforms |
-/// | 320–500 | Office lighting |
-/// | 400 | Sunrise or sunset on a clear day. |
-/// | 1000 | Overcast day; typical TV studio lighting |
-/// | 10,000–25,000 | Full daylight (not direct sun) |
-/// | 32,000–100,000 | Direct sunlight |
-///
-/// Source: [Wikipedia](https://en.wikipedia.org/wiki/Lux)
-///
-/// ## Shadows
-///
-/// To enable shadows, set the `shadows_enabled` property to `true`.
-///
-/// Shadows are produced via [cascaded shadow maps](https://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf).
-///
-/// To modify the cascade set up, such as the number of cascades or the maximum shadow distance,
-/// change the [`CascadeShadowConfig`] component of the [`DirectionalLightBundle`].
-///
-/// To control the resolution of the shadow maps, use the [`DirectionalLightShadowMap`] resource:
-///
-/// ```
-/// # use bevy_app::prelude::*;
-/// # use bevy_pbr::DirectionalLightShadowMap;
-/// App::new()
-/// .insert_resource(DirectionalLightShadowMap { size: 2048 });
-/// ```
-#[derive(Component, Debug, Clone, Reflect)]
-#[reflect(Component, Default)]
-pub struct DirectionalLight {
- pub color: Color,
- /// Illuminance in lux (lumens per square meter), representing the amount of
- /// light projected onto surfaces by this light source. Lux is used here
- /// instead of lumens because a directional light illuminates all surfaces
- /// more-or-less the same way (depending on the angle of incidence). Lumens
- /// can only be specified for light sources which emit light from a specific
- /// area.
- pub illuminance: f32,
- pub shadows_enabled: bool,
- pub shadow_depth_bias: f32,
- /// A bias applied along the direction of the fragment's surface normal. It is scaled to the
- /// shadow map's texel size so that it is automatically adjusted to the orthographic projection.
- pub shadow_normal_bias: f32,
-}
-
-impl Default for DirectionalLight {
- fn default() -> Self {
- DirectionalLight {
- color: Color::WHITE,
- illuminance: light_consts::lux::AMBIENT_DAYLIGHT,
- shadows_enabled: false,
- shadow_depth_bias: Self::DEFAULT_SHADOW_DEPTH_BIAS,
- shadow_normal_bias: Self::DEFAULT_SHADOW_NORMAL_BIAS,
- }
- }
-}
-
-impl DirectionalLight {
- pub const DEFAULT_SHADOW_DEPTH_BIAS: f32 = 0.02;
- pub const DEFAULT_SHADOW_NORMAL_BIAS: f32 = 1.8;
-}
-
/// Controls the resolution of [`DirectionalLight`] shadow maps.
#[derive(Resource, Clone, Debug, Reflect)]
#[reflect(Resource)]
diff --git a/crates/bevy_pbr/src/light/point_light.rs b/crates/bevy_pbr/src/light/point_light.rs
new file mode 100644
index 0000000000000..6ff5d39e4e8f1
--- /dev/null
+++ b/crates/bevy_pbr/src/light/point_light.rs
@@ -0,0 +1,56 @@
+use super::*;
+
+/// A light that emits light in all directions from a central point.
+///
+/// Real-world values for `intensity` (luminous power in lumens) based on the electrical power
+/// consumption of the type of real-world light are:
+///
+/// | Luminous Power (lumen) (i.e. the intensity member) | Incandescent non-halogen (Watts) | Incandescent halogen (Watts) | Compact fluorescent (Watts) | LED (Watts |
+/// |------|-----|----|--------|-------|
+/// | 200 | 25 | | 3-5 | 3 |
+/// | 450 | 40 | 29 | 9-11 | 5-8 |
+/// | 800 | 60 | | 13-15 | 8-12 |
+/// | 1100 | 75 | 53 | 18-20 | 10-16 |
+/// | 1600 | 100 | 72 | 24-28 | 14-17 |
+/// | 2400 | 150 | | 30-52 | 24-30 |
+/// | 3100 | 200 | | 49-75 | 32 |
+/// | 4000 | 300 | | 75-100 | 40.5 |
+///
+/// Source: [Wikipedia](https://en.wikipedia.org/wiki/Lumen_(unit)#Lighting)
+#[derive(Component, Debug, Clone, Copy, Reflect)]
+#[reflect(Component, Default)]
+pub struct PointLight {
+ pub color: Color,
+ /// Luminous power in lumens, representing the amount of light emitted by this source in all directions.
+ pub intensity: f32,
+ pub range: f32,
+ pub radius: f32,
+ pub shadows_enabled: bool,
+ pub shadow_depth_bias: f32,
+ /// A bias applied along the direction of the fragment's surface normal. It is scaled to the
+ /// shadow map's texel size so that it can be small close to the camera and gets larger further
+ /// away.
+ pub shadow_normal_bias: f32,
+}
+
+impl Default for PointLight {
+ fn default() -> Self {
+ PointLight {
+ color: Color::WHITE,
+ // 1,000,000 lumens is a very large "cinema light" capable of registering brightly at Bevy's
+ // default "very overcast day" exposure level. For "indoor lighting" with a lower exposure,
+ // this would be way too bright.
+ intensity: 1_000_000.0,
+ range: 20.0,
+ radius: 0.0,
+ shadows_enabled: false,
+ shadow_depth_bias: Self::DEFAULT_SHADOW_DEPTH_BIAS,
+ shadow_normal_bias: Self::DEFAULT_SHADOW_NORMAL_BIAS,
+ }
+ }
+}
+
+impl PointLight {
+ pub const DEFAULT_SHADOW_DEPTH_BIAS: f32 = 0.02;
+ pub const DEFAULT_SHADOW_NORMAL_BIAS: f32 = 0.6;
+}
diff --git a/crates/bevy_pbr/src/light/spot_light.rs b/crates/bevy_pbr/src/light/spot_light.rs
new file mode 100644
index 0000000000000..ab34196ff03fb
--- /dev/null
+++ b/crates/bevy_pbr/src/light/spot_light.rs
@@ -0,0 +1,57 @@
+use super::*;
+
+/// A light that emits light in a given direction from a central point.
+/// Behaves like a point light in a perfectly absorbent housing that
+/// shines light only in a given direction. The direction is taken from
+/// the transform, and can be specified with [`Transform::looking_at`](Transform::looking_at).
+#[derive(Component, Debug, Clone, Copy, Reflect)]
+#[reflect(Component, Default)]
+pub struct SpotLight {
+ pub color: Color,
+ /// Luminous power in lumens, representing the amount of light emitted by this source in all directions.
+ pub intensity: f32,
+ pub range: f32,
+ pub radius: f32,
+ pub shadows_enabled: bool,
+ pub shadow_depth_bias: f32,
+ /// A bias applied along the direction of the fragment's surface normal. It is scaled to the
+ /// shadow map's texel size so that it can be small close to the camera and gets larger further
+ /// away.
+ pub shadow_normal_bias: f32,
+ /// Angle defining the distance from the spot light direction to the outer limit
+ /// of the light's cone of effect.
+ /// `outer_angle` should be < `PI / 2.0`.
+ /// `PI / 2.0` defines a hemispherical spot light, but shadows become very blocky as the angle
+ /// approaches this limit.
+ pub outer_angle: f32,
+ /// Angle defining the distance from the spot light direction to the inner limit
+ /// of the light's cone of effect.
+ /// Light is attenuated from `inner_angle` to `outer_angle` to give a smooth falloff.
+ /// `inner_angle` should be <= `outer_angle`
+ pub inner_angle: f32,
+}
+
+impl SpotLight {
+ pub const DEFAULT_SHADOW_DEPTH_BIAS: f32 = 0.02;
+ pub const DEFAULT_SHADOW_NORMAL_BIAS: f32 = 1.8;
+}
+
+impl Default for SpotLight {
+ fn default() -> Self {
+ // a quarter arc attenuating from the center
+ Self {
+ color: Color::WHITE,
+ // 1,000,000 lumens is a very large "cinema light" capable of registering brightly at Bevy's
+ // default "very overcast day" exposure level. For "indoor lighting" with a lower exposure,
+ // this would be way too bright.
+ intensity: 1_000_000.0,
+ range: 20.0,
+ radius: 0.0,
+ shadows_enabled: false,
+ shadow_depth_bias: Self::DEFAULT_SHADOW_DEPTH_BIAS,
+ shadow_normal_bias: Self::DEFAULT_SHADOW_NORMAL_BIAS,
+ inner_angle: 0.0,
+ outer_angle: std::f32::consts::FRAC_PI_4,
+ }
+ }
+}
diff --git a/crates/bevy_ptr/Cargo.toml b/crates/bevy_ptr/Cargo.toml
index ae443652d11da..d76b911e78945 100644
--- a/crates/bevy_ptr/Cargo.toml
+++ b/crates/bevy_ptr/Cargo.toml
@@ -12,3 +12,7 @@ keywords = ["bevy", "no_std"]
[lints]
workspace = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
+all-features = true
diff --git a/crates/bevy_ptr/src/lib.rs b/crates/bevy_ptr/src/lib.rs
index d6c0322461528..19a34b412d251 100644
--- a/crates/bevy_ptr/src/lib.rs
+++ b/crates/bevy_ptr/src/lib.rs
@@ -1,5 +1,6 @@
#![doc = include_str!("../README.md")]
#![no_std]
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use core::fmt::{self, Formatter, Pointer};
use core::{
diff --git a/crates/bevy_reflect/Cargo.toml b/crates/bevy_reflect/Cargo.toml
index 5cb69dc88edbb..b9fe3e4bb6896 100644
--- a/crates/bevy_reflect/Cargo.toml
+++ b/crates/bevy_reflect/Cargo.toml
@@ -59,4 +59,5 @@ required-features = ["documentation"]
workspace = true
[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
diff --git a/crates/bevy_reflect/bevy_reflect_derive/Cargo.toml b/crates/bevy_reflect/bevy_reflect_derive/Cargo.toml
index e076283ac8453..deee32d6664c4 100644
--- a/crates/bevy_reflect/bevy_reflect_derive/Cargo.toml
+++ b/crates/bevy_reflect/bevy_reflect_derive/Cargo.toml
@@ -26,3 +26,7 @@ uuid = { version = "1.1", features = ["v4"] }
[lints]
workspace = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
+all-features = true
diff --git a/crates/bevy_reflect/bevy_reflect_derive/src/lib.rs b/crates/bevy_reflect/bevy_reflect_derive/src/lib.rs
index 5be3723b7b0d9..743c558dded22 100644
--- a/crates/bevy_reflect/bevy_reflect_derive/src/lib.rs
+++ b/crates/bevy_reflect/bevy_reflect_derive/src/lib.rs
@@ -1,3 +1,5 @@
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+
//! This crate contains macros used by Bevy's `Reflect` API.
//!
//! The main export of this crate is the derive macro for [`Reflect`]. This allows
diff --git a/crates/bevy_reflect/src/impls/std.rs b/crates/bevy_reflect/src/impls/std.rs
index 3b50abb0d9fdf..f81db9d6c7506 100644
--- a/crates/bevy_reflect/src/impls/std.rs
+++ b/crates/bevy_reflect/src/impls/std.rs
@@ -1,17 +1,16 @@
use crate::std_traits::ReflectDefault;
use crate::{self as bevy_reflect, ReflectFromPtr, ReflectFromReflect, ReflectOwned, TypeRegistry};
use crate::{
- impl_type_path, map_apply, map_partial_eq, Array, ArrayInfo, ArrayIter, DynamicEnum,
- DynamicMap, Enum, EnumInfo, FromReflect, FromType, GetTypeRegistration, List, ListInfo,
- ListIter, Map, MapInfo, MapIter, Reflect, ReflectDeserialize, ReflectKind, ReflectMut,
- ReflectRef, ReflectSerialize, TupleVariantInfo, TypeInfo, TypePath, TypeRegistration, Typed,
- UnitVariantInfo, UnnamedField, ValueInfo, VariantFieldIter, VariantInfo, VariantType,
+ impl_type_path, map_apply, map_partial_eq, Array, ArrayInfo, ArrayIter, DynamicMap,
+ FromReflect, FromType, GetTypeRegistration, List, ListInfo, ListIter, Map, MapInfo, MapIter,
+ Reflect, ReflectDeserialize, ReflectKind, ReflectMut, ReflectRef, ReflectSerialize, TypeInfo,
+ TypePath, TypeRegistration, Typed, ValueInfo,
};
use crate::utility::{
reflect_hasher, GenericTypeInfoCell, GenericTypePathCell, NonGenericTypeInfoCell,
};
-use bevy_reflect_derive::impl_reflect_value;
+use bevy_reflect_derive::{impl_reflect, impl_reflect_value};
use std::fmt;
use std::{
any::Any,
@@ -996,252 +995,14 @@ impl GetTypeRegistr
}
}
-impl GetTypeRegistration for Option {
- fn get_type_registration() -> TypeRegistration {
- TypeRegistration::of::