rafx_visibility/
visibility_object.rs

1use crate::geometry::{BoundingSphere, Transform};
2use crate::{ModelHandle, VisibilityObjectHandle, ZoneHandle};
3
4#[derive(Default, Clone)]
5pub struct VisibilityObject {
6    // The handle given to this object by the visibility system
7    pub handle: VisibilityObjectHandle,
8    // The opaque object ID (i.e. a pointer or ECS ID)
9    pub id: u64,
10    pub zone: Option<ZoneHandle>,
11    pub cull_model: Option<ModelHandle>,
12    pub transform: Option<Transform>,
13    // This is updated before processing commands in VisibilityWorld::update
14    pub previous_frame_transform: Option<Transform>,
15}
16
17impl VisibilityObject {
18    pub fn new(
19        id: u64,
20        handle: VisibilityObjectHandle,
21    ) -> Self {
22        VisibilityObject {
23            id,
24            handle,
25            ..Default::default()
26        }
27    }
28
29    pub fn default_bounding_sphere(transform: Transform) -> BoundingSphere {
30        // NOTE(dvd): Default size chosen to fit a 1x1 quad.
31        BoundingSphere::new(transform.translation, 1.42 * transform.scale.max_element())
32    }
33}