paddle/display/gpu/
gpu_triangle.rs1use crate::graphics::AbstractTriangle;
4use crate::Scalar;
5use std::cmp::Ordering;
6
7#[derive(Clone)]
8pub struct GpuTriangle {
10 pub z: f32,
12 pub indices: [u32; 3],
14}
15
16impl GpuTriangle {
17 pub fn new(offset: u32, indices: [u32; 3], z: impl Scalar) -> GpuTriangle {
19 GpuTriangle {
20 z: z.float(),
21 indices: [
22 indices[0] + offset,
23 indices[1] + offset,
24 indices[2] + offset,
25 ],
26 }
27 }
28 pub fn from_abstract(t: &AbstractTriangle, offset: u32, z: f32) -> Self {
29 Self {
30 z,
31 indices: [
32 t.indices[0] + offset,
33 t.indices[1] + offset,
34 t.indices[2] + offset,
35 ],
36 }
37 }
38}
39
40impl PartialEq for GpuTriangle {
42 fn eq(&self, other: &GpuTriangle) -> bool {
43 self.z.eq(&other.z)
44 }
45}
46
47impl Eq for GpuTriangle {}
48
49impl PartialOrd for GpuTriangle {
50 fn partial_cmp(&self, other: &GpuTriangle) -> Option<Ordering> {
51 Some(self.cmp(other))
52 }
53}
54
55impl Ord for GpuTriangle {
56 fn cmp(&self, other: &GpuTriangle) -> Ordering {
57 self.z.partial_cmp(&other.z).unwrap()
58 }
59}