1
+ use std:: sync:: Arc ;
2
+
1
3
use re_viewer_context:: {
2
- AnnotationMap , IdentifiedViewSystem , ViewContextSystem , ViewSystemIdentifier ,
4
+ AnnotationMap , IdentifiedViewSystem , ViewContextSystem , ViewContextSystemStaticExecResult ,
5
+ ViewSystemIdentifier ,
3
6
} ;
4
7
5
8
#[ derive( Default ) ]
6
- pub struct AnnotationSceneContext ( pub AnnotationMap ) ;
9
+ pub struct AnnotationSceneContext ( pub Arc < AnnotationMap > ) ;
7
10
8
11
impl IdentifiedViewSystem for AnnotationSceneContext {
9
12
fn identifier ( ) -> ViewSystemIdentifier {
@@ -12,19 +15,30 @@ impl IdentifiedViewSystem for AnnotationSceneContext {
12
15
}
13
16
14
17
impl ViewContextSystem for AnnotationSceneContext {
18
+ fn execute_static (
19
+ ctx : & re_viewer_context:: ViewerContext < ' _ > ,
20
+ ) -> ViewContextSystemStaticExecResult {
21
+ // Use static execution to load the annotation map for all entities.
22
+ // Alternatively, we could do this only for visible ones per View but this is actually a lot more expensive to do
23
+ // given that there's typically just one annotation map per recording anyways!
24
+ let mut annotation_map = AnnotationMap :: default ( ) ;
25
+ annotation_map. load ( ctx, & ctx. current_query ( ) ) ;
26
+
27
+ Box :: new ( Self ( Arc :: new ( annotation_map) ) )
28
+ }
29
+
15
30
fn execute (
16
31
& mut self ,
17
- ctx : & re_viewer_context:: ViewContext < ' _ > ,
18
- query : & re_viewer_context:: ViewQuery < ' _ > ,
32
+ _ctx : & re_viewer_context:: ViewContext < ' _ > ,
33
+ _query : & re_viewer_context:: ViewQuery < ' _ > ,
34
+ static_execution_result : & ViewContextSystemStaticExecResult ,
19
35
) {
20
- re_tracing:: profile_function!( ) ;
21
- // We create a list of *all* entities here, do not only iterate over those with annotation context.
22
- // TODO(andreas): But knowing ahead of time where we have annotation contexts could be used for optimization.
23
- self . 0 . load (
24
- ctx. viewer_ctx ,
25
- & query. latest_at_query ( ) ,
26
- query. iter_all_entities ( ) ,
27
- ) ;
36
+ // Take over the static result to make it available.
37
+ self . 0 = static_execution_result
38
+ . downcast_ref :: < Self > ( )
39
+ . expect ( "Unexpected static execution result type" )
40
+ . 0
41
+ . clone ( ) ;
28
42
}
29
43
30
44
fn as_any ( & self ) -> & dyn std:: any:: Any {
0 commit comments