Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Updated glam to 0.21. #5142

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish = false
license = "MIT OR Apache-2.0"

[dev-dependencies]
glam = "0.20"
glam = "0.21"
rand = "0.8"
rand_chacha = "0.3"
criterion = { version = "0.3", features = ["html_reports"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_encase_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ proc-macro = true

[dependencies]
bevy_macro_utils = { path = "../bevy_macro_utils", version = "0.8.0-dev" }
encase_derive_impl = "0.2"
encase_derive_impl = "0.3.0"
20 changes: 10 additions & 10 deletions crates/bevy_input/src/touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@ mod test {

let touch_event = Touch {
id: 4,
start_position: Vec2::new(0.0, 0.0),
start_position: Vec2::ZERO,
start_force: None,
previous_position: Vec2::new(0.0, 0.0),
previous_position: Vec2::ZERO,
previous_force: None,
position: Vec2::new(0.0, 0.0),
position: Vec2::ZERO,
force: None,
};

Expand Down Expand Up @@ -383,7 +383,7 @@ mod test {

let touch_event = TouchInput {
phase: TouchPhase::Started,
position: Vec2::new(4.0, 4.0),
position: Vec2::splat(4.0),
force: None,
id: 4,
};
Expand All @@ -398,7 +398,7 @@ mod test {

let moved_touch_event = TouchInput {
phase: TouchPhase::Moved,
position: Vec2::new(5.0, 5.0),
position: Vec2::splat(5.0),
force: None,
id: touch_event.id,
};
Expand All @@ -419,7 +419,7 @@ mod test {

let cancel_touch_event = TouchInput {
phase: TouchPhase::Cancelled,
position: Vec2::new(1.0, 1.0),
position: Vec2::ONE,
force: None,
id: touch_event.id,
};
Expand All @@ -434,7 +434,7 @@ mod test {

let end_touch_event = TouchInput {
phase: TouchPhase::Ended,
position: Vec2::new(4.0, 4.0),
position: Vec2::splat(4.0),
force: None,
id: 4,
};
Expand All @@ -456,7 +456,7 @@ mod test {

let touch_event = TouchInput {
phase: TouchPhase::Started,
position: Vec2::new(4.0, 4.0),
position: Vec2::splat(4.0),
force: None,
id: 4,
};
Expand All @@ -478,7 +478,7 @@ mod test {

let touch_event = TouchInput {
phase: TouchPhase::Ended,
position: Vec2::new(4.0, 4.0),
position: Vec2::splat(4.0),
force: None,
id: 4,
};
Expand All @@ -500,7 +500,7 @@ mod test {

let touch_event = TouchInput {
phase: TouchPhase::Cancelled,
position: Vec2::new(4.0, 4.0),
position: Vec2::splat(4.0),
force: None,
id: 4,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_math/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ license = "MIT OR Apache-2.0"
keywords = ["bevy"]

[dependencies]
glam = { version = "0.20.0", features = ["serde", "bytemuck"] }
glam = { version = "0.21", features = ["serde", "bytemuck"] }
2 changes: 1 addition & 1 deletion crates/bevy_mikktspace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "Zlib AND (MIT OR Apache-2.0)"
keywords = ["bevy", "3D", "graphics", "algorithm", "tangent"]

[dependencies]
glam = "0.20.0"
glam = "0.21"

[[example]]
name = "generate"
12 changes: 5 additions & 7 deletions crates/bevy_pbr/src/light.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::collections::HashSet;

use bevy_ecs::prelude::*;
use bevy_math::{
const_vec2, Mat4, UVec2, UVec3, Vec2, Vec3, Vec3A, Vec3Swizzles, Vec4, Vec4Swizzles,
};
use bevy_math::{Mat4, UVec2, UVec3, Vec2, Vec3, Vec3A, Vec3Swizzles, Vec4, Vec4Swizzles};
use bevy_reflect::prelude::*;
use bevy_render::{
camera::{Camera, CameraProjection, OrthographicProjection},
Expand Down Expand Up @@ -497,8 +495,8 @@ fn ndc_position_to_cluster(
.clamp(UVec3::ZERO, cluster_dimensions - UVec3::ONE)
}

const VEC2_HALF: Vec2 = const_vec2!([0.5, 0.5]);
const VEC2_HALF_NEGATIVE_Y: Vec2 = const_vec2!([0.5, -0.5]);
const VEC2_HALF: Vec2 = Vec2::splat(0.5);
const VEC2_HALF_NEGATIVE_Y: Vec2 = Vec2::new(0.5, -0.5);

// Calculate bounds for the light using a view space aabb.
// Returns a (Vec3, Vec3) containing min and max with
Expand Down Expand Up @@ -587,8 +585,8 @@ fn cluster_space_light_aabb(
)
}

const NDC_MIN: Vec2 = const_vec2!([-1.0, -1.0]);
const NDC_MAX: Vec2 = const_vec2!([1.0, 1.0]);
const NDC_MIN: Vec2 = Vec2::NEG_ONE;
const NDC_MAX: Vec2 = Vec2::ONE;

// Sort point lights with shadows enabled first, then by a stable key so that the index
// can be used to limit the number of point light shadows to render based on the device and
Expand Down
25 changes: 10 additions & 15 deletions crates/bevy_pbr/src/render/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bevy_ecs::{
prelude::*,
system::{lifetimeless::*, SystemParamItem},
};
use bevy_math::{const_vec3, Mat4, UVec2, UVec3, UVec4, Vec2, Vec3, Vec4, Vec4Swizzles};
use bevy_math::{Mat4, UVec2, UVec3, UVec4, Vec2, Vec3, Vec4, Vec4Swizzles};
use bevy_render::{
camera::{Camera, CameraProjection},
color::Color,
Expand Down Expand Up @@ -501,11 +501,6 @@ pub fn extract_lights(

pub(crate) const POINT_LIGHT_NEAR_Z: f32 = 0.1f32;

// Can't do `Vec3::Y * -1.0` because mul isn't const
const NEGATIVE_X: Vec3 = const_vec3!([-1.0, 0.0, 0.0]);
const NEGATIVE_Y: Vec3 = const_vec3!([0.0, -1.0, 0.0]);
const NEGATIVE_Z: Vec3 = const_vec3!([0.0, 0.0, -1.0]);

pub(crate) struct CubeMapFace {
pub(crate) target: Vec3,
pub(crate) up: Vec3,
Expand All @@ -515,33 +510,33 @@ pub(crate) struct CubeMapFace {
pub(crate) const CUBE_MAP_FACES: [CubeMapFace; 6] = [
// 0 GL_TEXTURE_CUBE_MAP_POSITIVE_X
CubeMapFace {
target: NEGATIVE_X,
up: NEGATIVE_Y,
target: Vec3::NEG_X,
up: Vec3::NEG_Y,
},
// 1 GL_TEXTURE_CUBE_MAP_NEGATIVE_X
CubeMapFace {
target: Vec3::X,
up: NEGATIVE_Y,
up: Vec3::NEG_Y,
},
// 2 GL_TEXTURE_CUBE_MAP_POSITIVE_Y
CubeMapFace {
target: NEGATIVE_Y,
target: Vec3::NEG_Y,
up: Vec3::Z,
},
// 3 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
CubeMapFace {
target: Vec3::Y,
up: NEGATIVE_Z,
up: Vec3::NEG_Z,
},
// 4 GL_TEXTURE_CUBE_MAP_POSITIVE_Z
CubeMapFace {
target: NEGATIVE_Z,
up: NEGATIVE_Y,
target: Vec3::NEG_Z,
up: Vec3::NEG_Y,
},
// 5 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
CubeMapFace {
target: Vec3::Z,
up: NEGATIVE_Y,
up: Vec3::NEG_Y,
},
];

Expand Down Expand Up @@ -1016,7 +1011,7 @@ struct GpuClusterLightIndexListsUniform {

// NOTE: Assert at compile time that GpuClusterLightIndexListsUniform
// fits within the maximum uniform buffer binding size
const _: () = assert!(GpuClusterLightIndexListsUniform::SIZE.get() <= 16384);
const _: () = assert!(GpuClusterLightIndexListsUniform::SHADER_SIZE.get() <= 16384);

impl Default for GpuClusterLightIndexListsUniform {
fn default() -> Self {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_reflect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ thiserror = "1.0"
once_cell = "1.11"
serde = "1"
smallvec = { version = "1.6", features = ["serde", "union", "const_generics"], optional = true }
glam = { version = "0.20.0", features = ["serde"], optional = true }
glam = { version = "0.21", features = ["serde"], optional = true }

[dev-dependencies]
ron = "0.7.0"
2 changes: 1 addition & 1 deletion crates/bevy_reflect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ bevy_reflect::tests::should_reflect_debug::Test {

assert_eq!(
result,
r#"{"type":"glam::vec3::Vec3","struct":{"x":{"type":"f32","value":12.0},"y":{"type":"f32","value":3.0},"z":{"type":"f32","value":-6.9}}}"#
r#"{"type":"glam::f32::vec3::Vec3","struct":{"x":{"type":"f32","value":12},"y":{"type":"f32","value":3},"z":{"type":"f32","value":-6.9}}}"#
);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ thiserror = "1.0"
futures-lite = "1.4.0"
anyhow = "1.0"
hex = "0.4.2"
hexasphere = "7.0.0"
hexasphere = "7.1"
CGMossa marked this conversation as resolved.
Show resolved Hide resolved
parking_lot = "0.11.0"
regex = "1.5"
copyless = "0.1.5"
Expand All @@ -70,4 +70,4 @@ flate2 = { version = "1.0.22", optional = true }
ruzstd = { version = "0.2.4", optional = true }
# For transcoding of UASTC/ETC1S universal formats, and for .basis file support
basis-universal = { version = "0.2.0", optional = true }
encase = { version = "0.2", features = ["glam"] }
encase = { version = "0.3", features = ["glam"] }
6 changes: 4 additions & 2 deletions crates/bevy_render/src/color/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,9 @@ impl encase::ShaderType for Color {
type ExtraMetadata = ();

const METADATA: encase::private::Metadata<Self::ExtraMetadata> = {
let size = encase::private::SizeValue::from(<f32 as encase::private::Size>::SIZE).mul(4);
let size =
encase::private::SizeValue::from(<f32 as encase::private::ShaderSize>::SHADER_SIZE)
.mul(4);
let alignment = encase::private::AlignmentValue::from_next_power_of_two_size(size);

encase::private::Metadata {
Expand Down Expand Up @@ -1214,7 +1216,7 @@ impl encase::private::CreateFrom for Color {
}
}

impl encase::Size for Color {}
impl encase::ShaderSize for Color {}

#[derive(Debug, Error)]
pub enum HexColorError {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_render/src/mesh/mesh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ struct MeshAttributeData {
values: VertexAttributeValues,
}

const VEC3_MIN: Vec3 = const_vec3!([std::f32::MIN, std::f32::MIN, std::f32::MIN]);
const VEC3_MAX: Vec3 = const_vec3!([std::f32::MAX, std::f32::MAX, std::f32::MAX]);
const VEC3_MIN: Vec3 = Vec3::splat(std::f32::MIN);
const VEC3_MAX: Vec3 = Vec3::splat(std::f32::MAX);

fn face_normal(a: [f32; 3], b: [f32; 3], c: [f32; 3]) -> [f32; 3] {
let (a, b, c) = (Vec3::from(a), Vec3::from(b), Vec3::from(c));
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/mesh/shape/capsule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl From<Capsule> for Mesh {
// North.
vs[j] = Vec3::new(0.0, summit, 0.0);
vts[j] = Vec2::new(s_texture_polar, 1.0);
vns[j] = Vec3::new(0.0, 1.0, 0.0);
vns[j] = Vec3::Y;

// South.
let idx = vert_offset_south_cap + j;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/render_resource/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ pub mod encase {
pub use encase::*;
}

pub use self::encase::{ShaderType, Size as ShaderSize};
pub use self::encase::{ShaderSize, ShaderType};

pub use naga::ShaderStage;
2 changes: 1 addition & 1 deletion crates/bevy_render/src/texture/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,6 @@ mod test {
#[test]
fn image_default_size() {
let image = Image::default();
assert_eq!(Vec2::new(1.0, 1.0), image.size());
assert_eq!(Vec2::ONE, image.size());
}
}
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/mesh2d/color_material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl RenderAsset for ColorMaterial {
flags: flags.bits(),
};

let byte_buffer = [0u8; ColorMaterialUniformData::SIZE.get() as usize];
let byte_buffer = [0u8; ColorMaterialUniformData::SHADER_SIZE.get() as usize];
let mut buffer = encase::UniformBuffer::new(byte_buffer);
buffer.write(&value).unwrap();

Expand Down
18 changes: 9 additions & 9 deletions crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy_ecs::{
prelude::*,
system::{lifetimeless::*, SystemParamItem},
};
use bevy_math::{const_vec2, Vec2};
use bevy_math::Vec2;
use bevy_reflect::Uuid;
use bevy_render::{
color::Color,
Expand Down Expand Up @@ -307,17 +307,17 @@ impl Default for SpriteMeta {
const QUAD_INDICES: [usize; 6] = [0, 2, 3, 0, 1, 2];

const QUAD_VERTEX_POSITIONS: [Vec2; 4] = [
const_vec2!([-0.5, -0.5]),
const_vec2!([0.5, -0.5]),
const_vec2!([0.5, 0.5]),
const_vec2!([-0.5, 0.5]),
Vec2::new(-0.5, -0.5),
Vec2::new(0.5, -0.5),
Vec2::new(0.5, 0.5),
Vec2::new(-0.5, 0.5),
];

const QUAD_UVS: [Vec2; 4] = [
const_vec2!([0., 1.]),
const_vec2!([1., 1.]),
const_vec2!([1., 0.]),
const_vec2!([0., 0.]),
Vec2::new(0., 1.),
Vec2::new(1., 1.),
Vec2::new(1., 0.),
Vec2::new(0., 0.),
];

#[derive(Component, Eq, PartialEq, Copy, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_text/src/font_atlas_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl FontAtlasSet {
vec![FontAtlas::new(
textures,
texture_atlases,
Vec2::new(512.0, 512.0),
Vec2::splat(512.0),
)]
});
let glyph_texture = Font::get_outlined_glyph_texture(outlined_glyph);
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_text/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<ID: Hash + Eq> TextPipeline<ID> {
id,
TextLayoutInfo {
glyphs: Vec::new(),
size: Vec2::new(0., 0.),
size: Vec2::ZERO,
},
);
return Ok(());
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_transform/src/components/global_transform.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::Transform;
use bevy_ecs::{component::Component, reflect::ReflectComponent};
use bevy_math::{const_vec3, Affine3A, Mat3, Mat4, Quat, Vec3};
use bevy_math::{Affine3A, Mat3, Mat4, Quat, Vec3};
use bevy_reflect::prelude::*;
use std::ops::Mul;

Expand Down Expand Up @@ -39,7 +39,7 @@ impl GlobalTransform {
#[doc(hidden)]
#[inline]
pub const fn from_xyz(x: f32, y: f32, z: f32) -> Self {
Self::from_translation(const_vec3!([x, y, z]))
Self::from_translation(Vec3::new(x, y, z))
}

/// Creates a new identity [`GlobalTransform`], with no translation, rotation, and a scale of 1
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_transform/src/components/transform.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::GlobalTransform;
use bevy_ecs::{component::Component, reflect::ReflectComponent};
use bevy_math::{const_vec3, Mat3, Mat4, Quat, Vec3};
use bevy_math::{Mat3, Mat4, Quat, Vec3};
use bevy_reflect::prelude::*;
use bevy_reflect::Reflect;
use std::ops::Mul;
Expand Down Expand Up @@ -43,7 +43,7 @@ impl Transform {
/// `z`-value.
#[inline]
pub const fn from_xyz(x: f32, y: f32, z: f32) -> Self {
Self::from_translation(const_vec3!([x, y, z]))
Self::from_translation(Vec3::new(x, y, z))
}

/// Creates a new identity [`Transform`], with no translation, rotation, and a scale of 1 on
Expand Down
Loading