Commit 71ca407 1 parent c92599f commit 71ca407 Copy full SHA for 71ca407
File tree 4 files changed +7
-2
lines changed
4 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -180,12 +180,15 @@ mod tests {
180
180
let model = & scene. models [ 0 ] ;
181
181
assert ! ( model. has_normals( ) ) ;
182
182
assert ! ( model. has_tex_coords( ) ) ;
183
- assert ! ( ! model. has_tangents( ) ) ;
183
+ assert ! ( model. has_tangents( ) ) ;
184
184
for t in model. triangles ( ) . unwrap ( ) . iter ( ) . flatten ( ) {
185
185
let pos = t. position ;
186
186
assert ! ( pos. x > -0.01 && pos. x < 1.01 ) ;
187
187
assert ! ( pos. y > -0.01 && pos. y < 1.01 ) ;
188
188
assert ! ( pos. z > -0.01 && pos. z < 1.01 ) ;
189
+
190
+ // Check that the tangent w component is 1 or -1
191
+ assert_eq ! ( t. tangent. w. abs( ) , 1. ) ;
189
192
}
190
193
}
191
194
Original file line number Diff line number Diff line change @@ -312,7 +312,8 @@ impl Model {
312
312
// Fill tangents
313
313
let has_tangents = if let Some ( tangents) = reader. read_tangents ( ) {
314
314
for ( i, tangent) in tangents. enumerate ( ) {
315
- vertices[ i] . tangent = Self :: apply_transform_tangent ( tangent, transform) . normalize ( ) ;
315
+ let tangent = Self :: apply_transform_tangent ( tangent, transform) ;
316
+ vertices[ i] . tangent = tangent. truncate ( ) . normalize ( ) . extend ( tangent. w ) ;
316
317
}
317
318
true
318
319
} else {
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ pub struct Vertex {
15
15
/// Normalized normal
16
16
pub normal : Vector3 < f32 > ,
17
17
/// Tangent normal
18
+ /// The w component is the handedness of the tangent basis (can be -1 or 1)
18
19
pub tangent : Vector4 < f32 > ,
19
20
/// Texture coordinates
20
21
pub tex_coords : Vector2 < f32 > ,
You can’t perform that action at this time.
0 commit comments