@@ -30,6 +30,8 @@ pub struct Image<N: Copy + RealField> {
3030 compute_mat : bool ,
3131 /// Whether to compute inverse transformation. Default is `true`.
3232 compute_inv : bool ,
33+ /// Whether to use passive transformations. Default is `false`.
34+ use_passive : bool ,
3335}
3436
3537impl < N : Copy + RealField > Image < N > {
@@ -49,11 +51,14 @@ impl<N: Copy + RealField> Image<N> {
4951 proj_view_inv : zero ( ) ,
5052 compute_mat : true ,
5153 compute_inv : true ,
54+ use_passive : false ,
5255 } ;
53- image. compute_view ( frame) ;
54- image. compute_projection_and_upp ( frame. distance ( ) , scope) ;
55- image. compute_transformation ( ) ;
56- image. compute_inverse_transformation ( ) ;
56+ if frame. distance ( ) != N :: zero ( ) {
57+ image. compute_view ( frame) ;
58+ image. compute_projection_and_upp ( frame. distance ( ) , scope) ;
59+ image. compute_transformation ( ) ;
60+ image. compute_inverse_transformation ( ) ;
61+ }
5762 image
5863 }
5964 /// Recomputes only cached matrices whose parameters have changed, see [`Self::set_compute()`].
@@ -90,6 +95,12 @@ impl<N: Copy + RealField> Image<N> {
9095 self . compute_mat = compute_mat;
9196 self . compute_inv = compute_inv;
9297 }
98+ /// Sets whether to use passive transformations.
99+ ///
100+ /// Default is `false`.
101+ pub const fn set_passive ( & mut self , use_passive : bool ) {
102+ self . use_passive = use_passive;
103+ }
93104 /// Current position in screen space of hovering input or pointing device.
94105 #[ must_use]
95106 pub const fn pos ( & self ) -> & Point2 < N > {
@@ -129,7 +140,11 @@ impl<N: Copy + RealField> Image<N> {
129140 }
130141 /// Computes view isometry and matrix from frame wrt camera eye and target.
131142 pub fn compute_view ( & mut self , frame : & Frame < N > ) {
132- self . view_iso = frame. view ( ) ;
143+ self . view_iso = if self . use_passive {
144+ frame. inverse_view ( )
145+ } else {
146+ frame. view ( )
147+ } ;
133148 self . view_mat = self . view_iso . to_homogeneous ( ) ;
134149 }
135150 /// Cached projection matrix.
@@ -229,6 +244,7 @@ impl<N: Copy + RealField> Image<N> {
229244 proj_view_inv : self . proj_view_inv . cast ( ) ,
230245 compute_mat : self . compute_mat ,
231246 compute_inv : self . compute_inv ,
247+ use_passive : self . use_passive ,
232248 }
233249 }
234250}
0 commit comments