use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize};
#[derive(Debug, Clone, Copy, ArrowField, ArrowSerialize, ArrowDeserialize)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[arrow_field(transparent)]
pub struct DrawOrder(pub f32);
impl DrawOrder {
pub const DEFAULT_IMAGE: DrawOrder = DrawOrder(-10.0);
pub const DEFAULT_BOX2D: DrawOrder = DrawOrder(10.0);
pub const DEFAULT_LINES2D: DrawOrder = DrawOrder(20.0);
pub const DEFAULT_POINTS2D: DrawOrder = DrawOrder(30.0);
}
impl re_log_types::LegacyComponent for DrawOrder {
#[inline]
fn legacy_name() -> re_log_types::ComponentName {
"rerun.draw_order".into()
}
}
impl std::cmp::PartialEq for DrawOrder {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.0.is_nan() && other.0.is_nan() || self.0 == other.0
}
}
impl std::cmp::Eq for DrawOrder {}
impl std::cmp::PartialOrd for DrawOrder {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
if other == self {
Some(std::cmp::Ordering::Equal)
} else if other.0.is_nan() || self.0 < other.0 {
Some(std::cmp::Ordering::Less)
} else {
Some(std::cmp::Ordering::Greater)
}
}
}
impl std::cmp::Ord for DrawOrder {
#[inline]
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.partial_cmp(other).unwrap()
}
}
impl From<f32> for DrawOrder {
#[inline]
fn from(value: f32) -> Self {
Self(value)
}
}
impl From<DrawOrder> for f32 {
#[inline]
fn from(value: DrawOrder) -> Self {
value.0
}
}
re_log_types::component_legacy_shim!(DrawOrder);