@@ -2,7 +2,7 @@ use crate::{CalculatedSize, Node, Style, Val};
2
2
use bevy_asset:: Assets ;
3
3
use bevy_ecs:: {
4
4
entity:: Entity ,
5
- query:: { Changed , Or , Without } ,
5
+ query:: { Changed , Or , With , Without } ,
6
6
system:: { Local , Query , QuerySet , Res , ResMut } ,
7
7
} ;
8
8
use bevy_math:: Size ;
@@ -45,6 +45,7 @@ pub fn text_constraint(min_size: Val, size: Val, max_size: Val, scale_factor: f6
45
45
#[ allow( clippy:: too_many_arguments) ]
46
46
pub fn text_system (
47
47
mut queued_text : Local < QueuedText > ,
48
+ mut last_scale_factor : Local < f64 > ,
48
49
mut textures : ResMut < Assets < Texture > > ,
49
50
fonts : Res < Assets < Font > > ,
50
51
windows : Res < Windows > ,
@@ -53,6 +54,7 @@ pub fn text_system(
53
54
mut text_pipeline : ResMut < DefaultTextPipeline > ,
54
55
mut text_queries : QuerySet < (
55
56
Query < Entity , Or < ( Changed < Text > , Changed < Style > ) > > ,
57
+ Query < Entity , ( With < Text > , With < Style > ) > ,
56
58
Query < ( & Text , & Style , & mut CalculatedSize ) > ,
57
59
) > ,
58
60
) {
@@ -64,9 +66,18 @@ pub fn text_system(
64
66
65
67
let inv_scale_factor = 1. / scale_factor;
66
68
67
- // Adds all entities where the text or the style has changed to the local queue
68
- for entity in text_queries. q0_mut ( ) . iter_mut ( ) {
69
- queued_text. entities . push ( entity) ;
69
+ #[ allow( clippy:: float_cmp) ]
70
+ if * last_scale_factor == scale_factor {
71
+ // Adds all entities where the text or the style has changed to the local queue
72
+ for entity in text_queries. q0 ( ) . iter ( ) {
73
+ queued_text. entities . push ( entity) ;
74
+ }
75
+ } else {
76
+ // If the scale factor has changed, queue all text
77
+ for entity in text_queries. q1 ( ) . iter ( ) {
78
+ queued_text. entities . push ( entity) ;
79
+ }
80
+ * last_scale_factor = scale_factor;
70
81
}
71
82
72
83
if queued_text. entities . is_empty ( ) {
@@ -75,7 +86,7 @@ pub fn text_system(
75
86
76
87
// Computes all text in the local queue
77
88
let mut new_queue = Vec :: new ( ) ;
78
- let query = text_queries. q1_mut ( ) ;
89
+ let query = text_queries. q2_mut ( ) ;
79
90
for entity in queued_text. entities . drain ( ..) {
80
91
if let Ok ( ( text, style, mut calculated_size) ) = query. get_mut ( entity) {
81
92
let node_size = Size :: new (
0 commit comments