Skip to content

Commit

Permalink
Merge branch 'main' into simple_move_from_remove
Browse files Browse the repository at this point in the history
  • Loading branch information
JaySpruce authored Jan 15, 2025
2 parents 4ba28f1 + 0756a19 commit 340eabb
Show file tree
Hide file tree
Showing 99 changed files with 3,859 additions and 925 deletions.
12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3311,6 +3311,18 @@ description = "Creates a solid color window"
category = "Window"
wasm = true

[[example]]
name = "custom_cursor_image"
path = "examples/window/custom_cursor_image.rs"
doc-scrape-examples = true
required-features = ["custom_cursor"]

[package.metadata.example.custom_cursor_image]
name = "Custom Cursor Image"
description = "Demonstrates creating an animated custom cursor from an image"
category = "Window"
wasm = true

[[example]]
name = "custom_user_event"
path = "examples/window/custom_user_event.rs"
Expand Down
19 changes: 19 additions & 0 deletions assets/cursors/kenney_crosshairPack/License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@


Crosshair Pack

by Kenney Vleugels (Kenney.nl)

------------------------------

License (Creative Commons Zero, CC0)
http://creativecommons.org/publicdomain/zero/1.0/

You may use these assets in personal and commercial projects.
Credit (Kenney or www.kenney.nl) would be nice but is not mandatory.

------------------------------

Donate: http://support.kenney.nl

