File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
crates/bevy_render/src/mesh/shape Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,6 @@ impl From<Torus> for Mesh {
37
37
38
38
for segment in 0 ..=torus. subdivisions_segments {
39
39
let theta = segment_stride * segment as f32 ;
40
- let segment_pos = Vec3 :: new ( theta. cos ( ) , 0.0 , theta. sin ( ) * torus. radius ) ;
41
40
42
41
for side in 0 ..=torus. subdivisions_sides {
43
42
let phi = side_stride * side as f32 ;
@@ -46,7 +45,14 @@ impl From<Torus> for Mesh {
46
45
let z = theta. sin ( ) * ( torus. radius + torus. ring_radius * phi. cos ( ) ) ;
47
46
let y = torus. ring_radius * phi. sin ( ) ;
48
47
49
- let normal = segment_pos. cross ( Vec3 :: Y ) . normalize ( ) ;
48
+ let tan_ring = Vec3 :: new (
49
+ theta. cos ( ) * phi. sin ( ) * -1.0 ,
50
+ theta. sin ( ) * phi. sin ( ) * -1.0 ,
51
+ phi. cos ( ) ,
52
+ ) ;
53
+ let tan = Vec3 :: new ( theta. sin ( ) * -1.0 , theta. cos ( ) , 0.0 ) ;
54
+
55
+ let normal = tan. cross ( tan_ring) . normalize ( ) ;
50
56
51
57
positions. push ( [ x, y, z] ) ;
52
58
normals. push ( normal. into ( ) ) ;
You can’t perform that action at this time.
0 commit comments