From d9ab0016c8477f05a22ed569c0a70a5e9d68c3bb Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 22 May 2024 20:22:45 +0200 Subject: refactor(engine): make PointLight non-exhaustive & add builder --- engine/src/lighting.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'engine/src/lighting.rs') 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, pub specular: Color, } +} + +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))] -- cgit v1.2.3-18-g5258