mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 14:10:19 +00:00
Upgrade glam to 0.9.3
This commit is contained in:
parent
00a887214e
commit
5912206441
5 changed files with 4 additions and 29 deletions
|
@ -10,4 +10,4 @@ license = "MIT"
|
||||||
keywords = ["bevy"]
|
keywords = ["bevy"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glam = { version = "0.8.7", features = ["serde"] }
|
glam = { version = "0.9.3", features = ["serde"] }
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
mod face_toward;
|
mod face_toward;
|
||||||
mod geometry;
|
mod geometry;
|
||||||
mod perspective;
|
|
||||||
|
|
||||||
pub use face_toward::*;
|
pub use face_toward::*;
|
||||||
pub use geometry::*;
|
pub use geometry::*;
|
||||||
pub use glam::*;
|
pub use glam::*;
|
||||||
pub use perspective::*;
|
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::{FaceToward, Mat3, Mat4, Quat, Rect, Size, Vec2, Vec3, Vec4};
|
pub use crate::{FaceToward, Mat3, Mat4, Quat, Rect, Size, Vec2, Vec3, Vec4};
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
use crate::Mat4;
|
|
||||||
use glam::Vec4;
|
|
||||||
|
|
||||||
/// Produces a "right handed" perspective matrix
|
|
||||||
pub trait PerspectiveRh {
|
|
||||||
/// Produces a "right handed" perspective matrix
|
|
||||||
fn perspective_rh(fov_y_radians: f32, aspect_ratio: f32, z_near: f32, z_far: f32) -> Self;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PerspectiveRh for Mat4 {
|
|
||||||
fn perspective_rh(fov_y_radians: f32, aspect_ratio: f32, z_near: f32, z_far: f32) -> Self {
|
|
||||||
let (sin_fov, cos_fov) = (0.5 * fov_y_radians).sin_cos();
|
|
||||||
let h = cos_fov / sin_fov;
|
|
||||||
let w = h / aspect_ratio;
|
|
||||||
let r = z_far / (z_near - z_far);
|
|
||||||
Mat4::from_cols(
|
|
||||||
Vec4::new(w, 0.0, 0.0, 0.0),
|
|
||||||
Vec4::new(0.0, h, 0.0, 0.0),
|
|
||||||
Vec4::new(0.0, 0.0, r, -1.0),
|
|
||||||
Vec4::new(0.0, 0.0, r * z_near, 0.0),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
use bevy_math::{Mat4, PerspectiveRh};
|
use bevy_math::Mat4;
|
||||||
use bevy_property::{Properties, Property};
|
use bevy_property::{Properties, Property};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use super::DepthCalculation;
|
use super::DepthCalculation;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{CalculatedSize, Node};
|
use crate::{CalculatedSize, Node};
|
||||||
use bevy_asset::{Assets, Handle};
|
use bevy_asset::{Assets, Handle};
|
||||||
use bevy_ecs::{Changed, Query, Res, ResMut};
|
use bevy_ecs::{Changed, Query, Res, ResMut};
|
||||||
use bevy_math::Size;
|
use bevy_math::{Size, Vec3};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
draw::{Draw, DrawContext, Drawable},
|
draw::{Draw, DrawContext, Drawable},
|
||||||
renderer::{AssetRenderResourceBindings, RenderResourceBindings},
|
renderer::{AssetRenderResourceBindings, RenderResourceBindings},
|
||||||
|
@ -59,7 +59,7 @@ pub fn draw_text_system(
|
||||||
mut query: Query<(&mut Draw, &Text, &Node, &Transform)>,
|
mut query: Query<(&mut Draw, &Text, &Node, &Transform)>,
|
||||||
) {
|
) {
|
||||||
for (mut draw, text, node, transform) in &mut query.iter() {
|
for (mut draw, text, node, transform) in &mut query.iter() {
|
||||||
let position = transform.value.w_axis().truncate() - (node.size / 2.0).extend(0.0);
|
let position = Vec3::from(transform.value.w_axis().truncate()) - (node.size / 2.0).extend(0.0);
|
||||||
|
|
||||||
let mut drawable_text = DrawableText {
|
let mut drawable_text = DrawableText {
|
||||||
font: fonts.get(&text.font).unwrap(),
|
font: fonts.get(&text.font).unwrap(),
|
||||||
|
|
Loading…
Reference in a new issue