@@ -19,19 +19,17 @@ use super::{
1919 VertexShader , View , ViewToProj , World , WorldToView ,
2020} ;
2121
22- /// Camera movement mode.
23- ///
24- /// TODO Rename to something more specific (e.g. `Motion`?)
25- pub trait Mode {
22+ /// Trait for different camera motion transforms.
23+ pub trait Transform {
2624 /// Returns the current world-to-view matrix of this camera mode.
2725 fn world_to_view ( & self ) -> Mat4x4 < WorldToView > ;
2826}
2927
3028/// Type to manage the world-to-viewport transformation.
3129#[ derive( Copy , Clone , Debug , Default ) ]
32- pub struct Camera < M > {
30+ pub struct Camera < Tf > {
3331 /// The movement mode of the camera.
34- pub mode : M ,
32+ pub transform : Tf ,
3533 /// Viewport width and height.
3634 pub dims : Dims ,
3735 /// Projection matrix.
@@ -85,9 +83,14 @@ impl Camera<()> {
8583 }
8684 }
8785
88- pub fn mode < M : Mode > ( self , mode : M ) -> Camera < M > {
86+ pub fn transform < M : Transform > ( self , mode : M ) -> Camera < M > {
8987 let Self { dims, project, viewport, .. } = self ;
90- Camera { mode, dims, project, viewport }
88+ Camera {
89+ transform : mode,
90+ dims,
91+ project,
92+ viewport,
93+ }
9194 }
9295}
9396
@@ -131,10 +134,10 @@ impl<M> Camera<M> {
131134 }
132135}
133136
134- impl < M : Mode > Camera < M > {
137+ impl < M : Transform > Camera < M > {
135138 /// Returns the composed camera and projection matrix.
136139 pub fn world_to_project ( & self ) -> Mat4x4 < RealToProj < World > > {
137- self . mode . world_to_view ( ) . then ( & self . project )
140+ self . transform . world_to_view ( ) . then ( & self . project )
138141 }
139142
140143 /// Renders the given geometry from the viewpoint of this camera.
@@ -262,7 +265,7 @@ impl Orbit {
262265//
263266
264267#[ cfg( feature = "fp" ) ]
265- impl Mode for FirstPerson {
268+ impl Transform for FirstPerson {
266269 fn world_to_view ( & self ) -> Mat4x4 < WorldToView > {
267270 let & Self { pos, heading, .. } = self ;
268271 let fwd_move = az_alt ( heading. az ( ) , turns ( 0.0 ) ) . to_cart ( ) ;
@@ -278,7 +281,7 @@ impl Mode for FirstPerson {
278281}
279282
280283#[ cfg( feature = "fp" ) ]
281- impl Mode for Orbit {
284+ impl Transform for Orbit {
282285 fn world_to_view ( & self ) -> Mat4x4 < WorldToView > {
283286 // TODO Figure out how to do this with orient
284287 //let fwd = self.dir.to_cart().normalize();
@@ -294,7 +297,7 @@ impl Mode for Orbit {
294297 }
295298}
296299
297- impl Mode for Mat4x4 < WorldToView > {
300+ impl Transform for Mat4x4 < WorldToView > {
298301 fn world_to_view ( & self ) -> Mat4x4 < WorldToView > {
299302 * self
300303 }
0 commit comments