diff options
| author | HampusM <hampus@hampusmat.com> | 2026-03-20 14:22:19 +0100 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-03-20 14:22:19 +0100 |
| commit | f285f82072b491b1f3cc92db8e08485f26779d5a (patch) | |
| tree | bf6c6c61cdfb3a12550e55966c8552957ade9e71 /engine/src/material.rs | |
| parent | 0546d575c11d3668d0f95933697ae4f670fe2a55 (diff) | |
Diffstat (limited to 'engine/src/material.rs')
| -rw-r--r-- | engine/src/material.rs | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/engine/src/material.rs b/engine/src/material.rs index 2b9a8ca..94ab24e 100644 --- a/engine/src/material.rs +++ b/engine/src/material.rs @@ -21,9 +21,9 @@ pub struct Material impl Material { - pub fn builder() -> Builder + pub const fn builder() -> Builder { - Builder::default() + Builder::new() } } @@ -51,7 +51,7 @@ pub struct Builder impl Builder { #[must_use] - pub fn new() -> Self + pub const fn new() -> Self { Self { ambient: Color::WHITE_F32, @@ -125,7 +125,7 @@ impl Builder /// # Panics /// Will panic if no ambient map, diffuse map or specular map is set. #[must_use] - pub fn build(self) -> Material + pub const fn build(self) -> Material { Material { ambient: self.ambient, @@ -149,8 +149,8 @@ impl Default for Builder builder! { /// Material flags. -#[builder(name = FlagsBuilder, derives = (Debug, Default, Clone))] -#[derive(Debug, Default, Clone, Component)] +#[builder(name = FlagsBuilder, derives = (Debug, Clone))] +#[derive(Debug, Clone, Component)] #[non_exhaustive] pub struct Flags { @@ -163,8 +163,32 @@ pub struct Flags impl Flags { #[must_use] - pub fn builder() -> FlagsBuilder + pub const fn builder() -> FlagsBuilder { - FlagsBuilder::default() + FlagsBuilder::new() + } +} + +impl Default for Flags +{ + fn default() -> Self + { + Self::builder().build() + } +} + +impl FlagsBuilder +{ + pub const fn new() -> Self + { + Self { use_ambient_color: false } + } +} + +impl Default for FlagsBuilder +{ + fn default() -> Self + { + Self::new() } } |
