@@ -49,6 +49,18 @@ impl Default for ComputedVisibility {
49
49
#[ derive( Component ) ]
50
50
pub struct NoFrustumCulling ;
51
51
52
+ /// Collection of entities visible from the current view.
53
+ ///
54
+ /// This component contains all entities which are visible from the currently
55
+ /// rendered view. The collection is updated automatically by the [`check_visibility()`]
56
+ /// system, and renderers can use it to optimize rendering of a particular view, to
57
+ /// prevent drawing items not visible from that view.
58
+ ///
59
+ /// This component is intended to be attached to the same entity as the [`Camera`] and
60
+ /// the [`Frustum`] defining the view.
61
+ ///
62
+ /// Currently this component is ignored by the sprite renderer, so sprite rendering
63
+ /// is not optimized per view.
52
64
#[ derive( Clone , Component , Default , Debug , Reflect ) ]
53
65
#[ reflect( Component ) ]
54
66
pub struct VisibleEntities {
@@ -76,6 +88,8 @@ pub enum VisibilitySystems {
76
88
UpdateOrthographicFrusta ,
77
89
UpdatePerspectiveFrusta ,
78
90
UpdateProjectionFrusta ,
91
+ /// Label for the [`check_visibility()`] system updating each frame the [`ComputedVisibility`]
92
+ /// of each entity and the [`VisibleEntities`] of each view.
79
93
CheckVisibility ,
80
94
}
81
95
@@ -149,6 +163,11 @@ pub fn update_frusta<T: Component + CameraProjection + Send + Sync + 'static>(
149
163
}
150
164
}
151
165
166
+ /// System updating the visibility of entities each frame.
167
+ ///
168
+ /// The system is labelled with [`VisibilitySystems::CheckVisibility`]. Each frame, it updates the
169
+ /// [`ComputedVisibility`] of all entities, and for each view also compute the [`VisibleEntities`]
170
+ /// for that view.
152
171
pub fn check_visibility (
153
172
mut thread_queues : Local < ThreadLocal < Cell < Vec < Entity > > > > ,
154
173
mut view_query : Query < ( & mut VisibleEntities , & Frustum , Option < & RenderLayers > ) , With < Camera > > ,
0 commit comments