@@ -235,26 +235,30 @@ pub fn scale_value(value: f32, factor: f32) -> f32 {
235235/// Used in system set [`VisibilitySystems::CalculateBounds`](bevy_render::view::VisibilitySystems::CalculateBounds).
236236pub fn calculate_bounds_text2d (
237237 mut commands : Commands ,
238- text_to_update_aabb : Query <
239- ( Entity , & TextLayoutInfo , & Anchor ) ,
240- (
241- Or < ( Without < Aabb > , Changed < TextLayoutInfo > ) > ,
242- Without < NoFrustumCulling > ,
243- ) ,
238+ mut text_to_update_aabb : Query <
239+ ( Entity , & TextLayoutInfo , & Anchor , Option < & mut Aabb > ) ,
240+ ( Changed < TextLayoutInfo > , Without < NoFrustumCulling > ) ,
244241 > ,
245242) {
246- for ( entity, layout_info, anchor) in & text_to_update_aabb {
243+ for ( entity, layout_info, anchor, aabb ) in & mut text_to_update_aabb {
247244 // `Anchor::as_vec` gives us an offset relative to the text2d bounds, by negating it and scaling
248245 // by the logical size we compensate the transform offset in local space to get the center.
249246 let center = ( -anchor. as_vec ( ) * layout_info. logical_size )
250247 . extend ( 0.0 )
251248 . into ( ) ;
252249 // Distance in local space from the center to the x and y limits of the text2d bounds.
253250 let half_extents = ( layout_info. logical_size / 2.0 ) . extend ( 0.0 ) . into ( ) ;
254- commands. entity ( entity) . try_insert ( Aabb {
255- center,
256- half_extents,
257- } ) ;
251+ if let Some ( mut aabb) = aabb {
252+ * aabb = Aabb {
253+ center,
254+ half_extents,
255+ } ;
256+ } else {
257+ commands. entity ( entity) . try_insert ( Aabb {
258+ center,
259+ half_extents,
260+ } ) ;
261+ }
258262 }
259263}
260264
0 commit comments