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 2 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_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::splat(-1.0);
CGMossa marked this conversation as resolved.
Show resolved Hide resolved
const NDC_MAX: Vec2 = Vec2::splat(1.0);

// 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
8 changes: 4 additions & 4 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 @@ -503,9 +503,9 @@ 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]);
const NEGATIVE_X: Vec3 = Vec3::new(-1.0, 0.0, 0.0);
const NEGATIVE_Y: Vec3 = Vec3::new(0.0, -1.0, 0.0);
const NEGATIVE_Z: Vec3 = Vec3::new(0.0, 0.0, -1.0);
CGMossa marked this conversation as resolved.
Show resolved Hide resolved

pub(crate) struct CubeMapFace {
pub(crate) target: Vec3,
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.2", features = ["serde"], optional = true }

[dev-dependencies]
ron = "0.7.0"
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::new(std::f32::MIN, std::f32::MIN, std::f32::MIN);
CGMossa marked this conversation as resolved.
Show resolved Hide resolved
const VEC3_MAX: Vec3 = Vec3::new(std::f32::MAX, std::f32::MAX, 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
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 @@ -308,17 +308,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
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
10 changes: 5 additions & 5 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{prelude::CameraUi, CalculatedClip, Node, UiColor, UiImage};
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, AssetEvent, Assets, Handle, HandleUntyped};
use bevy_ecs::prelude::*;
use bevy_math::{const_vec3, Mat4, Vec2, Vec3, Vec4Swizzles};
use bevy_math::{Mat4, Vec2, Vec3, Vec4Swizzles};
use bevy_reflect::TypeUuid;
use bevy_render::{
camera::{Camera, CameraProjection, DepthCalculation, OrthographicProjection, WindowOrigin},
Expand Down Expand Up @@ -353,10 +353,10 @@ impl Default for UiMeta {
}

const QUAD_VERTEX_POSITIONS: [Vec3; 4] = [
const_vec3!([-0.5, -0.5, 0.0]),
const_vec3!([0.5, -0.5, 0.0]),
const_vec3!([0.5, 0.5, 0.0]),
const_vec3!([-0.5, 0.5, 0.0]),
Vec3::new(-0.5, -0.5, 0.0),
Vec3::new(0.5, -0.5, 0.0),
Vec3::new(0.5, 0.5, 0.0),
Vec3::new(-0.5, 0.5, 0.0),
];

const QUAD_INDICES: [usize; 6] = [0, 2, 3, 0, 1, 2];
Expand Down
4 changes: 2 additions & 2 deletions examples/2d/rotation.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Demonstrates rotating entities in 2D using quaternions.

use bevy::{
math::{const_vec2, Vec3Swizzles},
math::Vec3Swizzles,
prelude::*,
time::FixedTimestep,
};

const TIME_STEP: f32 = 1.0 / 60.0;
const BOUNDS: Vec2 = const_vec2!([1200.0, 640.0]);
const BOUNDS: Vec2 = Vec2::new(1200.0, 640.0);

fn main() {
App::new()
Expand Down
12 changes: 5 additions & 7 deletions examples/games/breakout.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! A simplified implementation of the classic game "Breakout".

use bevy::{
math::{const_vec2, const_vec3},
prelude::*,
sprite::collide_aabb::{collide, Collision},
time::FixedTimestep,
Expand All @@ -12,18 +11,17 @@ const TIME_STEP: f32 = 1.0 / 60.0;

// These constants are defined in `Transform` units.
// Using the default 2D camera they correspond 1:1 with screen pixels.
// The `const_vec3!` macros are needed as functions that operate on floats cannot be constant in Rust.
const PADDLE_SIZE: Vec3 = const_vec3!([120.0, 20.0, 0.0]);
const PADDLE_SIZE: Vec3 = Vec3::new(120.0, 20.0, 0.0);
const GAP_BETWEEN_PADDLE_AND_FLOOR: f32 = 60.0;
const PADDLE_SPEED: f32 = 500.0;
// How close can the paddle get to the wall
const PADDLE_PADDING: f32 = 10.0;

// We set the z-value of the ball to 1 so it renders on top in the case of overlapping sprites.
const BALL_STARTING_POSITION: Vec3 = const_vec3!([0.0, -50.0, 1.0]);
const BALL_SIZE: Vec3 = const_vec3!([30.0, 30.0, 0.0]);
const BALL_STARTING_POSITION: Vec3 = Vec3::new(0.0, -50.0, 1.0);
const BALL_SIZE: Vec3 = Vec3::new(30.0, 30.0, 0.0);
const BALL_SPEED: f32 = 400.0;
const INITIAL_BALL_DIRECTION: Vec2 = const_vec2!([0.5, -0.5]);
const INITIAL_BALL_DIRECTION: Vec2 = Vec2::new(0.5, -0.5);

const WALL_THICKNESS: f32 = 10.0;
// x coordinates
Expand All @@ -33,7 +31,7 @@ const RIGHT_WALL: f32 = 450.;
const BOTTOM_WALL: f32 = -300.;
const TOP_WALL: f32 = 300.;

const BRICK_SIZE: Vec2 = const_vec2!([100., 30.]);
const BRICK_SIZE: Vec2 = Vec2::new(100., 30.);
// These values are exact
const GAP_BETWEEN_PADDLE_AND_BRICKS: f32 = 270.0;
const GAP_BETWEEN_BRICKS: f32 = 5.0;
Expand Down