summaryrefslogtreecommitdiff
path: root/engine/src/renderer/mod.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-05-22 20:18:11 +0200
committerHampusM <hampus@hampusmat.com>2024-05-22 20:18:11 +0200
commitd89c554388bfa6e325f03c53bc4bf2129a7df9b0 (patch)
treefb02381e3ceb35dd1f4d65c8872848ee338f7104 /engine/src/renderer/mod.rs
parent0f53ae83a4d8da002850859fe0d010c5df4f2f57 (diff)
refactor: rename LightSource to PointLight
Diffstat (limited to 'engine/src/renderer/mod.rs')
-rw-r--r--engine/src/renderer/mod.rs36
1 files changed, 18 insertions, 18 deletions
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<MaterialFlags>,
Transform,
)>,
- light_source_query: Query<(LightSource, Transform)>,
+ point_light_query: Query<(PointLight, Transform)>,
camera_query: Query<(Camera,)>,
window: Single<Window>,
global_light: Single<GlobalLight>,
@@ -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(),
);