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

Perform text scaling calculations per text, not per glyph #7819

Merged
merged 25 commits into from
Mar 14, 2023
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fb6cfaa
move transform scaling calculations for text out of the inner loop
ickshonpe Feb 25, 2023
67519e5
fix scaling in text2d
ickshonpe Feb 25, 2023
39f2f86
add many_glyphs example
ickshonpe Feb 25, 2023
fa6f831
Added many_glyphs example
ickshonpe Feb 25, 2023
a2ef631
modify example
ickshonpe Feb 25, 2023
65763ab
switch to single text section
ickshonpe Feb 25, 2023
b48bf4a
swapped flex_basis for style constraint on text node
ickshonpe Feb 25, 2023
58c69ee
Merge branch 'many_glyphs' into text-perf
ickshonpe Feb 25, 2023
ed801f5
cargo fmt
ickshonpe Feb 25, 2023
c64ee5c
fix manual-str-repeat
ickshonpe Feb 25, 2023
734ddb1
* cleaned up example
ickshonpe Feb 25, 2023
983b44d
cleaned up imports and improve transform calculations
ickshonpe Feb 25, 2023
15a41e4
replaced `extend` chain with `Vec4::from`
ickshonpe Feb 25, 2023
838fba2
Changed the precompution in `extract_text_uinodes` to use `from_scale…
ickshonpe Feb 27, 2023
6eabeef
cleaned up `extract_text2d_sprite` to be more similar to`extract_text…
ickshonpe Feb 27, 2023
3b760e7
Cleaned up `extract_text2d_sprite` to be more similar to`extract_tex…
ickshonpe Feb 27, 2023
26a04fe
Added text drawn with Text2d to the many_glyphs example.
ickshonpe Feb 27, 2023
c8ca008
cargo fmt
ickshonpe Feb 27, 2023
63f60cc
removed an unnecessary `mut` and an unused variable
ickshonpe Feb 27, 2023
6944b78
simplify text transform calculations
ickshonpe Feb 27, 2023
faedcab
simplified text calculations
ickshonpe Feb 27, 2023
567749c
fixed imports and fmt
ickshonpe Feb 27, 2023
fdfe321
fix clippy::doc-markdown warning
ickshonpe Feb 27, 2023
f3343cc
Merge branch 'main' into text-perf
ickshonpe Mar 13, 2023
d01878e
Moved scaling inversion calculation out of loop extraction loop.
ickshonpe Mar 13, 2023
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
Prev Previous commit
Next Next commit
Changed the precompution in extract_text_uinodes to use `from_scale…
…_rotation_translation` instead of constructing the matrix from columns.
  • Loading branch information
ickshonpe committed Feb 27, 2023
commit 838fba2207206d5c922dbba3f66fcf01789aa7ac
12 changes: 6 additions & 6 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{prelude::UiCameraConfig, BackgroundColor, CalculatedClip, Node, UiIm
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, AssetEvent, Assets, Handle, HandleUntyped};
use bevy_ecs::prelude::*;
use bevy_math::{mat4, Mat4, Rect, UVec4, Vec2, Vec3, Vec4, Vec4Swizzles};
use bevy_math::{Mat4, Rect, UVec4, Vec2, Vec3, Vec4, Vec4Swizzles};
use bevy_reflect::TypeUuid;
use bevy_render::texture::DEFAULT_IMAGE_HANDLE;
use bevy_render::{
Expand Down Expand Up @@ -329,12 +329,12 @@ pub fn extract_text_uinodes(
let mut color = Color::WHITE;
let mut current_section = usize::MAX;
let scale = scale_factor.recip();
let alignment_translation = -0.5 * uinode.size();
let transform = global_transform.compute_matrix()
* mat4(
Vec4::X * scale,
Vec4::Y * scale,
Vec4::Z * scale,
Vec4::from((-0.5 * uinode.size(), 0., 1.)),
* Mat4::from_scale_rotation_translation(
Vec3::splat(scale),
Quat::IDENTITY,
alignment_translation.extend(0.),
);

for PositionedGlyph {
Expand Down