diff --git a/crates/bevy_core/src/lib.rs b/crates/bevy_core/src/lib.rs index 038abaeb16..44b2be465b 100644 --- a/crates/bevy_core/src/lib.rs +++ b/crates/bevy_core/src/lib.rs @@ -1,13 +1,11 @@ #![warn(missing_docs)] //! This crate provides core functionality for Bevy Engine. -mod float_ord; mod name; mod task_pool_options; mod time; pub use bytemuck::{bytes_of, cast_slice, Pod, Zeroable}; -pub use float_ord::*; pub use name::*; pub use task_pool_options::*; pub use time::*; diff --git a/crates/bevy_core_pipeline/Cargo.toml b/crates/bevy_core_pipeline/Cargo.toml index 0fa33d8ec0..55ec3c7713 100644 --- a/crates/bevy_core_pipeline/Cargo.toml +++ b/crates/bevy_core_pipeline/Cargo.toml @@ -19,7 +19,6 @@ trace = [] # bevy bevy_app = { path = "../bevy_app", version = "0.8.0-dev" } bevy_asset = { path = "../bevy_asset", version = "0.8.0-dev" } -bevy_core = { path = "../bevy_core", version = "0.8.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.8.0-dev" } bevy_render = { path = "../bevy_render", version = "0.8.0-dev" } bevy_utils = { path = "../bevy_utils", version = "0.8.0-dev" } diff --git a/crates/bevy_core_pipeline/src/lib.rs b/crates/bevy_core_pipeline/src/lib.rs index e9d0c9b8b9..328b6d7011 100644 --- a/crates/bevy_core_pipeline/src/lib.rs +++ b/crates/bevy_core_pipeline/src/lib.rs @@ -20,7 +20,6 @@ pub use main_pass_driver::*; use std::ops::Range; use bevy_app::{App, Plugin}; -use bevy_core::FloatOrd; use bevy_ecs::prelude::*; use bevy_render::{ camera::{ActiveCamera, Camera2d, Camera3d, ExtractedCamera, RenderTarget}, @@ -36,6 +35,7 @@ use bevy_render::{ view::{ExtractedView, Msaa, ViewDepthTexture}, RenderApp, RenderStage, RenderWorld, }; +use bevy_utils::FloatOrd; /// When used as a resource, sets the color that is used to clear the screen between frames. /// diff --git a/crates/bevy_pbr/Cargo.toml b/crates/bevy_pbr/Cargo.toml index 9e9286183d..37107c44d4 100644 --- a/crates/bevy_pbr/Cargo.toml +++ b/crates/bevy_pbr/Cargo.toml @@ -15,7 +15,6 @@ webgl = [] # bevy bevy_app = { path = "../bevy_app", version = "0.8.0-dev" } bevy_asset = { path = "../bevy_asset", version = "0.8.0-dev" } -bevy_core = { path = "../bevy_core", version = "0.8.0-dev" } bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.8.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.8.0-dev" } bevy_math = { path = "../bevy_math", version = "0.8.0-dev" } diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index bef9f3e367..d3fafd0e01 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -4,7 +4,6 @@ use crate::{ PointLight, PointLightShadowMap, SetMeshBindGroup, VisiblePointLights, SHADOW_SHADER_HANDLE, }; use bevy_asset::Handle; -use bevy_core::FloatOrd; use bevy_core_pipeline::Transparent3d; use bevy_ecs::{ prelude::*, @@ -30,6 +29,7 @@ use bevy_render::{ }, }; use bevy_transform::components::GlobalTransform; +use bevy_utils::FloatOrd; use bevy_utils::{ tracing::{error, warn}, HashMap, diff --git a/crates/bevy_sprite/Cargo.toml b/crates/bevy_sprite/Cargo.toml index 9014f99fc8..238fe048b2 100644 --- a/crates/bevy_sprite/Cargo.toml +++ b/crates/bevy_sprite/Cargo.toml @@ -12,7 +12,6 @@ keywords = ["bevy"] # bevy bevy_app = { path = "../bevy_app", version = "0.8.0-dev" } bevy_asset = { path = "../bevy_asset", version = "0.8.0-dev" } -bevy_core = { path = "../bevy_core", version = "0.8.0-dev" } bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.8.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.8.0-dev" } bevy_log = { path = "../bevy_log", version = "0.8.0-dev" } diff --git a/crates/bevy_sprite/src/mesh2d/material.rs b/crates/bevy_sprite/src/mesh2d/material.rs index 44fcbfbf55..f088e761a0 100644 --- a/crates/bevy_sprite/src/mesh2d/material.rs +++ b/crates/bevy_sprite/src/mesh2d/material.rs @@ -1,6 +1,5 @@ use bevy_app::{App, Plugin}; use bevy_asset::{AddAsset, Asset, AssetServer, Handle}; -use bevy_core::FloatOrd; use bevy_core_pipeline::Transparent2d; use bevy_ecs::{ entity::Entity, @@ -29,6 +28,7 @@ use bevy_render::{ RenderApp, RenderStage, }; use bevy_transform::components::{GlobalTransform, Transform}; +use bevy_utils::FloatOrd; use std::hash::Hash; use std::marker::PhantomData; diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index 865eccd613..25b155fd65 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -5,7 +5,6 @@ use crate::{ Rect, Sprite, SPRITE_SHADER_HANDLE, }; use bevy_asset::{AssetEvent, Assets, Handle, HandleId}; -use bevy_core::FloatOrd; use bevy_core_pipeline::Transparent2d; use bevy_ecs::{ prelude::*, @@ -27,6 +26,7 @@ use bevy_render::{ RenderWorld, }; use bevy_transform::components::GlobalTransform; +use bevy_utils::FloatOrd; use bevy_utils::HashMap; use bytemuck::{Pod, Zeroable}; use copyless::VecHelper; diff --git a/crates/bevy_text/Cargo.toml b/crates/bevy_text/Cargo.toml index cbfebbae6c..d668108ea6 100644 --- a/crates/bevy_text/Cargo.toml +++ b/crates/bevy_text/Cargo.toml @@ -15,7 +15,6 @@ subpixel_glyph_atlas = [] # bevy bevy_app = { path = "../bevy_app", version = "0.8.0-dev" } bevy_asset = { path = "../bevy_asset", version = "0.8.0-dev" } -bevy_core = { path = "../bevy_core", version = "0.8.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.8.0-dev" } bevy_math = { path = "../bevy_math", version = "0.8.0-dev" } bevy_reflect = { path = "../bevy_reflect", version = "0.8.0-dev", features = ["bevy"] } diff --git a/crates/bevy_text/src/font_atlas_set.rs b/crates/bevy_text/src/font_atlas_set.rs index 29ede6cb53..34a1a843c4 100644 --- a/crates/bevy_text/src/font_atlas_set.rs +++ b/crates/bevy_text/src/font_atlas_set.rs @@ -1,11 +1,11 @@ use crate::{error::TextError, Font, FontAtlas}; use ab_glyph::{GlyphId, OutlinedGlyph, Point}; use bevy_asset::{Assets, Handle}; -use bevy_core::FloatOrd; use bevy_math::Vec2; use bevy_reflect::TypeUuid; use bevy_render::texture::Image; use bevy_sprite::TextureAtlas; +use bevy_utils::FloatOrd; use bevy_utils::HashMap; type FontSizeKey = FloatOrd; diff --git a/crates/bevy_ui/Cargo.toml b/crates/bevy_ui/Cargo.toml index 8f1b0a6be3..2997283d94 100644 --- a/crates/bevy_ui/Cargo.toml +++ b/crates/bevy_ui/Cargo.toml @@ -12,7 +12,6 @@ keywords = ["bevy"] # bevy bevy_app = { path = "../bevy_app", version = "0.8.0-dev" } bevy_asset = { path = "../bevy_asset", version = "0.8.0-dev" } -bevy_core = { path = "../bevy_core", version = "0.8.0-dev" } bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.8.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.8.0-dev" } bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.8.0-dev" } diff --git a/crates/bevy_ui/src/focus.rs b/crates/bevy_ui/src/focus.rs index fe8e072a04..bda95216f3 100644 --- a/crates/bevy_ui/src/focus.rs +++ b/crates/bevy_ui/src/focus.rs @@ -1,5 +1,4 @@ use crate::{CalculatedClip, Node}; -use bevy_core::FloatOrd; use bevy_ecs::{ entity::Entity, prelude::Component, @@ -10,6 +9,7 @@ use bevy_input::{mouse::MouseButton, touch::Touches, Input}; use bevy_math::Vec2; use bevy_reflect::{Reflect, ReflectDeserialize}; use bevy_transform::components::GlobalTransform; +use bevy_utils::FloatOrd; use bevy_window::Windows; use serde::{Deserialize, Serialize}; use smallvec::SmallVec; diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index 6b98ec4191..3548d5c297 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -9,7 +9,6 @@ pub use render_pass::*; use crate::{CalculatedClip, Node, UiColor, UiImage}; use bevy_app::prelude::*; use bevy_asset::{load_internal_asset, AssetEvent, Assets, Handle, HandleUntyped}; -use bevy_core::FloatOrd; use bevy_ecs::prelude::*; use bevy_math::{const_vec3, Mat4, Vec2, Vec3, Vec4Swizzles}; use bevy_reflect::TypeUuid; @@ -27,6 +26,7 @@ use bevy_render::{ use bevy_sprite::{Rect, SpriteAssetEvents, TextureAtlas}; use bevy_text::{DefaultTextPipeline, Text}; use bevy_transform::components::GlobalTransform; +use bevy_utils::FloatOrd; use bevy_utils::HashMap; use bevy_window::{WindowId, Windows}; use bytemuck::{Pod, Zeroable}; diff --git a/crates/bevy_ui/src/render/render_pass.rs b/crates/bevy_ui/src/render/render_pass.rs index 16b2280c13..dd7c8fd31a 100644 --- a/crates/bevy_ui/src/render/render_pass.rs +++ b/crates/bevy_ui/src/render/render_pass.rs @@ -1,4 +1,3 @@ -use bevy_core::FloatOrd; use bevy_ecs::{ prelude::*, system::{lifetimeless::*, SystemParamItem}, @@ -13,6 +12,7 @@ use bevy_render::{ renderer::*, view::*, }; +use bevy_utils::FloatOrd; use crate::prelude::CameraUi; diff --git a/crates/bevy_core/src/float_ord.rs b/crates/bevy_utils/src/float_ord.rs similarity index 90% rename from crates/bevy_core/src/float_ord.rs rename to crates/bevy_utils/src/float_ord.rs index 7b265e2016..45832198ad 100644 --- a/crates/bevy_core/src/float_ord.rs +++ b/crates/bevy_utils/src/float_ord.rs @@ -41,12 +41,12 @@ impl Hash for FloatOrd { fn hash(&self, state: &mut H) { if self.0.is_nan() { // Ensure all NaN representations hash to the same value - state.write(bytemuck::bytes_of(&f32::NAN)); + state.write(&f32::to_ne_bytes(f32::NAN)); } else if self.0 == 0.0 { // Ensure both zeroes hash to the same value - state.write(bytemuck::bytes_of(&0.0f32)); + state.write(&f32::to_ne_bytes(0.0f32)); } else { - state.write(bytemuck::bytes_of(&self.0)); + state.write(&f32::to_ne_bytes(self.0)); } } } diff --git a/crates/bevy_utils/src/lib.rs b/crates/bevy_utils/src/lib.rs index f6b3f56ce4..92eed886f8 100644 --- a/crates/bevy_utils/src/lib.rs +++ b/crates/bevy_utils/src/lib.rs @@ -7,10 +7,12 @@ pub mod label; mod default; mod enum_variant_meta; +mod float_ord; pub use ahash::AHasher; pub use default::default; pub use enum_variant_meta::*; +pub use float_ord::*; pub use hashbrown; pub use instant::{Duration, Instant}; pub use tracing; diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index e4cc86d886..201e32571f 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -1,5 +1,4 @@ use bevy::{ - core::FloatOrd, core_pipeline::Transparent2d, prelude::*, reflect::TypeUuid, @@ -21,6 +20,7 @@ use bevy::{ DrawMesh2d, Mesh2dHandle, Mesh2dPipeline, Mesh2dPipelineKey, Mesh2dUniform, SetMesh2dBindGroup, SetMesh2dViewBindGroup, }, + utils::FloatOrd, }; /// This example shows how to manually render 2d items using "mid level render apis" with a custom pipeline for 2d meshes