Follow on Twitter for updates: @KenneyNL (www.twitter.com/kenneynl)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ impl AutoExposureCompensationCurve {
let lut_inv_range = 1.0 / (lut_end - lut_begin);

// Iterate over all LUT entries whose pixel centers fall within the current segment.
#[allow(clippy::needless_range_loop)]
#[expect(
clippy::needless_range_loop,
reason = "This for-loop also uses `i` to calculate a value `t`."
)]
for i in lut_begin.ceil() as usize..=lut_end.floor() as usize {
let t = (i as f32 - lut_begin) * lut_inv_range;
lut[i] = previous.y.lerp(current.y, t);
Expand Down
34 changes: 27 additions & 7 deletions crates/bevy_core_pipeline/src/core_2d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use core::ops::Range;
use bevy_asset::UntypedAssetId;
use bevy_render::{
batching::gpu_preprocessing::GpuPreprocessingMode,
render_phase::PhaseItemBatchSetKey,
view::{ExtractedView, RetainedViewEntity},
};
use bevy_utils::{HashMap, HashSet};
Expand Down Expand Up @@ -132,7 +133,7 @@ pub struct Opaque2d {
///
/// Objects in a single batch set can potentially be multi-drawn together,
/// if it's enabled and the current platform supports it.
pub batch_set_key: (),
pub batch_set_key: BatchSetKey2d,
/// The key, which determines which can be batched.
pub bin_key: Opaque2dBinKey,
/// An entity from which data will be fetched, including the mesh if
Expand Down Expand Up @@ -198,7 +199,7 @@ impl PhaseItem for Opaque2d {
impl BinnedPhaseItem for Opaque2d {
// Since 2D meshes presently can't be multidrawn, the batch set key is
// irrelevant.
type BatchSetKey = ();
type BatchSetKey = BatchSetKey2d;

type BinKey = Opaque2dBinKey;

Expand All @@ -219,6 +220,20 @@ impl BinnedPhaseItem for Opaque2d {
}
}

/// 2D meshes aren't currently multi-drawn together, so this batch set key only
/// stores whether the mesh is indexed.
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash)]
pub struct BatchSetKey2d {
/// True if the mesh is indexed.
pub indexed: bool,
}

impl PhaseItemBatchSetKey for BatchSetKey2d {
fn indexed(&self) -> bool {
self.indexed
}
}

impl CachedRenderPipelinePhaseItem for Opaque2d {
#[inline]
fn cached_pipeline(&self) -> CachedRenderPipelineId {
Expand All @@ -232,7 +247,7 @@ pub struct AlphaMask2d {
///
/// Objects in a single batch set can potentially be multi-drawn together,
/// if it's enabled and the current platform supports it.
pub batch_set_key: (),
pub batch_set_key: BatchSetKey2d,
/// The key, which determines which can be batched.
pub bin_key: AlphaMask2dBinKey,
/// An entity from which data will be fetched, including the mesh if
Expand Down Expand Up @@ -297,9 +312,7 @@ impl PhaseItem for AlphaMask2d {
}

impl BinnedPhaseItem for AlphaMask2d {
// Since 2D meshes presently can't be multidrawn, the batch set key is
// irrelevant.
type BatchSetKey = ();
type BatchSetKey = BatchSetKey2d;

type BinKey = AlphaMask2dBinKey;

Expand Down Expand Up @@ -335,6 +348,9 @@ pub struct Transparent2d {
pub draw_function: DrawFunctionId,
pub batch_range: Range<u32>,
pub extra_index: PhaseItemExtraIndex,
/// Whether the mesh in question is indexed (uses an index buffer in
/// addition to its vertex buffer).
pub indexed: bool,
}

impl PhaseItem for Transparent2d {
Expand Down Expand Up @@ -387,6 +403,10 @@ impl SortedPhaseItem for Transparent2d {
// radsort is a stable radix sort that performed better than `slice::sort_by_key` or `slice::sort_unstable_by_key`.
radsort::sort_by_key(items, |item| item.sort_key().0);
}

fn indexed(&self) -> bool {
self.indexed
}
}

impl CachedRenderPipelinePhaseItem for Transparent2d {
Expand All @@ -411,7 +431,7 @@ pub fn extract_core_2d_camera_phases(
}

// This is the main 2D camera, so we use the first subview index (0).
let retained_view_entity = RetainedViewEntity::new(main_entity.into(), 0);
let retained_view_entity = RetainedViewEntity::new(main_entity.into(), None, 0);

transparent_2d_phases.insert_or_clear(retained_view_entity);
opaque_2d_phases.insert_or_clear(retained_view_entity, GpuPreprocessingMode::None);
Expand Down
27 changes: 25 additions & 2 deletions crates/bevy_core_pipeline/src/core_3d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ use core::ops::Range;
use bevy_render::{
batching::gpu_preprocessing::{GpuPreprocessingMode, GpuPreprocessingSupport},
mesh::allocator::SlabId,
render_phase::PhaseItemBatchSetKey,
view::{NoIndirectDrawing, RetainedViewEntity},
};
pub use camera_3d::*;
Expand Down Expand Up @@ -269,6 +270,12 @@ pub struct Opaque3dBatchSetKey {
pub lightmap_slab: Option<NonMaxU32>,
}

impl PhaseItemBatchSetKey for Opaque3dBatchSetKey {
fn indexed(&self) -> bool {
self.index_slab.is_some()
}
}

/// Data that must be identical in order to *batch* phase items together.
///
/// Note that a *batch set* (if multi-draw is in use) contains multiple batches.
Expand Down Expand Up @@ -430,6 +437,9 @@ pub struct Transmissive3d {
pub draw_function: DrawFunctionId,
pub batch_range: Range<u32>,
pub extra_index: PhaseItemExtraIndex,
/// Whether the mesh in question is indexed (uses an index buffer in
/// addition to its vertex buffer).
pub indexed: bool,
}

impl PhaseItem for Transmissive3d {
Expand Down Expand Up @@ -493,6 +503,11 @@ impl SortedPhaseItem for Transmissive3d {
fn sort(items: &mut [Self]) {
radsort::sort_by_key(items, |item| item.distance);
}

#[inline]
fn indexed(&self) -> bool {
self.indexed
}
}

impl CachedRenderPipelinePhaseItem for Transmissive3d {
Expand All @@ -509,6 +524,9 @@ pub struct Transparent3d {
pub draw_function: DrawFunctionId,
pub batch_range: Range<u32>,
pub extra_index: PhaseItemExtraIndex,
/// Whether the mesh in question is indexed (uses an index buffer in
/// addition to its vertex buffer).
pub indexed: bool,
}

impl PhaseItem for Transparent3d {
Expand Down Expand Up @@ -560,6 +578,11 @@ impl SortedPhaseItem for Transparent3d {
fn sort(items: &mut [Self]) {
radsort::sort_by_key(items, |item| item.distance);
}

#[inline]
fn indexed(&self) -> bool {
self.indexed
}
}

impl CachedRenderPipelinePhaseItem for Transparent3d {
Expand Down Expand Up @@ -594,7 +617,7 @@ pub fn extract_core_3d_camera_phases(
});

// This is the main 3D camera, so use the first subview index (0).
let retained_view_entity = RetainedViewEntity::new(main_entity.into(), 0);
let retained_view_entity = RetainedViewEntity::new(main_entity.into(), None, 0);

opaque_3d_phases.insert_or_clear(retained_view_entity, gpu_preprocessing_mode);
alpha_mask_3d_phases.insert_or_clear(retained_view_entity, gpu_preprocessing_mode);
Expand Down Expand Up @@ -662,7 +685,7 @@ pub fn extract_camera_prepass_phase(
});

// This is the main 3D camera, so we use the first subview index (0).
let retained_view_entity = RetainedViewEntity::new(main_entity.into(), 0);
let retained_view_entity = RetainedViewEntity::new(main_entity.into(), None, 0);

if depth_prepass || normal_prepass || motion_vector_prepass {
opaque_3d_prepass_phases.insert_or_clear(retained_view_entity, gpu_preprocessing_mode);
Expand Down
5 changes: 5 additions & 0 deletions crates/bevy_core_pipeline/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![forbid(unsafe_code)]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
Expand Down
7 changes: 7 additions & 0 deletions crates/bevy_core_pipeline/src/prepass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use bevy_ecs::prelude::*;
use bevy_math::Mat4;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::mesh::allocator::SlabId;
use bevy_render::render_phase::PhaseItemBatchSetKey;
use bevy_render::sync_world::MainEntity;
use bevy_render::{
render_phase::{
Expand Down Expand Up @@ -184,6 +185,12 @@ pub struct OpaqueNoLightmap3dBatchSetKey {
pub index_slab: Option<SlabId>,
}

impl PhaseItemBatchSetKey for OpaqueNoLightmap3dBatchSetKey {
fn indexed(&self) -> bool {
self.index_slab.is_some()
}
}

// TODO: Try interning these.
/// The data used to bin each opaque 3D object in the prepass and deferred pass.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand Down
7 changes: 5 additions & 2 deletions crates/bevy_core_pipeline/src/tonemapping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,11 @@ pub fn get_lut_bind_group_layout_entries() -> [BindGroupLayoutEntryBuilder; 2] {
]
}

// allow(dead_code) so it doesn't complain when the tonemapping_luts feature is disabled
#[allow(dead_code)]
#[expect(clippy::allow_attributes, reason = "`dead_code` is not always linted.")]
#[allow(
dead_code,
reason = "There is unused code when the `tonemapping_luts` feature is disabled."
)]
fn setup_tonemapping_lut_image(bytes: &[u8], image_type: ImageType) -> Image {
let image_sampler = ImageSampler::Descriptor(bevy_image::ImageSamplerDescriptor {
label: Some("Tonemapping LUT sampler".to_string()),
Expand Down
12 changes: 10 additions & 2 deletions crates/bevy_dylib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![warn(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"
Expand Down Expand Up @@ -54,6 +59,9 @@
//! ```
// Force linking of the main bevy crate
#[allow(unused_imports)]
#[allow(clippy::single_component_path_imports)]
#[expect(
unused_imports,
clippy::single_component_path_imports,
reason = "This links the main bevy crate when using dynamic linking, and as such cannot be removed or changed without affecting dynamic linking."
)]
use bevy_internal;
10 changes: 8 additions & 2 deletions crates/bevy_ecs/src/archetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,10 @@ pub struct Archetypes {
pub struct ArchetypeRecord {
/// Index of the component in the archetype's [`Table`](crate::storage::Table),
/// or None if the component is a sparse set component.
#[allow(dead_code)]
#[expect(
dead_code,
reason = "Currently unused, but planned to be used to implement a component index to improve performance of fragmenting relations."
)]
pub(crate) column: Option<usize>,
}

Expand Down Expand Up @@ -827,7 +830,10 @@ impl Archetypes {

/// Fetches the total number of [`Archetype`]s within the world.
#[inline]
#[allow(clippy::len_without_is_empty)] // the internal vec is never empty.
#[expect(
clippy::len_without_is_empty,
reason = "The internal vec is never empty"
)]
pub fn len(&self) -> usize {
self.archetypes.len()
}
Expand Down
Loading

0 comments on commit 340eabb

Please sign in to comment.