Skip to content

Commit 4bc2b3f

Browse files
committed
Fixup light source
1 parent f855399 commit 4bc2b3f

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

core/src/render/cam.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ use crate::math::{
99
};
1010
use crate::util::{Dims, rect::Rect};
1111

12-
#[cfg(feature = "fp")]
13-
use crate::math::{
14-
Angle, Vec3, orient_z, pt3, rotate_x, rotate_y, spherical, translate, turns,
15-
};
16-
1712
use super::{
1813
Clip, Context, FragmentShader, NdcToScreen, RealToProj, Render, Target,
1914
VertexShader, View, ViewToProj, World, WorldToView, clip::ClipVec,
2015
};
16+
#[cfg(feature = "fp")]
17+
use crate::math::{
18+
Angle, Vec3, orient_z, pt3, rotate_x, rotate_y, spherical, translate, turns,
19+
};
20+
use crate::prelude::Shader;
2121

2222
/// Trait for different modes of camera motion.
2323
pub trait Transform {
@@ -198,6 +198,9 @@ impl<T> Camera<T> {
198198
}
199199
}
200200

201+
// TODO Should probably pass view and projection matrices separately
202+
pub type CameraUni<'a, B, Uni> = (&'a Mat4x4<RealToProj<B>>, Uni);
203+
201204
impl<T: Transform> Camera<T> {
202205
/// Returns the composed camera and projection matrix.
203206
pub fn world_to_project(&self) -> Mat4x4<RealToProj<World>> {
@@ -221,23 +224,18 @@ impl<T: Transform> Camera<T> {
221224
) where
222225
Prim: Render<Var> + Clone,
223226
[<Prim>::Clip]: Clip<Item = Prim::Clip>,
224-
Shd: for<'a> VertexShader<
225-
Vtx,
226-
(&'a Mat4x4<RealToProj<B>>, Uni),
227-
Output = Vertex<ClipVec, Var>,
228-
> + FragmentShader<Var, Uni>,
227+
Shd: for<'a> Shader<Vtx, Var, CameraUni<'a, B, Uni>>,
229228
{
230-
/*let tf = to_world.then(&self.world_to_project());
231-
229+
let to_proj = to_world.then(&self.world_to_project());
232230
super::render(
233231
prims.as_ref(),
234232
verts.as_ref(),
235233
shader,
236-
(&tf, uniform),
234+
(&to_proj, uniform),
237235
self.viewport,
238236
target,
239237
ctx,
240-
);*/
238+
);
241239
}
242240
}
243241

core/src/render/light.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ pub enum Kind<B: Default> {
3131
Point {
3232
pos: Point3<B>,
3333
},
34-
#[cfg(feature = "fp")]
3534
Spot {
3635
pos: Point3<B>,
3736
dir: Vec3<B>,
@@ -98,7 +97,6 @@ impl<B: Debug + Default> Light<B> {
9897
Kind::Directional { dir } => {
9998
Kind::Directional { dir: mat.to().apply3(&dir) }
10099
}
101-
#[cfg(feature = "fp")]
102100
Kind::Spot { pos, dir, radii } => Kind::Spot {
103101
pos: mat.apply_pt(&pos),
104102
dir: mat.to().apply3(&dir),

core/src/render/raster.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ mod tests {
373373
super::tri_fill(verts, |mut sl| {
374374
write!(s, "{:w$}", " ", w = sl.xs.start).ok();
375375

376-
for c in sl.fragments().map(|f| ((10.0 * f.var) as u8)) {
376+
for c in sl.fragments().map(|f| (10.0 * f.var) as u8) {
377377
write!(s, "{c}").ok();
378378
}
379379
writeln!(s).ok();

0 commit comments

Comments
 (0)