use crate::AABB;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Copy, Clone)]
pub enum GroupActivation {
Position { aabb: AABB },
Always,
Never,
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Copy, Clone)]
pub struct Group {
active: bool,
pub activation: GroupActivation,
pub user_data: u64,
}
impl Group {
pub fn new(activation: GroupActivation, user_data: u64) -> Group {
Group {
activation,
user_data,
active: false,
}
}
pub(crate) fn intersects_camera(&self, cam_aabb: AABB) -> bool {
match &self.activation {
GroupActivation::Position { aabb } => return cam_aabb.intersects(aabb),
GroupActivation::Always => {
return true;
}
GroupActivation::Never => {
return false;
}
}
}
pub(crate) fn set_active(&mut self, active: bool) {
self.active = active;
}
pub fn set_activation(&mut self, activation: GroupActivation) {
self.activation = activation;
}
pub fn set_user_data(&mut self, user_data: u64) {
self.user_data = user_data;
}
pub const fn activation(&self) -> &GroupActivation {
&self.activation
}
pub const fn active(&self) -> bool {
self.active
}
pub const fn user_data(&self) -> u64 {
self.user_data
}
}