summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/src/lighting.rs20
-rw-r--r--engine/src/util.rs12
2 files changed, 32 insertions, 0 deletions
diff --git a/engine/src/lighting.rs b/engine/src/lighting.rs
index e79c1bc..bfc2d9b 100644
--- a/engine/src/lighting.rs
+++ b/engine/src/lighting.rs
@@ -3,12 +3,24 @@ use ecs::{Component, Sole};
use crate::color::Color;
use crate::util::builder;
+builder! {
+#[builder(name = PointLightBuilder, derives = (Debug, Clone))]
#[derive(Debug, Clone, Component)]
+#[non_exhaustive]
pub struct PointLight
{
pub diffuse: Color<f32>,
pub specular: Color<f32>,
}
+}
+
+impl PointLight
+{
+ pub fn builder() -> PointLightBuilder
+ {
+ PointLightBuilder::default()
+ }
+}
impl Default for PointLight
{
@@ -21,6 +33,14 @@ impl Default for PointLight
}
}
+impl Default for PointLightBuilder
+{
+ fn default() -> Self
+ {
+ PointLight::default().into()
+ }
+}
+
builder! {
/// Global light properties.
#[builder(name = GlobalLightBuilder, derives = (Debug, Clone, Default))]
diff --git a/engine/src/util.rs b/engine/src/util.rs
index 409b98f..532bdee 100644
--- a/engine/src/util.rs
+++ b/engine/src/util.rs
@@ -77,6 +77,18 @@ macro_rules! builder {
}
}
}
+
+ impl From<$name> for $builder_name
+ {
+ fn from(built: $name) -> Self
+ {
+ Self {
+ $(
+ $field: built.$field,
+ )*
+ }
+ }
+ }
};
}