use crate::graphics::AbstractTriangle;
use crate::Scalar;
use std::cmp::Ordering;
#[derive(Clone)]
pub struct GpuTriangle {
pub z: f32,
pub indices: [u32; 3],
}
impl GpuTriangle {
pub fn new(offset: u32, indices: [u32; 3], z: impl Scalar) -> GpuTriangle {
GpuTriangle {
z: z.float(),
indices: [
indices[0] + offset,
indices[1] + offset,
indices[2] + offset,
],
}
}
pub fn from_abstract(t: &AbstractTriangle, offset: u32, z: f32) -> Self {
Self {
z,
indices: [
t.indices[0] + offset,
t.indices[1] + offset,
t.indices[2] + offset,
],
}
}
}
impl PartialEq for GpuTriangle {
fn eq(&self, other: &GpuTriangle) -> bool {
self.z.eq(&other.z)
}
}
impl Eq for GpuTriangle {}
impl PartialOrd for GpuTriangle {
fn partial_cmp(&self, other: &GpuTriangle) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for GpuTriangle {
fn cmp(&self, other: &GpuTriangle) -> Ordering {
self.z.partial_cmp(&other.z).unwrap()
}
}