Ambient icon indicating copy to clipboard operation
Ambient copied to clipboard

Component for entity visibility

Open philpax opened this issue 2 years ago • 5 comments

As requested by @kevzettler - a way (likely a component) to show or hide an entire entity.

Open design questions:

  1. Is this clientside only?
  2. If it's on the serverside as well, should it disable physics for that entity as well?
  3. Is this recursive? Does hiding an entity hide all of its children too? (#299 potentially relevant - maybe we should add entity::[set/add]_component_recursive?)

philpax avatar Jul 23 '23 13:07 philpax

  1. Not sure what the state of rendering is in general, but there are plenty of server-side rendering components like color(), so allowing this on the server side seems consistent to me unless long-term we are considering moving all those other rendering components to be clientside only.

  2. I think we already have a way to disable physics - remove physics_controlled - and it could create extra confusion to add another way an object's physics might be toggled. Maybe this is alluding to some kind of entity_disabled component, but I think that raises a lot of other weird questions. I'd prefer to use a Concept for disabling multiple otherwise-unrelated components at once, or to just despawn entities that we want to 'not exist' for a while.

  3. Left a comment in that issue about this topic

droqen avatar Jul 23 '23 14:07 droqen

Re. recursive case; we need a solution for that in general, but the tricky thing is that the sub-tree can change, so just setting it once won't work (hence the outlines_recursive etc.).

FredrikNoren avatar Jul 23 '23 18:07 FredrikNoren

2. I think we already have a way to disable physics - remove physics_controlled - and it could create extra confusion to add another way an object's physics might be toggled.

Is removing/readding physics_controlled a quick operation? If so, then yeah, that should be fine. (might need to better document it)

Re. recursive case; we need a solution for that in general, but the tricky thing is that the sub-tree can change, so just setting it once won't work (hence the outlines_recursive etc.).

Mm yeah, it seems likely we'll need something more advanced like the two-entity queries @droqen suggested or a more specific solution (like an entity::add_component_to_hierarchy that does the necessary bookkeeping to apply that to the hierarchy, even as the hierarchy changes)

philpax avatar Jul 23 '23 18:07 philpax

This would also be nice for something I've run into - storing templates in the ECS. Right now, these template entities show up in the world - it would be ideal to hide them entirely, and only show them when they're instantiated for real.

philpax avatar Oct 19 '23 10:10 philpax

@philpax You can also remove the main_scene component from all the entities to hide them. The renderer will only render things with main_scene or ui_scene on them.

FredrikNoren avatar Oct 19 '23 15:10 FredrikNoren