Skip to content

Commit

Permalink
Merge branch 'main' into push-vzxrnylxuozx
Browse files Browse the repository at this point in the history
  • Loading branch information
SpecificProtagonist authored Jan 11, 2025
2 parents edf8299 + 5c0e13f commit d30a104
Show file tree
Hide file tree
Showing 46 changed files with 202 additions and 60 deletions.
12 changes: 10 additions & 2 deletions assets/shaders/custom_ui_material.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@

@fragment
fn fragment(in: UiVertexOutput) -> @location(0) vec4<f32> {
// normalized position relative to the center of the UI node
let r = in.uv - 0.5;

// normalized size of the border closest to the current position
let b = vec2(
select(in.border_widths.x, in.border_widths.y, r.x < 0.),
select(in.border_widths.z, in.border_widths.w, r.y < 0.)
select(in.border_widths.x, in.border_widths.y, 0. < r.x),
select(in.border_widths.z, in.border_widths.w, 0. < r.y)
);

// if the distance to the edge from the current position on any axis
// is less than the border width on that axis then the position is within
// the border and we return the border color
if any(0.5 - b < abs(r)) {
return border_color;
}

// sample the texture at this position if it's to the left of the slider value
// otherwise return a fully transparent color
if in.uv.x < slider {
let output_color = textureSample(material_color_texture, material_color_sampler, in.uv) * color;
return output_color;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_animation/src/animatable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct BlendInput<T> {

/// An animatable value type.
pub trait Animatable: Reflect + Sized + Send + Sync + 'static {
/// Interpolates between `a` and `b` with a interpolation factor of `time`.
/// Interpolates between `a` and `b` with an interpolation factor of `time`.
///
/// The `time` parameter here may not be clamped to the range `[0.0, 1.0]`.
fn interpolate(a: &Self, b: &Self, time: f32) -> Self;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_animation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ pub enum AnimationEvaluationError {
/// An animation that an [`AnimationPlayer`] is currently either playing or was
/// playing, but is presently paused.
///
/// An stopped animation is considered no longer active.
/// A stopped animation is considered no longer active.
#[derive(Debug, Clone, Copy, Reflect)]
pub struct ActiveAnimation {
/// The factor by which the weight from the [`AnimationGraph`] is multiplied.
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ pub enum AppExit {
}

impl AppExit {
/// Creates a [`AppExit::Error`] with a error code of 1.
/// Creates a [`AppExit::Error`] with an error code of 1.
#[must_use]
pub const fn error() -> Self {
Self::Error(NonZero::<u8>::MIN)
Expand Down Expand Up @@ -1733,7 +1733,7 @@ mod tests {

#[test]
fn app_exit_size() {
// There wont be many of them so the size isn't a issue but
// There wont be many of them so the size isn't an issue but
// it's nice they're so small let's keep it that way.
assert_eq!(size_of::<AppExit>(), size_of::<u8>());
}
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_asset/src/asset_changed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<'w, A: AsAssetId> AssetChangeCheck<'w, A> {
}
}

/// Filter that selects entities with a `A` for an asset that changed
/// Filter that selects entities with an `A` for an asset that changed
/// after the system last ran, where `A` is a component that implements
/// [`AsAssetId`].
///
Expand Down Expand Up @@ -114,8 +114,8 @@ impl<'w, A: AsAssetId> AssetChangeCheck<'w, A> {
/// # Performance
///
/// When at least one `A` is updated, this will
/// read a hashmap once per entity with a `A` component. The
/// runtime of the query is proportional to how many entities with a `A`
/// read a hashmap once per entity with an `A` component. The
/// runtime of the query is proportional to how many entities with an `A`
/// it matches.
///
/// If no `A` asset updated since the last time the system ran, then no lookups occur.
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/smaa/smaa.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ const SMAA_CORNER_ROUNDING: u32 = 25u;
// "SMAA Presets".)

/**
* If there is an neighbor edge that has SMAA_LOCAL_CONTRAST_FACTOR times
* If there is a neighbor edge that has SMAA_LOCAL_CONTRAST_FACTOR times
* bigger contrast than current edge, current edge will be discarded.
*
* This allows to eliminate spurious crossing edges, and is based on the fact
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/upscaling/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn prepare_view_upscaling_pipelines(

match blend_state {
None => {
// If we've already seen this output for a camera and it doesn't have a output blend
// If we've already seen this output for a camera and it doesn't have an output blend
// mode configured, default to alpha blend so that we don't accidentally overwrite
// the output texture
if already_seen {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/query/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryIter<'w, 's, D, F> {
}

/// Executes the equivalent of [`Iterator::fold`] over a contiguous segment
/// from an storage.
/// from a storage.
///
/// # Safety
/// - `range` must be in `[0, storage::entity_count)` or None.
Expand Down Expand Up @@ -187,7 +187,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryIter<'w, 's, D, F> {
}

/// Executes the equivalent of [`Iterator::fold`] over a contiguous segment
/// from an table.
/// from a table.
///
/// # Safety
/// - all `rows` must be in `[0, table.entity_count)`.
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/query/world_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub unsafe trait WorldQuery {
/// Fetch [`Self::Item`](`WorldQuery::Item`) for either the given `entity` in the current [`Table`],
/// or for the given `entity` in the current [`Archetype`]. This must always be called after
/// [`WorldQuery::set_table`] with a `table_row` in the range of the current [`Table`] or after
/// [`WorldQuery::set_archetype`] with a `entity` in the current archetype.
/// [`WorldQuery::set_archetype`] with an `entity` in the current archetype.
/// Accesses components registered in [`WorldQuery::update_component_access`].
///
/// # Safety
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ where
///
/// Ordering constraints will be applied between the successive elements.
///
/// If the preceding node on a edge has deferred parameters, a [`ApplyDeferred`](crate::schedule::ApplyDeferred)
/// If the preceding node on an edge has deferred parameters, an [`ApplyDeferred`](crate::schedule::ApplyDeferred)
/// will be inserted on the edge. If this behavior is not desired consider using
/// [`chain_ignore_deferred`](Self::chain_ignore_deferred) instead.
fn chain(self) -> SystemConfigs {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/graph/graph_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub type DiGraph<S = FixedHasher> = Graph<true, S>;
/// `Graph<DIRECTED>` is a graph datastructure using an associative array
/// of its node weights `NodeId`.
///
/// It uses an combined adjacency list and sparse adjacency matrix
/// It uses a combined adjacency list and sparse adjacency matrix
/// representation, using **O(|N| + |E|)** space, and allows testing for edge
/// existence in constant time.
///
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_ecs/src/storage/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ impl TableId {
}
}

/// A opaque newtype for rows in [`Table`]s. Specifies a single row in a specific table.
/// An opaque newtype for rows in [`Table`]s. Specifies a single row in a specific table.
///
/// Values of this type are retrievable from [`Archetype::entity_table_row`] and can be
/// used alongside [`Archetype::table_id`] to fetch the exact table and row where an
/// [`Entity`]'s
/// [`Entity`]'s components are stored.
///
/// Values of this type are only valid so long as entities have not moved around.
/// Adding and removing components from an entity, or despawning it will invalidate
Expand Down Expand Up @@ -183,7 +183,7 @@ impl TableBuilder {
/// A column-oriented [structure-of-arrays] based storage for [`Component`]s of entities
/// in a [`World`].
///
/// Conceptually, a `Table` can be thought of as an `HashMap<ComponentId, Column>`, where
/// Conceptually, a `Table` can be thought of as a `HashMap<ComponentId, Column>`, where
/// each [`ThinColumn`] is a type-erased `Vec<T: Component>`. Each row corresponds to a single entity
/// (i.e. index 3 in Column A and index 3 in Column B point to different components on the same
/// entity). Fetching components from a table involves fetching the associated column for a
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/system/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ unsafe impl<'w, 's, D: QueryData + 'static, F: QueryFilter + 'static>
/// .build_state(&mut world)
/// .build_system(|query: Query<()>| {
/// for _ in &query {
/// // This only includes entities with an `Player` component.
/// // This only includes entities with a `Player` component.
/// }
/// });
///
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gizmos/src/primitives/dim3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ where
Config: GizmoConfigGroup,
Clear: 'static + Send + Sync,
{
/// Set the number of lines used to approximate the top an bottom of the cylinder geometry.
/// Set the number of lines used to approximate the top and bottom of the cylinder geometry.
pub fn resolution(mut self, resolution: u32) -> Self {
self.resolution = resolution;
self
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gizmos/src/primitives/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn single_circle_coordinate(radius: f32, resolution: u32, nth_point:

/// Generates an iterator over the coordinates of a circle.
///
/// The coordinates form a open circle, meaning the first and last points aren't the same.
/// The coordinates form an open circle, meaning the first and last points aren't the same.
///
/// This function creates an iterator that yields the positions of points approximating a
/// circle with the given radius, divided into linear segments. The iterator produces `resolution`
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_gltf/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ fn texture_sampler(texture: &gltf::Texture) -> ImageSamplerDescriptor {
}
}

/// Maps the texture address mode form glTF to wgpu.
/// Maps the texture address mode from glTF to wgpu.
fn texture_address_mode(gltf_address_mode: &WrappingMode) -> ImageAddressMode {
match gltf_address_mode {
WrappingMode::ClampToEdge => ImageAddressMode::ClampToEdge,
Expand All @@ -1814,7 +1814,7 @@ fn texture_address_mode(gltf_address_mode: &WrappingMode) -> ImageAddressMode {
}
}

/// Maps the `primitive_topology` form glTF to `wgpu`.
/// Maps the `primitive_topology` from glTF to `wgpu`.
#[expect(
clippy::result_large_err,
reason = "`GltfError` is only barely past the threshold for large errors."
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_image/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ bevy_color = { path = "../bevy_color", version = "0.16.0-dev", features = [
"serialize",
"wgpu-types",
] }
bevy_math = { path = "../bevy_math", version = "0.16.0-dev" }
bevy_math = { path = "../bevy_math", version = "0.16.0-dev", features = [
"bevy_reflect",
] }
bevy_reflect = { path = "../bevy_reflect", version = "0.16.0-dev", features = [
"bevy",
] }
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_image/src/compressed_image_saver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ impl AssetSaver for CompressedImageSaver {
source_image.init(&image.data, size.x, size.y, 4);

let mut compressor = basis_universal::Compressor::new(4);
#[expect(
unsafe_code,
reason = "The basis-universal compressor cannot be interacted with except through unsafe functions"
)]
// SAFETY: the CompressorParams are "valid" to the best of our knowledge. The basis-universal
// library bindings note that invalid params might produce undefined behavior.
unsafe {
Expand Down
82 changes: 73 additions & 9 deletions crates/bevy_image/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ impl ImageFormat {
#[cfg(feature = "webp")]
ImageFormat::WebP => &["webp"],
// FIXME: https://github.com/rust-lang/rust/issues/129031
#[allow(unreachable_patterns)]
#[expect(
clippy::allow_attributes,
reason = "`unreachable_patterns` may not always lint"
)]
#[allow(
unreachable_patterns,
reason = "The wildcard pattern will be unreachable if all formats are enabled; otherwise, it will be reachable"
)]
_ => &[],
}
}
Expand Down Expand Up @@ -165,13 +172,27 @@ impl ImageFormat {
#[cfg(feature = "webp")]
ImageFormat::WebP => &["image/webp"],
// FIXME: https://github.com/rust-lang/rust/issues/129031
#[allow(unreachable_patterns)]
#[expect(
clippy::allow_attributes,
reason = "`unreachable_patterns` may not always lint"
)]
#[allow(
unreachable_patterns,
reason = "The wildcard pattern will be unreachable if all formats are enabled; otherwise, it will be reachable"
)]
_ => &[],
}
}

pub fn from_mime_type(mime_type: &str) -> Option<Self> {
#[allow(unreachable_code)]
#[expect(
clippy::allow_attributes,
reason = "`unreachable_code` may not always lint"
)]
#[allow(
unreachable_code,
reason = "If all features listed below are disabled, then all arms will have a `return None`, keeping the surrounding `Some()` from being constructed."
)]
Some(match mime_type.to_ascii_lowercase().as_str() {
// note: farbfeld does not have a MIME type
"image/basis" | "image/x-basis" => feature_gate!("basis-universal", Basis),
Expand All @@ -197,7 +218,14 @@ impl ImageFormat {
}

pub fn from_extension(extension: &str) -> Option<Self> {
#[allow(unreachable_code)]
#[expect(
clippy::allow_attributes,
reason = "`unreachable_code` may not always lint"
)]
#[allow(
unreachable_code,
reason = "If all features listed below are disabled, then all arms will have a `return None`, keeping the surrounding `Some()` from being constructed."
)]
Some(match extension.to_ascii_lowercase().as_str() {
"basis" => feature_gate!("basis-universal", Basis),
"bmp" => feature_gate!("bmp", Bmp),
Expand All @@ -220,7 +248,14 @@ impl ImageFormat {
}

pub fn as_image_crate_format(&self) -> Option<image::ImageFormat> {
#[allow(unreachable_code)]
#[expect(
clippy::allow_attributes,
reason = "`unreachable_code` may not always lint"
)]
#[allow(
unreachable_code,
reason = "If all features listed below are disabled, then all arms will have a `return None`, keeping the surrounding `Some()` from being constructed."
)]
Some(match self {
#[cfg(feature = "bmp")]
ImageFormat::Bmp => image::ImageFormat::Bmp,
Expand Down Expand Up @@ -255,13 +290,27 @@ impl ImageFormat {
#[cfg(feature = "ktx2")]
ImageFormat::Ktx2 => return None,
// FIXME: https://github.com/rust-lang/rust/issues/129031
#[allow(unreachable_patterns)]
#[expect(
clippy::allow_attributes,
reason = "`unreachable_patterns` may not always lint"
)]
#[allow(
unreachable_patterns,
reason = "The wildcard pattern will be unreachable if all formats are enabled; otherwise, it will be reachable"
)]
_ => return None,
})
}

pub fn from_image_crate_format(format: image::ImageFormat) -> Option<ImageFormat> {
#[allow(unreachable_code)]
#[expect(
clippy::allow_attributes,
reason = "`unreachable_code` may not always lint"
)]
#[allow(
unreachable_code,
reason = "If all features listed below are disabled, then all arms will have a `return None`, keeping the surrounding `Some()` from being constructed."
)]
Some(match format {
image::ImageFormat::Bmp => feature_gate!("bmp", Bmp),
image::ImageFormat::Dds => feature_gate!("dds", Dds),
Expand Down Expand Up @@ -874,7 +923,15 @@ impl Image {
#[cfg(all(debug_assertions, feature = "dds"))] name: String,
buffer: &[u8],
image_type: ImageType,
#[allow(unused_variables)] supported_compressed_formats: CompressedImageFormats,
#[expect(
clippy::allow_attributes,
reason = "`unused_variables` may not always lint"
)]
#[allow(
unused_variables,
reason = "`supported_compressed_formats` is needed where the image format is `Basis`, `Dds`, or `Ktx2`; if these are disabled, then `supported_compressed_formats` is unused."
)]
supported_compressed_formats: CompressedImageFormats,
is_srgb: bool,
image_sampler: ImageSampler,
asset_usage: RenderAssetUsages,
Expand Down Expand Up @@ -904,7 +961,14 @@ impl Image {
ImageFormat::Ktx2 => {
ktx2_buffer_to_image(buffer, supported_compressed_formats, is_srgb)?
}
#[allow(unreachable_patterns)]
#[expect(
clippy::allow_attributes,
reason = "`unreachable_patterns` may not always lint"
)]
#[allow(
unreachable_patterns,
reason = "The wildcard pattern may be unreachable if only the specially-handled formats are enabled; however, the wildcard pattern is needed for any formats not specially handled"
)]
_ => {
let image_crate_format = format
.as_image_crate_format()
Expand Down
6 changes: 5 additions & 1 deletion crates/bevy_image/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![allow(unsafe_code)]
#![deny(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]

extern crate alloc;

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_input/src/common_conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::ButtonInput;
use bevy_ecs::system::Res;
use core::hash::Hash;

/// Stateful run condition that can be toggled via a input press using [`ButtonInput::just_pressed`].
/// Stateful run condition that can be toggled via an input press using [`ButtonInput::just_pressed`].
///
/// ```no_run
/// # use bevy_app::{App, NoopPluginGroup as DefaultPlugins, Update};
Expand Down
Loading

0 comments on commit d30a104

Please sign in to comment.