use crate::components::{Hidden, RenderHandle};
use crate::ecs::{Entity, PipelineContext};
use crate::gfx::ops::RenderOps;
pub(super) fn set_subtree_visibility(
ctx: &mut PipelineContext,
ops: &mut RenderOps,
root: Entity,
visible: bool,
) {
for entity in super::despawn::collect_subtree(ctx, root) {
if visible {
ctx.remove::<Hidden>(entity);
} else if ctx.get::<Hidden>(entity).is_none() {
ctx.insert(entity, Hidden);
}
let slots: concinnity_memory::InlineVec<u32> = ctx
.get::<RenderHandle>(entity)
.map(|h| h.draws.clone())
.unwrap_or_default();
for slot in slots {
ops.record(move |backend| backend.update_visibility(slot as usize, visible));
}
}
}