@@ -140,7 +140,7 @@ impl ProjectionMatrix {
140
140
}
141
141
142
142
/// The helper struct to build a projection matrix
143
- #[ derive( Copy , Clone ) ]
143
+ #[ derive( Clone ) ]
144
144
pub struct ProjectionMatrixBuilder {
145
145
/// Specifies the yaw of the 3D coordinate system
146
146
pub yaw : f64 ,
@@ -150,6 +150,7 @@ pub struct ProjectionMatrixBuilder {
150
150
pub scale : f64 ,
151
151
pivot_before : ( i32 , i32 , i32 ) ,
152
152
pivot_after : ( i32 , i32 ) ,
153
+ transformation_queue : Vec < ProjectionMatrix > ,
153
154
}
154
155
155
156
impl Default for ProjectionMatrixBuilder {
@@ -160,6 +161,7 @@ impl Default for ProjectionMatrixBuilder {
160
161
scale : 1.0 ,
161
162
pivot_after : ( 0 , 0 ) ,
162
163
pivot_before : ( 0 , 0 , 0 ) ,
164
+ transformation_queue : [ ] . to_vec ( ) ,
163
165
}
164
166
}
165
167
}
@@ -178,6 +180,12 @@ impl ProjectionMatrixBuilder {
178
180
self
179
181
}
180
182
183
+ /// Adds matrix to list of transformations to apply
184
+ pub fn add_transform ( & mut self , projection : ProjectionMatrix ) -> & mut Self {
185
+ self . transformation_queue . push ( projection) ;
186
+ self
187
+ }
188
+
181
189
/// Build the matrix based on the configuration
182
190
pub fn into_matrix ( self ) -> ProjectionMatrix {
183
191
let mut ret = if self . pivot_before == ( 0 , 0 , 0 ) {
@@ -187,6 +195,10 @@ impl ProjectionMatrixBuilder {
187
195
ProjectionMatrix :: shift ( -x as f64 , -y as f64 , -z as f64 ) * ProjectionMatrix :: default ( )
188
196
} ;
189
197
198
+ for transform in self . transformation_queue {
199
+ ret = ret * transform;
200
+ }
201
+
190
202
if self . yaw . abs ( ) > 1e-20 {
191
203
ret = ret * ProjectionMatrix :: rotate ( 0.0 , self . yaw , 0.0 ) ;
192
204
}
0 commit comments