@@ -14,10 +14,7 @@ use super::{Aabb3d, Bounded3d, BoundingSphere};
14
14
15
15
impl Bounded3d for Sphere {
16
16
fn aabb_3d ( & self , translation : Vec3 , _rotation : Quat ) -> Aabb3d {
17
- Aabb3d {
18
- min : translation - Vec3 :: splat ( self . radius ) ,
19
- max : translation + Vec3 :: splat ( self . radius ) ,
20
- }
17
+ Aabb3d :: new ( translation, Vec3 :: splat ( self . radius ) )
21
18
}
22
19
23
20
fn bounding_sphere ( & self , translation : Vec3 , _rotation : Quat ) -> BoundingSphere {
@@ -39,10 +36,7 @@ impl Bounded3d for Plane3d {
39
36
let half_depth = if facing_z { 0.0 } else { f32:: MAX / 2.0 } ;
40
37
let half_size = Vec3 :: new ( half_width, half_height, half_depth) ;
41
38
42
- Aabb3d {
43
- min : translation - half_size,
44
- max : translation + half_size,
45
- }
39
+ Aabb3d :: new ( translation, half_size)
46
40
}
47
41
48
42
fn bounding_sphere ( & self , translation : Vec3 , _rotation : Quat ) -> BoundingSphere {
@@ -62,10 +56,7 @@ impl Bounded3d for Line3d {
62
56
let half_depth = if direction. z == 0.0 { 0.0 } else { max } ;
63
57
let half_size = Vec3 :: new ( half_width, half_height, half_depth) ;
64
58
65
- Aabb3d {
66
- min : translation - half_size,
67
- max : translation + half_size,
68
- }
59
+ Aabb3d :: new ( translation, half_size)
69
60
}
70
61
71
62
fn bounding_sphere ( & self , translation : Vec3 , _rotation : Quat ) -> BoundingSphere {
@@ -77,12 +68,9 @@ impl Bounded3d for Segment3d {
77
68
fn aabb_3d ( & self , translation : Vec3 , rotation : Quat ) -> Aabb3d {
78
69
// Rotate the segment by `rotation`
79
70
let direction = rotation * * self . direction ;
80
- let half_extent = ( self . half_length * direction) . abs ( ) ;
71
+ let half_size = ( self . half_length * direction) . abs ( ) ;
81
72
82
- Aabb3d {
83
- min : translation - half_extent,
84
- max : translation + half_extent,
85
- }
73
+ Aabb3d :: new ( translation, half_size)
86
74
}
87
75
88
76
fn bounding_sphere ( & self , translation : Vec3 , _rotation : Quat ) -> BoundingSphere {
@@ -112,7 +100,7 @@ impl Bounded3d for BoxedPolyline3d {
112
100
113
101
impl Bounded3d for Cuboid {
114
102
fn aabb_3d ( & self , translation : Vec3 , rotation : Quat ) -> Aabb3d {
115
- // Compute the AABB of the rotated cuboid by transforming the half-extents
103
+ // Compute the AABB of the rotated cuboid by transforming the half-size
116
104
// by an absolute rotation matrix.
117
105
let rot_mat = Mat3 :: from_quat ( rotation) ;
118
106
let abs_rot_mat = Mat3 :: from_cols (
@@ -122,10 +110,7 @@ impl Bounded3d for Cuboid {
122
110
) ;
123
111
let half_size = abs_rot_mat * self . half_size ;
124
112
125
- Aabb3d {
126
- min : translation - half_size,
127
- max : translation + half_size,
128
- }
113
+ Aabb3d :: new ( translation, half_size)
129
114
}
130
115
131
116
fn bounding_sphere ( & self , translation : Vec3 , _rotation : Quat ) -> BoundingSphere {
@@ -147,11 +132,11 @@ impl Bounded3d for Cylinder {
147
132
let bottom = -top;
148
133
149
134
let e = Vec3 :: ONE - segment_dir * segment_dir;
150
- let half_extents = self . radius * Vec3 :: new ( e. x . sqrt ( ) , e. y . sqrt ( ) , e. z . sqrt ( ) ) ;
135
+ let half_size = self . radius * Vec3 :: new ( e. x . sqrt ( ) , e. y . sqrt ( ) , e. z . sqrt ( ) ) ;
151
136
152
137
Aabb3d {
153
- min : translation + ( top - half_extents ) . min ( bottom - half_extents ) ,
154
- max : translation + ( top + half_extents ) . max ( bottom + half_extents ) ,
138
+ min : translation + ( top - half_size ) . min ( bottom - half_size ) ,
139
+ max : translation + ( top + half_size ) . max ( bottom + half_size ) ,
155
140
}
156
141
}
157
142
@@ -305,15 +290,12 @@ impl Bounded3d for Torus {
305
290
// Reference: http://iquilezles.org/articles/diskbbox/
306
291
let normal = rotation * Vec3 :: Y ;
307
292
let e = 1.0 - normal * normal;
308
- let disc_half_extents = self . major_radius * Vec3 :: new ( e. x . sqrt ( ) , e. y . sqrt ( ) , e. z . sqrt ( ) ) ;
293
+ let disc_half_size = self . major_radius * Vec3 :: new ( e. x . sqrt ( ) , e. y . sqrt ( ) , e. z . sqrt ( ) ) ;
309
294
310
- // Expand the disc by the minor radius to get the torus half extents
311
- let half_extents = disc_half_extents + Vec3 :: splat ( self . minor_radius ) ;
295
+ // Expand the disc by the minor radius to get the torus half-size
296
+ let half_size = disc_half_size + Vec3 :: splat ( self . minor_radius ) ;
312
297
313
- Aabb3d {
314
- min : translation - half_extents,
315
- max : translation + half_extents,
316
- }
298
+ Aabb3d :: new ( translation, half_size)
317
299
}
318
300
319
301
fn bounding_sphere ( & self , translation : Vec3 , _rotation : Quat ) -> BoundingSphere {
0 commit comments