@@ -28,7 +28,7 @@ impl Aabb {
28
28
29
29
/// Ending corner. This is calculated as `position + size`.
30
30
#[ inline]
31
- pub fn end ( & self ) -> Vector3 {
31
+ pub fn end ( self ) -> Vector3 {
32
32
self . position + self . size
33
33
}
34
34
@@ -41,7 +41,7 @@ impl Aabb {
41
41
/// Returns an `Aabb` with equivalent position and area, modified so that the most-negative
42
42
/// corner is the origin and the size is positive.
43
43
#[ inline]
44
- pub fn abs ( & self ) -> Self {
44
+ pub fn abs ( self ) -> Self {
45
45
let position = self . position + Vector3 :: gd ( self . size . glam ( ) . min ( glam:: Vec3A :: ZERO ) ) ;
46
46
let size = self . size . abs ( ) ;
47
47
@@ -54,7 +54,7 @@ impl Aabb {
54
54
///
55
55
/// [get_area]: https://docs.godotengine.org/en/stable/classes/class_aabb.html#class-aabb-method-get-area
56
56
#[ inline]
57
- pub fn get_volume ( & self ) -> f32 {
57
+ pub fn get_volume ( self ) -> f32 {
58
58
self . size . x * self . size . y * self . size . z
59
59
}
60
60
@@ -68,13 +68,13 @@ impl Aabb {
68
68
///
69
69
/// [`has_no_area`]: https://docs.godotengine.org/en/stable/classes/class_aabb.html#class-aabb-method-has-no-area
70
70
#[ inline]
71
- pub fn has_no_volume ( & self ) -> bool {
71
+ pub fn has_no_volume ( self ) -> bool {
72
72
self . size . x <= 0.0 || self . size . y <= 0.0 || self . size . z <= 0.0
73
73
}
74
74
75
75
/// Returns true if the bounding box is empty or all of its dimensions are negative.
76
76
#[ inline]
77
- pub fn has_no_surface ( & self ) -> bool {
77
+ pub fn has_no_surface ( self ) -> bool {
78
78
self . size . x <= 0.0 && self . size . y <= 0.0 && self . size . z <= 0.0
79
79
}
80
80
@@ -84,7 +84,7 @@ impl Aabb {
84
84
/// Note: This method is not reliable for bounding boxes with a negative size. Use
85
85
/// [`abs`][Self::abs] to get a positive sized equivalent box to check for contained points.
86
86
#[ inline]
87
- pub fn contains_point ( & self , point : Vector3 ) -> bool {
87
+ pub fn contains_point ( self , point : Vector3 ) -> bool {
88
88
let point = point - self . position ;
89
89
90
90
point. abs ( ) == point
@@ -96,15 +96,15 @@ impl Aabb {
96
96
/// Returns true if this bounding box and `b` are approximately equal, by calling
97
97
/// [`is_equal_approx`](Vector3::is_equal_approx) on each component.
98
98
#[ inline]
99
- pub fn is_equal_approx ( & self , b : Self ) -> bool {
99
+ pub fn is_equal_approx ( self , b : Self ) -> bool {
100
100
self . position . is_equal_approx ( b. position ) && self . size . is_equal_approx ( b. size )
101
101
}
102
102
103
103
/// Gets the position of the 8 endpoints of the bounding box in space.
104
104
///
105
105
/// The index returns an arbitrary point, but all points are guaranteed to be unique.
106
106
#[ inline]
107
- pub fn get_endpoint ( & self , index : usize ) -> Option < Vector3 > {
107
+ pub fn get_endpoint ( self , index : usize ) -> Option < Vector3 > {
108
108
match index {
109
109
0 => Some ( self . position ) ,
110
110
1 => Some ( self . position + Vector3 :: new ( 0.0 , 0.0 , self . size . z ) ) ,
@@ -120,42 +120,42 @@ impl Aabb {
120
120
121
121
/// Returns the normalized longest axis of the bounding box.
122
122
#[ inline]
123
- pub fn get_longest_axis ( & self ) -> Vector3 {
123
+ pub fn get_longest_axis ( self ) -> Vector3 {
124
124
self . size . max_axis ( ) . to_unit_vector ( )
125
125
}
126
126
127
127
/// Returns the index of the longest axis of the bounding box.
128
128
///
129
129
/// If multiple axes have the same length, then the first in order X, Y, Z is returned.
130
130
#[ inline]
131
- pub fn get_longest_axis_index ( & self ) -> Axis {
131
+ pub fn get_longest_axis_index ( self ) -> Axis {
132
132
self . size . max_axis ( )
133
133
}
134
134
135
135
/// Returns the scalar length of the longest axis of the bounding box.
136
136
#[ inline]
137
- pub fn get_longest_axis_size ( & self ) -> f32 {
137
+ pub fn get_longest_axis_size ( self ) -> f32 {
138
138
let Vector3 { x, y, z } = self . size ;
139
139
x. max ( y) . max ( z)
140
140
}
141
141
142
142
/// Returns the normalized shortest axis of the bounding box.
143
143
#[ inline]
144
- pub fn get_shortest_axis ( & self ) -> Vector3 {
144
+ pub fn get_shortest_axis ( self ) -> Vector3 {
145
145
self . size . min_axis ( ) . to_unit_vector ( )
146
146
}
147
147
148
148
/// Returns the index of the shortest axis of the bounding box.
149
149
///
150
150
/// If multiple axes have the same length, then the first in order X, Y, Z is returned.
151
151
#[ inline]
152
- pub fn get_shortest_axis_index ( & self ) -> Axis {
152
+ pub fn get_shortest_axis_index ( self ) -> Axis {
153
153
self . size . min_axis ( )
154
154
}
155
155
156
156
/// Returns the scalar length of the shortest axis of the bounding box.
157
157
#[ inline]
158
- pub fn get_shortest_axis_size ( & self ) -> f32 {
158
+ pub fn get_shortest_axis_size ( self ) -> f32 {
159
159
let Vector3 { x, y, z } = self . size ;
160
160
x. min ( y) . min ( z)
161
161
}
@@ -173,7 +173,7 @@ impl Aabb {
173
173
/// [1]: https://ncollide.org/geometric_representations/#support-mappings
174
174
/// [2]: https://www.toptal.com/game/video-game-physics-part-ii-collision-detection-for-solid-objects
175
175
#[ inline]
176
- pub fn get_support ( & self , dir : Vector3 ) -> Vector3 {
176
+ pub fn get_support ( self , dir : Vector3 ) -> Vector3 {
177
177
self . position
178
178
+ Vector3 :: new (
179
179
if dir. x > 0.0 { 0.0 } else { self . size . x } ,
@@ -187,7 +187,7 @@ impl Aabb {
187
187
/// It is possible to specify a negative amount to shrink the AABB (note that this can invert the AABB).
188
188
#[ inline]
189
189
#[ must_use]
190
- pub fn grow ( & self , by : f32 ) -> Self {
190
+ pub fn grow ( self , by : f32 ) -> Self {
191
191
let position = self . position - Vector3 :: new ( by, by, by) ;
192
192
let size = self . size + Vector3 :: new ( by, by, by) * 2.0 ;
193
193
@@ -198,7 +198,7 @@ impl Aabb {
198
198
///
199
199
/// This **excludes** borders; if the intersection has no volume, `false` is returned.
200
200
#[ inline]
201
- pub fn intersects ( & self , b : Self ) -> bool {
201
+ pub fn intersects ( self , b : Self ) -> bool {
202
202
self . position . x < b. position . x + b. size . x
203
203
&& self . position . x + self . size . x > b. position . x
204
204
&& self . position . y < b. position . y + b. size . y
@@ -209,7 +209,7 @@ impl Aabb {
209
209
210
210
/// Returns true if the bounding box is on both sides of a plane.
211
211
#[ inline]
212
- pub fn intersects_plane ( & self , plane : Plane ) -> bool {
212
+ pub fn intersects_plane ( self , plane : Plane ) -> bool {
213
213
let mut corners = [ Vector3 :: ZERO ; 8 ] ;
214
214
for ( i, corner) in corners. iter_mut ( ) . enumerate ( ) {
215
215
* corner = self . get_endpoint ( i) . unwrap ( ) ;
@@ -230,7 +230,7 @@ impl Aabb {
230
230
231
231
/// Returns true if the bounding box intersects the line segment between `from` and `to`.
232
232
#[ inline]
233
- pub fn intersects_segment ( & self , from : Vector3 , to : Vector3 ) -> bool {
233
+ pub fn intersects_segment ( self , from : Vector3 , to : Vector3 ) -> bool {
234
234
let mut min: f32 = 0.0 ;
235
235
let mut max: f32 = 1.0 ;
236
236
@@ -283,7 +283,7 @@ impl Aabb {
283
283
/// This **excludes** borders; if the intersection has no volume, `None` is returned.
284
284
#[ inline]
285
285
#[ must_use]
286
- pub fn intersection ( & self , b : Self ) -> Option < Self > {
286
+ pub fn intersection ( self , b : Self ) -> Option < Self > {
287
287
if !self . intersects ( b) {
288
288
return None ;
289
289
}
@@ -306,7 +306,7 @@ impl Aabb {
306
306
/// Returns a larger bounding box that contains both this `Aabb` and `b`.
307
307
#[ inline]
308
308
#[ must_use]
309
- pub fn merge ( & self , b : Self ) -> Self {
309
+ pub fn merge ( self , b : Self ) -> Self {
310
310
let position = Vector3 :: new (
311
311
self . position . x . min ( b. position . x ) ,
312
312
self . position . y . min ( b. position . y ) ,
0 commit comments