summaryrefslogtreecommitdiff
path: root/engine/src
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src')
-rw-r--r--engine/src/material.rs24
-rw-r--r--engine/src/renderer/mod.rs18
2 files changed, 15 insertions, 27 deletions
diff --git a/engine/src/material.rs b/engine/src/material.rs
index c896084..880f689 100644
--- a/engine/src/material.rs
+++ b/engine/src/material.rs
@@ -7,9 +7,9 @@ use crate::texture::{Id as TextureId, Texture};
#[derive(Debug, Clone, Component)]
pub struct Material
{
- ambient: Option<Color<f32>>,
- diffuse: Option<Color<f32>>,
- specular: Option<Color<f32>>,
+ ambient: Color<f32>,
+ diffuse: Color<f32>,
+ specular: Color<f32>,
ambient_map: TextureId,
diffuse_map: TextureId,
specular_map: TextureId,
@@ -20,21 +20,21 @@ pub struct Material
impl Material
{
#[must_use]
- pub fn ambient(&self) -> Option<&Color<f32>>
+ pub fn ambient(&self) -> &Color<f32>
{
- self.ambient.as_ref()
+ &self.ambient
}
#[must_use]
- pub fn diffuse(&self) -> Option<&Color<f32>>
+ pub fn diffuse(&self) -> &Color<f32>
{
- self.diffuse.as_ref()
+ &self.diffuse
}
#[must_use]
- pub fn specular(&self) -> Option<&Color<f32>>
+ pub fn specular(&self) -> &Color<f32>
{
- self.specular.as_ref()
+ &self.specular
}
#[must_use]
@@ -206,9 +206,9 @@ impl Builder
});
Material {
- ambient: self.ambient.clone(),
- diffuse: self.diffuse.clone(),
- specular: self.specular.clone(),
+ ambient: self.ambient.unwrap_or_default(),
+ diffuse: self.diffuse.unwrap_or_default(),
+ specular: self.specular.unwrap_or_default(),
ambient_map,
diffuse_map,
specular_map,
diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs
index fbb86f7..e2a567a 100644
--- a/engine/src/renderer/mod.rs
+++ b/engine/src/renderer/mod.rs
@@ -385,30 +385,18 @@ fn apply_light(
gl_shader_program.set_uniform_vec_3fv(
cstr!("material.ambient"),
- &material
- .ambient()
- .cloned()
- .unwrap_or(Color { red: 1.0, green: 1.0, blue: 1.0 })
- .into(),
+ &material.ambient().clone().into(),
);
gl_shader_program.set_uniform_vec_3fv(
cstr!("material.diffuse"),
- &material
- .diffuse()
- .cloned()
- .unwrap_or(Color { red: 1.0, green: 1.0, blue: 1.0 })
- .into(),
+ &material.diffuse().clone().into(),
);
#[allow(clippy::cast_possible_wrap)]
gl_shader_program.set_uniform_vec_3fv(
cstr!("material.specular"),
- &material
- .specular()
- .cloned()
- .unwrap_or(Color { red: 1.0, green: 1.0, blue: 1.0 })
- .into(),
+ &material.specular().clone().into(),
);
#[allow(clippy::cast_possible_wrap)]