Struct re_viewer::external::re_entity_db::entity_tree::EntityTree
source · pub struct EntityTree {
pub path: EntityPath,
pub children: BTreeMap<EntityPathPart, EntityTree>,
}
Expand description
A recursive, manually updated ChunkStoreSubscriber
that maintains the entity hierarchy.
The tree contains a list of subtrees, and so on recursively.
Fields§
§path: EntityPath
Full path prefix to the root of this (sub)tree.
children: BTreeMap<EntityPathPart, EntityTree>
Direct descendants of this (sub)tree.
Implementations§
source§impl EntityTree
impl EntityTree
pub fn root() -> EntityTree
pub fn new(path: EntityPath) -> EntityTree
sourcepub fn check_is_empty(&self, engine: &StorageEngineReadGuard<'_>) -> bool
pub fn check_is_empty(&self, engine: &StorageEngineReadGuard<'_>) -> bool
Returns true
if this entity has no children and no data.
Checking for the absence of data is neither costly nor totally free: do it a few hundreds or
thousands times a frame and it will absolutely kill framerate.
Don’t blindly call this on every existing entity every frame: use ChunkStoreEvent
s to make
sure anything changed at all first.
sourcepub fn on_store_additions(&mut self, events: &[ChunkStoreEvent])
pub fn on_store_additions(&mut self, events: &[ChunkStoreEvent])
Updates the EntityTree
by applying a batch of ChunkStoreEvent
s,
adding any new entities to the tree.
Only reacts to additions (event.kind == StoreDiffKind::Addition
).
sourcepub fn on_store_deletions(
&mut self,
engine: &StorageEngineReadGuard<'_>,
entity_paths_with_deletions: &HashSet<EntityPath, BuildHasherDefault<NoHashHasher<EntityPath>>>,
events: &[ChunkStoreEvent]
)
pub fn on_store_deletions( &mut self, engine: &StorageEngineReadGuard<'_>, entity_paths_with_deletions: &HashSet<EntityPath, BuildHasherDefault<NoHashHasher<EntityPath>>>, events: &[ChunkStoreEvent] )
Updates the EntityTree
by removing any entities which have no data and no children.
pub fn subtree(&self, path: &EntityPath) -> Option<&EntityTree>
pub fn visit_children_recursively(&self, visitor: impl FnMut(&EntityPath))
sourcepub fn find_first_child_recursive(
&self,
predicate: impl FnMut(&EntityPath) -> bool
) -> Option<&EntityTree>
pub fn find_first_child_recursive( &self, predicate: impl FnMut(&EntityPath) -> bool ) -> Option<&EntityTree>
Invokes the predicate
for self
and all children recursively,
returning the first entity for which the predicate
returns true
.
Note that this function has early return semantics, meaning if multiple
entities would return true
, only the first is returned.
The entities are yielded in order of their entity paths.
Trait Implementations§
source§impl ChunkStoreSubscriber for EntityTree
impl ChunkStoreSubscriber for EntityTree
source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
self
: Read moresource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
self
: Read moresource§fn on_events(&mut self, _events: &[ChunkStoreEvent])
fn on_events(&mut self, _events: &[ChunkStoreEvent])
ChunkStore
s. Read moreAuto Trait Implementations§
impl Freeze for EntityTree
impl RefUnwindSafe for EntityTree
impl Send for EntityTree
impl Sync for EntityTree
impl Unpin for EntityTree
impl UnwindSafe for EntityTree
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request