mirror of
https://github.com/bevyengine/bevy
synced 2024-11-21 20:23:28 +00:00
Cargo fmt with unstable features (#1903)
Fresh version of #1670 off the latest main. Mostly fixing documentation wrapping.
This commit is contained in:
parent
30c6ca6166
commit
e4e32598a9
20 changed files with 75 additions and 63 deletions
|
@ -185,9 +185,9 @@ impl AppBuilder {
|
|||
|
||||
/// Adds a new [State] with the given `initial` value.
|
||||
/// This inserts a new `State<T>` resource and adds a new "driver" to [CoreStage::Update].
|
||||
/// Each stage that uses `State<T>` for system run criteria needs a driver. If you need to use your state in a
|
||||
/// different stage, consider using [Self::add_state_to_stage] or manually adding [State::get_driver] to additional stages
|
||||
/// you need it in.
|
||||
/// Each stage that uses `State<T>` for system run criteria needs a driver. If you need to use
|
||||
/// your state in a different stage, consider using [Self::add_state_to_stage] or manually
|
||||
/// adding [State::get_driver] to additional stages you need it in.
|
||||
pub fn add_state<T>(&mut self, initial: T) -> &mut Self
|
||||
where
|
||||
T: Component + Debug + Clone + Eq + Hash,
|
||||
|
@ -197,9 +197,9 @@ impl AppBuilder {
|
|||
|
||||
/// Adds a new [State] with the given `initial` value.
|
||||
/// This inserts a new `State<T>` resource and adds a new "driver" to the given stage.
|
||||
/// Each stage that uses `State<T>` for system run criteria needs a driver. If you need to use your state in
|
||||
/// more than one stage, consider manually adding [State::get_driver] to the stages
|
||||
/// you need it in.
|
||||
/// Each stage that uses `State<T>` for system run criteria needs a driver. If you need to use
|
||||
/// your state in more than one stage, consider manually adding [State::get_driver] to the
|
||||
/// stages you need it in.
|
||||
pub fn add_state_to_stage<T>(&mut self, stage: impl StageLabel, initial: T) -> &mut Self
|
||||
where
|
||||
T: Component + Debug + Clone + Eq + Hash,
|
||||
|
|
|
@ -344,7 +344,8 @@ impl ComponentTicks {
|
|||
}
|
||||
|
||||
/// Manually sets the change tick.
|
||||
/// Usually, this is done automatically via the [`DerefMut`](std::ops::DerefMut) implementation on [`Mut`](crate::world::Mut) or [`ResMut`](crate::system::ResMut) etc.
|
||||
/// Usually, this is done automatically via the [`DerefMut`](std::ops::DerefMut) implementation
|
||||
/// on [`Mut`](crate::world::Mut) or [`ResMut`](crate::system::ResMut) etc.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust,no_run
|
||||
|
|
|
@ -891,8 +891,7 @@ impl Stage for SystemStage {
|
|||
mod tests {
|
||||
use crate::{
|
||||
entity::Entity,
|
||||
query::ChangeTrackers,
|
||||
query::Changed,
|
||||
query::{ChangeTrackers, Changed},
|
||||
schedule::{
|
||||
BoxedSystemLabel, ExclusiveSystemDescriptorCoercion, ParallelSystemDescriptorCoercion,
|
||||
RunCriteria, RunCriteriaDescriptorCoercion, RunCriteriaPiping, ShouldRun,
|
||||
|
|
|
@ -300,7 +300,8 @@ where
|
|||
}
|
||||
|
||||
/// Schedule a state change that replaces the full stack with the given state.
|
||||
/// This will fail if there is a scheduled operation, or if the given `state` matches the current state
|
||||
/// This will fail if there is a scheduled operation, or if the given `state` matches the
|
||||
/// current state
|
||||
pub fn replace(&mut self, state: T) -> Result<(), StateError> {
|
||||
if self.stack.last().unwrap() == &state {
|
||||
return Err(StateError::AlreadyInState);
|
||||
|
@ -314,7 +315,8 @@ where
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Same as [Self::replace], but if there is already a next state, it will be overwritten instead of failing
|
||||
/// Same as [Self::replace], but if there is already a next state, it will be overwritten
|
||||
/// instead of failing
|
||||
pub fn overwrite_replace(&mut self, state: T) -> Result<(), StateError> {
|
||||
if self.stack.last().unwrap() == &state {
|
||||
return Err(StateError::AlreadyInState);
|
||||
|
|
|
@ -328,8 +328,8 @@ impl Table {
|
|||
let available_space = self.capacity - self.len();
|
||||
if available_space < amount {
|
||||
let min_capacity = self.len() + amount;
|
||||
// normally we would check if min_capacity is 0 for the below calculation, but amount > available_space and
|
||||
// available_space > 0, so min_capacity > 1
|
||||
// normally we would check if min_capacity is 0 for the below calculation, but amount >
|
||||
// available_space and available_space > 0, so min_capacity > 1
|
||||
let new_capacity =
|
||||
((min_capacity + self.grow_amount - 1) / self.grow_amount) * self.grow_amount;
|
||||
let reserve_amount = new_capacity - self.len();
|
||||
|
|
|
@ -86,8 +86,8 @@ impl<'a> Commands<'a> {
|
|||
|
||||
/// Creates a new entity with the components contained in `bundle`.
|
||||
///
|
||||
/// This returns an [`EntityCommands`] builder, which enables inserting more components and bundles
|
||||
/// using a "builder pattern".
|
||||
/// This returns an [`EntityCommands`] builder, which enables inserting more components and
|
||||
/// bundles using a "builder pattern".
|
||||
///
|
||||
/// Note that `bundle` is a [`Bundle`], which is a collection of components. [`Bundle`] is
|
||||
/// automatically implemented for tuples of components. You can also create your own bundle
|
||||
|
@ -212,9 +212,9 @@ impl<'a, 'b> EntityCommands<'a, 'b> {
|
|||
/// # Warning
|
||||
///
|
||||
/// It's possible to call this with a bundle, but this is likely not intended and
|
||||
/// [`Self::insert_bundle`] should be used instead. If `with` is called with a bundle, the bundle
|
||||
/// itself will be added as a component instead of the bundles' inner components each being
|
||||
/// added.
|
||||
/// [`Self::insert_bundle`] should be used instead. If `with` is called with a bundle, the
|
||||
/// bundle itself will be added as a component instead of the bundles' inner components each
|
||||
/// being added.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
|
|
@ -51,7 +51,8 @@ impl SystemState {
|
|||
|
||||
/// Conversion trait to turn something into a [`System`].
|
||||
///
|
||||
/// Use this to get a system from a function. Also note that every system implements this trait as well.
|
||||
/// Use this to get a system from a function. Also note that every system implements this trait as
|
||||
/// well.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -106,9 +107,9 @@ pub struct InputMarker;
|
|||
|
||||
/// The [`System`] counter part of an ordinary function.
|
||||
///
|
||||
/// You get this by calling [`IntoSystem::system`] on a function that only accepts [`SystemParam`]s.
|
||||
/// The output of the system becomes the functions return type, while the input becomes the functions
|
||||
/// [`In`] tagged parameter or `()` if no such paramater exists.
|
||||
/// You get this by calling [`IntoSystem::system`] on a function that only accepts
|
||||
/// [`SystemParam`]s. The output of the system becomes the functions return type, while the input
|
||||
/// becomes the functions [`In`] tagged parameter or `()` if no such paramater exists.
|
||||
pub struct FunctionSystem<In, Out, Param, Marker, F>
|
||||
where
|
||||
Param: SystemParam,
|
||||
|
|
|
@ -126,7 +126,8 @@ where
|
|||
|
||||
/// Runs `f` on each query result in parallel using the given task pool.
|
||||
///
|
||||
/// This can only be called for read-only queries, see [`Self::par_for_each_mut`] for write-queries.
|
||||
/// This can only be called for read-only queries, see [`Self::par_for_each_mut`] for
|
||||
/// write-queries.
|
||||
#[inline]
|
||||
pub fn par_for_each(
|
||||
&self,
|
||||
|
@ -270,7 +271,8 @@ where
|
|||
}
|
||||
|
||||
/// Gets a mutable reference to the [`Entity`]'s [`Component`] of the given type. This will fail
|
||||
/// if the entity does not have the given component type or the component does not match the query.
|
||||
/// if the entity does not have the given component type or the component does not match the
|
||||
/// query.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
|
@ -352,7 +354,8 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// Gets the query result if it is only a single result, otherwise returns a [`QuerySingleError`].
|
||||
/// Gets the query result if it is only a single result, otherwise returns a
|
||||
/// [`QuerySingleError`].
|
||||
pub fn single_mut(&mut self) -> Result<<Q::Fetch as Fetch<'_>>::Item, QuerySingleError> {
|
||||
let mut query = self.iter_mut();
|
||||
let first = query.next();
|
||||
|
@ -381,8 +384,8 @@ pub enum QueryComponentError {
|
|||
NoSuchEntity,
|
||||
}
|
||||
|
||||
/// An error that occurs when evaluating a [`Query`] as a single expected resulted via [`Query::single`]
|
||||
/// or [`Query::single_mut`].
|
||||
/// An error that occurs when evaluating a [`Query`] as a single expected resulted via
|
||||
/// [`Query::single`] or [`Query::single_mut`].
|
||||
#[derive(Debug, Error)]
|
||||
pub enum QuerySingleError {
|
||||
#[error("No entities fit the query {0}")]
|
||||
|
|
|
@ -31,7 +31,8 @@ impl SystemId {
|
|||
/// It's possible to specify explicit execution order between specific systems,
|
||||
/// see [SystemDescriptor](crate::schedule::SystemDescriptor).
|
||||
pub trait System: Send + Sync + 'static {
|
||||
/// The system's input. See [`In`](crate::system::In) for [`FunctionSystem`](crate::system::FunctionSystem)s.
|
||||
/// The system's input. See [`In`](crate::system::In) for
|
||||
/// [`FunctionSystem`](crate::system::FunctionSystem)s.
|
||||
type In;
|
||||
/// The system's output.
|
||||
type Out;
|
||||
|
|
|
@ -74,8 +74,8 @@ where
|
|||
self.just_pressed.contains(&input)
|
||||
}
|
||||
|
||||
/// Clear the "just pressed" state of `input`. Future calls to [`Input::just_pressed`] for the given
|
||||
/// input will return false until a new press event occurs.
|
||||
/// Clear the "just pressed" state of `input`. Future calls to [`Input::just_pressed`] for the
|
||||
/// given input will return false until a new press event occurs.
|
||||
/// Returns true if `input` is currently "just pressed"
|
||||
pub fn clear_just_pressed(&mut self, input: T) -> bool {
|
||||
self.just_pressed.remove(&input)
|
||||
|
@ -86,8 +86,8 @@ where
|
|||
self.just_released.contains(&input)
|
||||
}
|
||||
|
||||
/// Clear the "just released" state of `input`. Future calls to [`Input::just_released`] for the given
|
||||
/// input will return false until a new release event occurs.
|
||||
/// Clear the "just released" state of `input`. Future calls to [`Input::just_released`] for the
|
||||
/// given input will return false until a new release event occurs.
|
||||
/// Returns true if `input` is currently "just released"
|
||||
pub fn clear_just_released(&mut self, input: T) -> bool {
|
||||
self.just_released.remove(&input)
|
||||
|
|
|
@ -7,20 +7,20 @@ use bevy_render::{color::Color, renderer::RenderResources, shader::ShaderDefs, t
|
|||
#[derive(Debug, RenderResources, ShaderDefs, TypeUuid)]
|
||||
#[uuid = "dace545e-4bc6-4595-a79d-c224fc694975"]
|
||||
pub struct StandardMaterial {
|
||||
/// Doubles as diffuse albedo for non-metallic, specular for metallic and a mix for everything in between
|
||||
/// If used together with a base_color_texture, this is factored into the final base color
|
||||
/// as `base_color * base_color_texture_value`
|
||||
/// Doubles as diffuse albedo for non-metallic, specular for metallic and a mix for everything
|
||||
/// in between If used together with a base_color_texture, this is factored into the final
|
||||
/// base color as `base_color * base_color_texture_value`
|
||||
pub base_color: Color,
|
||||
#[shader_def]
|
||||
pub base_color_texture: Option<Handle<Texture>>,
|
||||
/// Linear perceptual roughness, clamped to [0.089, 1.0] in the shader
|
||||
/// Defaults to minimum of 0.089
|
||||
/// If used together with a roughness/metallic texture, this is factored into the final base color
|
||||
/// as `roughness * roughness_texture_value`
|
||||
/// If used together with a roughness/metallic texture, this is factored into the final base
|
||||
/// color as `roughness * roughness_texture_value`
|
||||
pub roughness: f32,
|
||||
/// From [0.0, 1.0], dielectric to pure metallic
|
||||
/// If used together with a roughness/metallic texture, this is factored into the final base color
|
||||
/// as `metallic * metallic_texture_value`
|
||||
/// If used together with a roughness/metallic texture, this is factored into the final base
|
||||
/// color as `metallic * metallic_texture_value`
|
||||
pub metallic: f32,
|
||||
/// Specular intensity for non-metals on a linear scale of [0.0, 1.0]
|
||||
/// defaults to 0.5 which is mapped to 4% reflectance in the shader
|
||||
|
@ -51,8 +51,9 @@ impl Default for StandardMaterial {
|
|||
base_color_texture: None,
|
||||
// This is the minimum the roughness is clamped to in shader code
|
||||
// See https://google.github.io/filament/Filament.html#materialsystem/parameterization/
|
||||
// It's the minimum floating point value that won't be rounded down to 0 in the calculations used.
|
||||
// Although technically for 32-bit floats, 0.045 could be used.
|
||||
// It's the minimum floating point value that won't be rounded down to 0 in the
|
||||
// calculations used. Although technically for 32-bit floats, 0.045 could be
|
||||
// used.
|
||||
roughness: 0.089,
|
||||
// Few materials are purely dielectric or metallic
|
||||
// This is just a default for mostly-dielectric
|
||||
|
|
|
@ -24,8 +24,9 @@ pub enum ReflectMut<'a> {
|
|||
/// A reflected rust type.
|
||||
///
|
||||
/// # Safety
|
||||
/// Implementors _must_ ensure that [Reflect::any] and [Reflect::any_mut] both return the `self` value passed in
|
||||
/// If this is not done, [Reflect::downcast] will be UB (and also just logically broken).
|
||||
/// Implementors _must_ ensure that [Reflect::any] and [Reflect::any_mut] both return the `self`
|
||||
/// value passed in If this is not done, [Reflect::downcast] will be UB (and also just logically
|
||||
/// broken).
|
||||
pub unsafe trait Reflect: Any + Send + Sync {
|
||||
fn type_name(&self) -> &str;
|
||||
fn any(&self) -> &dyn Any;
|
||||
|
|
|
@ -25,7 +25,8 @@ pub enum Color {
|
|||
/// Alpha component. [0.0, 1.0]
|
||||
alpha: f32,
|
||||
},
|
||||
/// RGBA color in the Linear sRGB colorspace (often colloquially referred to as "linear", "RGB", or "linear RGB").
|
||||
/// RGBA color in the Linear sRGB colorspace (often colloquially referred to as "linear",
|
||||
/// "RGB", or "linear RGB").
|
||||
RgbaLinear {
|
||||
/// Red component. [0.0, 1.0]
|
||||
red: f32,
|
||||
|
|
|
@ -222,8 +222,8 @@ impl From<&Indices> for IndexFormat {
|
|||
#[uuid = "8ecbac0f-f545-4473-ad43-e1f4243af51e"]
|
||||
pub struct Mesh {
|
||||
primitive_topology: PrimitiveTopology,
|
||||
/// `std::collections::BTreeMap` with all defined vertex attributes (Positions, Normals, ...) for this
|
||||
/// mesh. Attribute name maps to attribute values.
|
||||
/// `std::collections::BTreeMap` with all defined vertex attributes (Positions, Normals, ...)
|
||||
/// for this mesh. Attribute name maps to attribute values.
|
||||
/// Uses a BTreeMap because, unlike HashMap, it has a defined iteration order,
|
||||
/// which allows easy stable VertexBuffers (i.e. same buffer order)
|
||||
attributes: BTreeMap<Cow<'static, str>, VertexAttributeValues>,
|
||||
|
|
|
@ -167,7 +167,8 @@ where
|
|||
}
|
||||
for render_command in draw.render_commands.iter() {
|
||||
commands.push(render_command.clone());
|
||||
// whenever a new pipeline is set, ensure the relevant camera bind groups are set
|
||||
// whenever a new pipeline is set, ensure the relevant camera bind groups
|
||||
// are set
|
||||
if let RenderCommand::SetPipeline { pipeline } = render_command {
|
||||
let bind_groups = pipeline_camera_commands
|
||||
.entry(pipeline.clone_weak())
|
||||
|
|
|
@ -53,9 +53,9 @@ impl Default for Text2dBundle {
|
|||
}
|
||||
}
|
||||
|
||||
/// System for drawing text in a 2D scene via a 2D `OrthographicCameraBundle`. Included in the default
|
||||
/// `TextPlugin`. Position is determined by the `Transform`'s translation, though scale and rotation
|
||||
/// are ignored.
|
||||
/// System for drawing text in a 2D scene via a 2D `OrthographicCameraBundle`. Included in the
|
||||
/// default `TextPlugin`. Position is determined by the `Transform`'s translation, though scale and
|
||||
/// rotation are ignored.
|
||||
pub fn draw_text2d_system(
|
||||
mut context: DrawContext,
|
||||
msaa: Res<Msaa>,
|
||||
|
|
|
@ -169,7 +169,8 @@ fn setup(
|
|||
let mut first_pass_camera = PerspectiveCameraBundle {
|
||||
camera: Camera {
|
||||
name: Some(FIRST_PASS_CAMERA.to_string()),
|
||||
window: WindowId::new(), // otherwise it will use main window size / aspect for calculation of projection matrix
|
||||
window: WindowId::new(), /* otherwise it will use main window size / aspect for
|
||||
* calculation of projection matrix */
|
||||
..Default::default()
|
||||
},
|
||||
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 15.0))
|
||||
|
|
|
@ -84,7 +84,8 @@ fn setup(
|
|||
fragment: Some(shaders.add(Shader::from_glsl(ShaderStage::Fragment, FRAGMENT_SHADER))),
|
||||
}));
|
||||
|
||||
// Add a `RenderResourcesNode` to our `RenderGraph`. This will bind `TimeComponent` to our shader.
|
||||
// Add a `RenderResourcesNode` to our `RenderGraph`. This will bind `TimeComponent` to our
|
||||
// shader.
|
||||
render_graph.add_system_node(
|
||||
"time_uniform",
|
||||
RenderResourcesNode::<TimeUniform>::new(true),
|
||||
|
@ -115,9 +116,9 @@ fn setup(
|
|||
});
|
||||
}
|
||||
|
||||
/// In this system we query for the `TimeComponent` and global `Time` resource, and set `time.seconds_since_startup()`
|
||||
/// as the `value` of the `TimeComponent`. This value will be accessed by the fragment shader and used
|
||||
/// to animate the shader.
|
||||
/// In this system we query for the `TimeComponent` and global `Time` resource, and set
|
||||
/// `time.seconds_since_startup()` as the `value` of the `TimeComponent`. This value will be
|
||||
/// accessed by the fragment shader and used to animate the shader.
|
||||
fn animate_shader(time: Res<Time>, mut query: Query<&mut TimeUniform>) {
|
||||
let mut time_uniform = query.single_mut().unwrap();
|
||||
time_uniform.value = time.seconds_since_startup() as f32;
|
||||
|
|
|
@ -5,7 +5,6 @@ newline_style = "Unix"
|
|||
# Once these features have stabilized, they should be added to the always-enabled options above.
|
||||
# unstable_features = true
|
||||
# imports_granularity = "Crate"
|
||||
#reorder_impl_items = true
|
||||
# wrap_comments = true
|
||||
# comment_width = 100
|
||||
# normalize_comments = true
|
||||
|
|
Loading…
Reference in a new issue