summaryrefslogtreecommitdiff
path: root/engine/src/lighting.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-05-22 20:22:45 +0200
committerHampusM <hampus@hampusmat.com>2024-05-22 20:22:45 +0200
commitd9ab0016c8477f05a22ed569c0a70a5e9d68c3bb (patch)
tree1d0bd28dbefd042be265c2f2c63f580212290645 /engine/src/lighting.rs
parentd89c554388bfa6e325f03c53bc4bf2129a7df9b0 (diff)
refactor(engine): make PointLight non-exhaustive & add builder
Diffstat (limited to 'engine/src/lighting.rs')
-rw-r--r--engine/src/lighting.rs20
1 files changed, 20 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))]