honeycomb_render/options/
resource.rs

1use bevy::prelude::*;
2use bevy_egui::egui::Color32;
3
4macro_rules! declare_newtype_resource {
5    ($nam: ident, $inr: ty) => {
6        /// Rendering option as a resource.
7        #[derive(Resource)]
8        pub struct $nam(pub $inr);
9    };
10    ($nam: ident, $inr: ty, $def: expr) => {
11        /// Rendering option as a resource.
12        #[derive(Resource)]
13        pub struct $nam(pub $inr);
14
15        impl Default for $nam {
16            fn default() -> Self {
17                Self($def)
18            }
19        }
20    };
21    ($nam: ident, $inr1: ty, $inr2: ty, $def: expr) => {
22        /// Rendering option as a resource.
23        #[derive(Resource)]
24        pub struct $nam(pub $inr1, pub $inr2);
25
26        impl Default for $nam {
27            fn default() -> Self {
28                Self($def.0, $def.1)
29            }
30        }
31    };
32}
33
34// --- NewType parameters
35// fine granulation of parameters allow lighter rendering update logic
36
37// -- indicate if objects of the given type should be rendered, & what color should be used
38
39declare_newtype_resource!(DartRenderColor, bool, Color32, (true, Color32::BLACK));
40#[rustfmt::skip]
41declare_newtype_resource!(BetaRenderColor, bool, Color32, (false, Color32::TRANSPARENT));
42declare_newtype_resource!(VertexRenderColor, bool, Color32, (true, Color32::GOLD));
43declare_newtype_resource!(EdgeRenderColor, bool, Color32, (false, Color32::YELLOW));
44declare_newtype_resource!(FaceRenderColor, bool, Color32, (false, Color32::RED));
45declare_newtype_resource!(VolumeRenderColor, bool, Color32, (false, Color32::DARK_RED));
46
47// -- material handle for objects of the given type; those exist for efficiency reasons
48
49declare_newtype_resource!(DartMatHandle, Handle<StandardMaterial>);
50declare_newtype_resource!(BetaMatHandle, Handle<StandardMaterial>);
51declare_newtype_resource!(VertexMatHandle, Handle<StandardMaterial>);
52declare_newtype_resource!(EdgeMatHandle, Handle<StandardMaterial>);
53declare_newtype_resource!(FaceMatHandle, Handle<StandardMaterial>);
54declare_newtype_resource!(VolumeMatHandle, Handle<StandardMaterial>);
55
56// -- shrink factor for objects of the given type; these are only relevant to a subset of types
57
58declare_newtype_resource!(DartShrink, f32, 0.0);
59declare_newtype_resource!(FaceShrink, f32, 0.0);
60declare_newtype_resource!(VolumeShrink, f32, 0.0);
61
62// -- size for objects of the given type; these are only relevant to a subset of types
63
64declare_newtype_resource!(DartWidth, f32);
65declare_newtype_resource!(BetaWidth, f32);
66declare_newtype_resource!(VertexWidth, f32);
67declare_newtype_resource!(EdgeWidth, f32);
68
69// -- more specific options
70
71declare_newtype_resource!(VertexHandle, Handle<Mesh>);
72declare_newtype_resource!(DartHeadHandle, Handle<Mesh>);
73declare_newtype_resource!(DartHeadMul, f32, 2.0);