#How do you add ComputedVisiblityFlag to the type registery?

20 messages · Page 1 of 1 (latest)

devout adder
#

I'm trying to make a general plugin for serializing/deserializing things, but when i try to add ComputedVisiblityFlag to the type registry:

use bevy::{prelude::*, core_pipeline::core_3d::Camera3dDepthTextureUsage, render::view::ComputedVisibilityFlags};

... in plugin block
app.register_type::<ComputedVisibilityFlags>()

I get the error:

struct `ComputedVisibilityFlags` is private
private struct
bitflags::bitflags! {
    #[derive(Clone, Debug, Eq, PartialEq)]
    pub(super) struct ComputedVisibilityFlags: u8 {
        const VISIBLE_IN_VIEW = 1 << 0;
        const VISIBLE_IN_HIERARCHY = 1 << 1;
    }
}
bevy_reflect::impl_reflect_value!((in bevy_render::view) ComputedVisibilityFlags);

/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
#[derive(Component, Clone, Reflect, Debug, Eq, PartialEq)]
#[reflect(Component, Default)]
pub struct ComputedVisibility {
    flags: ComputedVisibilityFlags,
}
#

How do you add ComputedVisiblityFlag to the type registery?

night tapir
devout adder
hollow berry
#

Please don't serialize that type. It's a temporary value created every frame, it's not meant to be persisted.

devout adder
#

adding a system to manually query every entity to see if its missing it every update frame so it can add a dummy value seems needlessly expensive though

night tapir
devout adder
#

the only component stopping that from wokring as expected, is ComputedVisiblityFlag, which is private. it implements reflect, but I can't access it to add it to the type_registry

trim pond
#

Please don't serialize that type. It's a temporary value created every frame, it's not meant to be persisted.

I don't think that's right -- it's updated every frame, but bevy assumes / relies on its existence.

topaz loom
#

You shouldn't need to manually add it, Visibility and ComputedVisibility should be all that's needed, as that's what you normally add in a SpriteBundle for example

devout adder
trim pond
#

ComputedVisiblity was split into two components in 0.12-dev. Probably worth checking to see if this works there. I think you'll have to find a workaround in the meantime.

devout adder
trim pond
#

gross, but yay 🙂

#

was going to suggest something similar.

topaz loom
#

Yeah you should anyway just have a system that's adds Visibility, ComputedVisibility, and GlobalTransform to your things that have sprites

#

You should look up the blueprint pattern in bevy_replicon's docs