From d89c554388bfa6e325f03c53bc4bf2129a7df9b0 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 22 May 2024 20:18:11 +0200 Subject: refactor: rename LightSource to PointLight --- engine/src/renderer/mod.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engine/src/renderer/mod.rs') diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs index d843020..e736165 100644 --- a/engine/src/renderer/mod.rs +++ b/engine/src/renderer/mod.rs @@ -12,7 +12,7 @@ use crate::camera::Camera; use crate::color::Color; use crate::data_types::dimens::Dimens; use crate::event::{Present as PresentEvent, Start as StartEvent}; -use crate::lighting::{GlobalLight, LightSource}; +use crate::lighting::{GlobalLight, PointLight}; use crate::material::{Flags as MaterialFlags, Material}; use crate::matrix::Matrix; use crate::mesh::Mesh; @@ -98,7 +98,7 @@ fn render( Option, Transform, )>, - light_source_query: Query<(LightSource, Transform)>, + point_light_query: Query<(PointLight, Transform)>, camera_query: Query<(Camera,)>, window: Single, global_light: Single, @@ -117,12 +117,12 @@ fn render( return; }; - // TODO: Maybe find a way to not clone here? Cloning here is needed since a light - // source transform can be in both the object query and the light source query - let light_source = light_source_query + // TODO: Maybe find a way to not clone here? Cloning here is needed since a transform + // can be in both the object query and the light source query + let point_light = point_light_query .iter() .next() - .map(|(light_source, transform)| (light_source.clone(), transform.clone())); + .map(|(point_light, transform)| (point_light.clone(), transform.clone())); let GlObjects { shader_programs: gl_shader_programs, @@ -152,10 +152,10 @@ fn render( &material_flags, &global_light, shader_program, - light_source + point_light .as_ref() - .map(|(light_source, light_source_transform)| { - (light_source, light_source_transform) + .map(|(point_light, point_light_transform)| { + (point_light, point_light_transform) }), &camera, ); @@ -360,31 +360,31 @@ fn apply_light( material_flags: &MaterialFlags, global_light: &GlobalLight, gl_shader_program: &mut GlShaderProgram, - light_source: Option<(&LightSource, &Transform)>, + point_light: Option<(&PointLight, &Transform)>, camera: &Camera, ) { gl_shader_program.set_uniform_vec_3fv( cstr!("light.position"), - &light_source.map_or_else(Vec3::default, |(_, light_source_transform)| { - light_source_transform.position + &point_light.map_or_else(Vec3::default, |(_, point_light_transform)| { + point_light_transform.position }), ); gl_shader_program.set_uniform_vec_3fv( cstr!("light.diffuse"), - &light_source - .map_or(Color::WHITE_F32, |(light_source, _)| { - light_source.diffuse.clone() + &point_light + .map_or(Color::WHITE_F32, |(point_light, _)| { + point_light.diffuse.clone() }) .into(), ); gl_shader_program.set_uniform_vec_3fv( cstr!("light.specular"), - &light_source - .map_or(Color::WHITE_F32, |(light_source, _)| { - light_source.specular.clone() + &point_light + .map_or(Color::WHITE_F32, |(point_light, _)| { + point_light.specular.clone() }) .into(), ); -- cgit v1.2.3-18-g5258