@@ -21,7 +21,7 @@ use gloog_core::types::{
21
21
VertexAttribType ,
22
22
} ;
23
23
use gloog_core:: { GLContext , InitFailureMode } ;
24
- use gloog_math:: { Mat3 , Mat4 , Vec3 , Vec4 } ;
24
+ use gloog_math:: { Mat4 , Vec3 , Vec4 } ;
25
25
use log:: { debug, info, log} ;
26
26
27
27
@@ -90,7 +90,7 @@ fn run(model_path: String) -> Result<(), Box<dyn Error>> {
90
90
gl. uniform ( uniforms. lights [ i] . ambient , & light. ambient ) ;
91
91
gl. uniform ( uniforms. lights [ i] . specular , & light. specular ) ;
92
92
93
- let lp4_ws = Vec4 :: from3 ( light. position , 1.0 ) ;
93
+ let lp4_ws = Vec4 :: from_vec3 ( light. position , 1.0 ) ;
94
94
let lp4_vs = view_matrix * lp4_ws;
95
95
let lp3_vs = Vec3 :: new ( lp4_vs[ 0 ] , lp4_vs[ 1 ] , lp4_vs[ 2 ] ) ;
96
96
@@ -217,18 +217,10 @@ impl<'gl, 'a> Thingy<'gl, 'a> {
217
217
let & Self { gl, model, vao, .. } = self ;
218
218
219
219
let model_matrix = model_matrix ( & self . pos , & self . rot , & self . scl ) ;
220
- let normal_matrix = ( view_matrix * model_matrix) . inverse ( ) . transpose ( ) ;
221
-
222
- // TODO: actually write a method to trim a Mat4 down to a Mat3 (and Vec4->Vec3 too lol)
223
- #[ rustfmt:: skip]
224
- let norm_matrix = Mat3 :: new (
225
- normal_matrix[ [ 0 , 0 ] ] , normal_matrix[ [ 0 , 1 ] ] , normal_matrix[ [ 0 , 2 ] ] ,
226
- normal_matrix[ [ 1 , 0 ] ] , normal_matrix[ [ 1 , 1 ] ] , normal_matrix[ [ 1 , 2 ] ] ,
227
- normal_matrix[ [ 2 , 0 ] ] , normal_matrix[ [ 2 , 1 ] ] , normal_matrix[ [ 2 , 2 ] ] ,
228
- ) ;
220
+ let normal_matrix = ( view_matrix * model_matrix) . inverse ( ) . transpose ( ) . to_mat3 ( ) ;
229
221
230
222
gl. uniform ( uniforms. matrix . model , & model_matrix) ;
231
- gl. uniform ( uniforms. matrix . normal , & norm_matrix ) ;
223
+ gl. uniform ( uniforms. matrix . normal , & normal_matrix ) ;
232
224
233
225
gl. bind_vertex_array ( vao) ;
234
226
0 commit comments