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

docs: Documentation and clean up of bevy_math. #3503

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 1 addition & 2 deletions crates/bevy_math/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ license = "MIT OR Apache-2.0"
keywords = ["bevy"]

[dependencies]
glam = { version = "0.20.0", features = ["serde", "bytemuck"] }
bevy_reflect = { path = "../bevy_reflect", version = "0.7.0-dev", features = ["bevy"] }
glam = { version = "0.20.0", features = ["serde", "bytemuck"] }
41 changes: 0 additions & 41 deletions crates/bevy_math/src/face_toward.rs

This file was deleted.

184 changes: 0 additions & 184 deletions crates/bevy_math/src/geometry.rs

This file was deleted.

15 changes: 9 additions & 6 deletions crates/bevy_math/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
mod face_toward;
mod geometry;
#![warn(missing_docs)]

//! Provides math types and functionality for the Bevy game engine.
//!
//! The commonly used types are vectors like [`Vec2`], [`Vec3`] and [`Vec4`] and
//! matrices like [`Mat3`] and [`Mat4`].

pub use face_toward::*;
pub use geometry::*;
pub use glam::*;

/// The `bevy_math` prelude.
pub mod prelude {
#[doc(hidden)]
pub use crate::{
BVec2, BVec3, BVec4, EulerRot, FaceToward, IVec2, IVec3, IVec4, Mat3, Mat4, Quat, Rect,
Size, UVec2, UVec3, UVec4, Vec2, Vec3, Vec4,
BVec2, BVec3, BVec4, EulerRot, IVec2, IVec3, IVec4, Mat3, Mat4, Quat, UVec2, UVec3, UVec4,
Vec2, Vec3, Vec4,
};
}
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bevy_ecs::{
prelude::*,
system::{lifetimeless::*, SystemParamItem},
};
use bevy_math::{Mat4, Size};
use bevy_math::{Mat4, Vec2};
use bevy_reflect::TypeUuid;
use bevy_render::{
mesh::{GpuBufferInfo, Mesh, MeshVertexBufferLayout},
Expand Down Expand Up @@ -329,7 +329,7 @@ impl FromWorld for MeshPipeline {
texture_view,
texture_format: image.texture_descriptor.format,
sampler,
size: Size::new(
size: Vec2::new(
image.texture_descriptor.size.width as f32,
image.texture_descriptor.size.height as f32,
),
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_render/src/texture/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
};
use bevy_asset::HandleUntyped;
use bevy_ecs::system::{lifetimeless::SRes, SystemParamItem};
use bevy_math::{Size, Vec2};
use bevy_math::Vec2;
use bevy_reflect::TypeUuid;
use thiserror::Error;
use wgpu::{
Expand Down Expand Up @@ -533,14 +533,14 @@ impl TextureFormatPixelInfo for TextureFormat {
}

/// The GPU-representation of an [`Image`].
/// Consists of the [`Texture`], its [`TextureView`] and the corresponding [`Sampler`], and the texture's [`Size`].
/// Consists of the [`Texture`], its [`TextureView`] and the corresponding [`Sampler`], and the textures `size` represented by a [`Vec2`].
#[derive(Debug, Clone)]
pub struct GpuImage {
pub texture: Texture,
pub texture_view: TextureView,
pub texture_format: TextureFormat,
pub sampler: Sampler,
pub size: Size,
pub size: Vec2,
}

impl RenderAsset for Image {
Expand Down Expand Up @@ -595,7 +595,7 @@ impl RenderAsset for Image {
};

let texture_view = texture.create_view(&TextureViewDescriptor::default());
let size = Size::new(
let size = Vec2::new(
image.texture_descriptor.size.width as f32,
image.texture_descriptor.size.height as f32,
);
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_sprite/src/mesh2d/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bevy_ecs::{
prelude::*,
system::{lifetimeless::*, SystemParamItem},
};
use bevy_math::{Mat4, Size};
use bevy_math::{Mat4, Vec2};
use bevy_reflect::TypeUuid;
use bevy_render::{
mesh::{GpuBufferInfo, Mesh, MeshVertexBufferLayout},
Expand Down Expand Up @@ -194,7 +194,7 @@ impl FromWorld for Mesh2dPipeline {
texture_view,
texture_format: image.texture_descriptor.format,
sampler,
size: Size::new(
size: Vec2::new(
image.texture_descriptor.size.width as f32,
image.texture_descriptor.size.height as f32,
),
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ pub fn queue_sprites(
gpu_images.get(&Handle::weak(new_batch.image_handle_id))
{
current_batch = new_batch;
current_image_size = Vec2::new(gpu_image.size.width, gpu_image.size.height);
current_image_size = Vec2::new(gpu_image.size.x, gpu_image.size.y);
current_batch_entity = commands.spawn_bundle((current_batch,)).id();

image_bind_groups
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_text/src/glyph_brush.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ab_glyph::{Font as _, FontArc, Glyph, ScaleFont as _};
use bevy_asset::{Assets, Handle};
use bevy_math::{Size, Vec2};
use bevy_math::Vec2;
use bevy_render::texture::Image;
use bevy_sprite::TextureAtlas;
use glyph_brush_layout::{
Expand Down Expand Up @@ -29,11 +29,11 @@ impl GlyphBrush {
pub fn compute_glyphs<S: ToSectionText>(
&self,
sections: &[S],
bounds: Size,
bounds: Vec2,
text_alignment: TextAlignment,
) -> Result<Vec<SectionGlyph>, TextError> {
let geom = SectionGeometry {
bounds: (bounds.width, bounds.height),
bounds: (bounds.x, bounds.y),
..Default::default()
};
let section_glyphs = Layout::default()
Expand Down
Loading