1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
use std::sync::atomic::{AtomicUsize, Ordering};
use ecs::Component;
use crate::util::builder;
static CURRENT_BUNDLE_ID: AtomicUsize = AtomicUsize::new(0);
builder! {
/// Flags for how a object should be drawn.
#[builder(name = Builder, derives = (Debug, Default, Clone))]
#[derive(Debug, Default, Clone, Component)]
#[non_exhaustive]
pub struct DrawFlags
{
pub polygon_mode_config: PolygonModeConfig,
}
}
impl DrawFlags
{
pub fn builder() -> Builder
{
Builder::default()
}
}
#[derive(Debug, Default, Clone)]
pub struct PolygonModeConfig
{
pub face: PolygonModeFace,
pub mode: PolygonMode,
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum PolygonMode
{
Point,
Line,
#[default]
Fill,
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum PolygonModeFace
{
Front,
Back,
#[default]
FrontAndBack,
}
/// Metadata for how a object should be drawn together with other objects.
#[derive(Debug, Clone, Component)]
pub struct DrawingBundled
{
pub bundle_id: DrawingBundleId,
pub order: usize,
}
/// The ID of a object drawing bundle.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct DrawingBundleId
{
inner: usize,
}
impl DrawingBundleId
{
/// Creates a new unique bundle ID.
pub fn new() -> Self
{
Self {
inner: CURRENT_BUNDLE_ID.fetch_add(1, Ordering::Relaxed),
}
}
pub fn inner(&self) -> usize
{
self.inner
}
}
|