@@ -45,7 +45,7 @@ impl Aabb {
45
45
46
46
/// Returns an AABB with the same geometry, with most-negative corner as `position` and non-negative `size`.
47
47
#[ inline]
48
- pub fn abs ( & self ) -> Self {
48
+ pub fn abs ( self ) -> Self {
49
49
Aabb {
50
50
position : self . position + self . size . coord_min ( Vector3 :: ZERO ) ,
51
51
size : self . size . abs ( ) ,
@@ -54,7 +54,7 @@ impl Aabb {
54
54
55
55
/// Whether `self` covers at least the entire area of `b` (and possibly more).
56
56
#[ inline]
57
- pub fn encloses ( & self , b : Aabb ) -> bool {
57
+ pub fn encloses ( self , b : Aabb ) -> bool {
58
58
let end = self . end ( ) ;
59
59
let b_end = b. end ( ) ;
60
60
@@ -71,16 +71,16 @@ impl Aabb {
71
71
/// # Panics
72
72
/// If `self.size` is negative.
73
73
#[ inline]
74
- pub fn expand ( & self , to : Vector3 ) -> Self {
75
- self . merge ( & Aabb :: new ( to, Vector3 :: ZERO ) )
74
+ pub fn expand ( self , to : Vector3 ) -> Self {
75
+ self . merge ( Aabb :: new ( to, Vector3 :: ZERO ) )
76
76
}
77
77
78
78
/// Returns a larger AABB that contains this AABB and `b`.
79
79
///
80
80
/// # Panics
81
81
/// If either `self.size` or `b.size` is negative.
82
82
#[ inline]
83
- pub fn merge ( & self , b : & Aabb ) -> Self {
83
+ pub fn merge ( self , b : Aabb ) -> Self {
84
84
self . assert_nonnegative ( ) ;
85
85
b. assert_nonnegative ( ) ;
86
86
@@ -95,21 +95,21 @@ impl Aabb {
95
95
/// # Panics
96
96
/// If `self.size` is negative.
97
97
#[ inline]
98
- pub fn volume ( & self ) -> real {
98
+ pub fn volume ( self ) -> real {
99
99
self . assert_nonnegative ( ) ;
100
100
self . size . x * self . size . y * self . size . z
101
101
}
102
102
103
103
/// Returns the center of the AABB, which is equal to `position + (size / 2)`.
104
104
#[ inline]
105
- pub fn center ( & self ) -> Vector3 {
105
+ pub fn center ( self ) -> Vector3 {
106
106
self . position + ( self . size / 2.0 )
107
107
}
108
108
109
109
/// Returns a copy of the AABB grown by the specified `amount` on all sides.
110
110
#[ inline]
111
111
#[ must_use]
112
- pub fn grow ( & self , amount : real ) -> Self {
112
+ pub fn grow ( self , amount : real ) -> Self {
113
113
let position = self . position - Vector3 :: new ( amount, amount, amount) ;
114
114
let size = self . size + Vector3 :: new ( amount, amount, amount) * 2.0 ;
115
115
@@ -122,7 +122,7 @@ impl Aabb {
122
122
/// # Panics
123
123
/// If `self.size` is negative.
124
124
#[ inline]
125
- pub fn has_point ( & self , point : Vector3 ) -> bool {
125
+ pub fn has_point ( self , point : Vector3 ) -> bool {
126
126
self . assert_nonnegative ( ) ;
127
127
128
128
let point = point - self . position ;
@@ -135,13 +135,13 @@ impl Aabb {
135
135
136
136
/// Returns `true` if the AABB has area, and `false` if the AABB is linear, empty, or has a negative size. See also `Aabb.area()`.
137
137
#[ inline]
138
- pub fn has_area ( & self ) -> bool {
138
+ pub fn has_area ( self ) -> bool {
139
139
( ( self . size . x > 0.0 ) as u8 + ( self . size . y > 0.0 ) as u8 + ( self . size . z > 0.0 ) as u8 ) >= 2
140
140
}
141
141
142
142
/// Returns true if the AABB has a volume, and false if the AABB is flat, linear, empty, or has a negative size.
143
143
#[ inline]
144
- pub fn has_volume ( & self ) -> bool {
144
+ pub fn has_volume ( self ) -> bool {
145
145
self . size . x > 0.0 && self . size . y > 0.0 && self . size . z > 0.0
146
146
}
147
147
@@ -150,14 +150,14 @@ impl Aabb {
150
150
/// # Panics
151
151
/// If `self.size` is negative.
152
152
#[ inline]
153
- pub fn intersection ( & self , b : & Aabb ) -> Option < Self > {
153
+ pub fn intersection ( self , b : Aabb ) -> Option < Self > {
154
154
self . assert_nonnegative ( ) ;
155
155
156
156
if !self . intersects ( b) {
157
157
return None ;
158
158
}
159
159
160
- let mut rect = * b;
160
+ let mut rect = b;
161
161
rect. position = rect. position . coord_max ( self . position ) ;
162
162
163
163
let end = self . end ( ) ;
@@ -169,13 +169,13 @@ impl Aabb {
169
169
170
170
/// Returns `true` if this AABB is finite, by calling `@GlobalScope.is_finite` on each component.
171
171
#[ inline]
172
- pub fn is_finite ( & self ) -> bool {
172
+ pub fn is_finite ( self ) -> bool {
173
173
self . position . is_finite ( ) && self . size . is_finite ( )
174
174
}
175
175
176
176
/// The end of the `Aabb` calculated as `position + size`.
177
177
#[ inline]
178
- pub fn end ( & self ) -> Vector3 {
178
+ pub fn end ( self ) -> Vector3 {
179
179
self . position + self . size
180
180
}
181
181
@@ -189,7 +189,7 @@ impl Aabb {
189
189
190
190
/// Returns the normalized longest axis of the AABB.
191
191
#[ inline]
192
- pub fn longest_axis ( & self ) -> Option < Vector3 > {
192
+ pub fn longest_axis ( self ) -> Option < Vector3 > {
193
193
self . longest_axis_index ( ) . map ( |axis| match axis {
194
194
Vector3Axis :: X => Vector3 :: RIGHT ,
195
195
Vector3Axis :: Y => Vector3 :: UP ,
@@ -199,19 +199,19 @@ impl Aabb {
199
199
200
200
/// Returns the index of the longest axis of the AABB (according to Vector3's AXIS_* constants).
201
201
#[ inline]
202
- pub fn longest_axis_index ( & self ) -> Option < Vector3Axis > {
202
+ pub fn longest_axis_index ( self ) -> Option < Vector3Axis > {
203
203
self . size . max_axis ( )
204
204
}
205
205
206
206
/// Returns the scalar length of the longest axis of the AABB.
207
207
#[ inline]
208
- pub fn longest_axis_size ( & self ) -> real {
208
+ pub fn longest_axis_size ( self ) -> real {
209
209
self . size . x . max ( self . size . y . max ( self . size . z ) )
210
210
}
211
211
212
212
/// Returns the normalized shortest axis of the AABB.
213
213
#[ inline]
214
- pub fn shortest_axis ( & self ) -> Option < Vector3 > {
214
+ pub fn shortest_axis ( self ) -> Option < Vector3 > {
215
215
self . shortest_axis_index ( ) . map ( |axis| match axis {
216
216
Vector3Axis :: X => Vector3 :: RIGHT ,
217
217
Vector3Axis :: Y => Vector3 :: UP ,
@@ -221,19 +221,19 @@ impl Aabb {
221
221
222
222
/// Returns the index of the shortest axis of the AABB (according to Vector3::AXIS* enum).
223
223
#[ inline]
224
- pub fn shortest_axis_index ( & self ) -> Option < Vector3Axis > {
224
+ pub fn shortest_axis_index ( self ) -> Option < Vector3Axis > {
225
225
self . size . min_axis ( )
226
226
}
227
227
228
228
/// Returns the scalar length of the shortest axis of the AABB.
229
229
#[ inline]
230
- pub fn shortest_axis_size ( & self ) -> real {
230
+ pub fn shortest_axis_size ( self ) -> real {
231
231
self . size . x . min ( self . size . y . min ( self . size . z ) )
232
232
}
233
233
234
234
/// Returns the support point in a given direction. This is useful for collision detection algorithms.
235
235
#[ inline]
236
- pub fn support ( & self , dir : Vector3 ) -> Vector3 {
236
+ pub fn support ( self , dir : Vector3 ) -> Vector3 {
237
237
let half_extents = self . size * 0.5 ;
238
238
let relative_center_point = self . position + half_extents;
239
239
@@ -253,7 +253,7 @@ impl Aabb {
253
253
///
254
254
/// _Godot equivalent: `AABB.intersects(AABB b, bool include_borders = true)`_
255
255
#[ inline]
256
- pub fn intersects ( & self , b : & Aabb ) -> bool {
256
+ pub fn intersects ( self , b : Aabb ) -> bool {
257
257
let end = self . end ( ) ;
258
258
let end_b = b. end ( ) ;
259
259
@@ -271,7 +271,7 @@ impl Aabb {
271
271
///
272
272
/// _Godot equivalent: `AABB.intersects(AABB b, bool include_borders = false)`_
273
273
#[ inline]
274
- pub fn intersects_exclude_borders ( & self , & b: & Aabb ) -> bool {
274
+ pub fn intersects_exclude_borders ( self , b : Aabb ) -> bool {
275
275
let end = self . end ( ) ;
276
276
let end_b = b. end ( ) ;
277
277
@@ -285,7 +285,7 @@ impl Aabb {
285
285
286
286
/// Returns `true` if the AABB is on both sides of a plane.
287
287
#[ inline]
288
- pub fn intersects_plane ( & self , plane : & Plane ) -> bool {
288
+ pub fn intersects_plane ( self , plane : Plane ) -> bool {
289
289
// The set of the edges of the AABB.
290
290
let points = [
291
291
self . position ,
@@ -318,7 +318,7 @@ impl Aabb {
318
318
/// # Panics
319
319
/// If `self.size` is negative.
320
320
#[ inline]
321
- pub fn intersects_ray ( & self , from : Vector3 , dir : Vector3 ) -> bool {
321
+ pub fn intersects_ray ( self , from : Vector3 , dir : Vector3 ) -> bool {
322
322
self . assert_nonnegative ( ) ;
323
323
324
324
let tmin = ( self . position - from) / dir;
@@ -338,7 +338,7 @@ impl Aabb {
338
338
/// # Panics
339
339
/// If `self.size` is negative.
340
340
#[ inline]
341
- pub fn intersects_segment ( & self , from : Vector3 , to : Vector3 ) -> bool {
341
+ pub fn intersects_segment ( self , from : Vector3 , to : Vector3 ) -> bool {
342
342
self . assert_nonnegative ( ) ;
343
343
344
344
let segment_dir = to - from;
@@ -371,7 +371,7 @@ impl Aabb {
371
371
///
372
372
/// Most functions will fail to give a correct result if the size is negative.
373
373
#[ inline]
374
- pub fn assert_nonnegative ( & self ) {
374
+ pub fn assert_nonnegative ( self ) {
375
375
assert ! (
376
376
self . size. x >= 0.0 && self . size. y >= 0.0 && self . size. z >= 0.0 ,
377
377
"size {:?} is negative" ,
@@ -467,27 +467,27 @@ mod test {
467
467
} ;
468
468
469
469
// Check for intersection including border
470
- assert ! ( aabb1. intersects( & aabb2) ) ;
471
- assert ! ( aabb2. intersects( & aabb1) ) ;
470
+ assert ! ( aabb1. intersects( aabb2) ) ;
471
+ assert ! ( aabb2. intersects( aabb1) ) ;
472
472
473
473
// Check for non-intersection including border
474
- assert ! ( !aabb1. intersects( & aabb3) ) ;
475
- assert ! ( !aabb3. intersects( & aabb1) ) ;
474
+ assert ! ( !aabb1. intersects( aabb3) ) ;
475
+ assert ! ( !aabb3. intersects( aabb1) ) ;
476
476
477
477
// Check for intersection excluding border
478
- assert ! ( aabb1. intersects_exclude_borders( & aabb2) ) ;
479
- assert ! ( aabb2. intersects_exclude_borders( & aabb1) ) ;
478
+ assert ! ( aabb1. intersects_exclude_borders( aabb2) ) ;
479
+ assert ! ( aabb2. intersects_exclude_borders( aabb1) ) ;
480
480
481
481
// Check for non-intersection excluding border
482
- assert ! ( !aabb1. intersects_exclude_borders( & aabb3) ) ;
483
- assert ! ( !aabb3. intersects_exclude_borders( & aabb1) ) ;
482
+ assert ! ( !aabb1. intersects_exclude_borders( aabb3) ) ;
483
+ assert ! ( !aabb3. intersects_exclude_borders( aabb1) ) ;
484
484
485
485
// Check for non-intersection excluding border
486
- assert ! ( !aabb1. intersects_exclude_borders( & aabb4) ) ;
487
- assert ! ( !aabb4. intersects_exclude_borders( & aabb1) ) ;
486
+ assert ! ( !aabb1. intersects_exclude_borders( aabb4) ) ;
487
+ assert ! ( !aabb4. intersects_exclude_borders( aabb1) ) ;
488
488
489
489
// Check for intersection with same AABB including border
490
- assert ! ( aabb1. intersects( & aabb1) ) ;
490
+ assert ! ( aabb1. intersects( aabb1) ) ;
491
491
}
492
492
493
493
#[ test]
@@ -515,17 +515,17 @@ mod test {
515
515
516
516
// Test cases
517
517
assert_eq ! (
518
- aabb1. intersection( & aabb2) ,
518
+ aabb1. intersection( aabb2) ,
519
519
Some ( Aabb {
520
520
position: Vector3 :: new( 1.0 , 1.0 , 1.0 ) ,
521
521
size: Vector3 :: new( 1.0 , 1.0 , 1.0 ) ,
522
522
} )
523
523
) ;
524
524
525
- assert_eq ! ( aabb1. intersection( & aabb3) , None ) ;
525
+ assert_eq ! ( aabb1. intersection( aabb3) , None ) ;
526
526
527
527
assert_eq ! (
528
- aabb1. intersection( & aabb4) ,
528
+ aabb1. intersection( aabb4) ,
529
529
Some ( Aabb {
530
530
position: Vector3 :: new( 0.0 , 0.0 , 0.0 ) ,
531
531
size: Vector3 :: new( 0.0 , 0.0 , 0.0 ) ,
@@ -620,10 +620,10 @@ mod test {
620
620
} ;
621
621
622
622
// Test cases
623
- assert ! ( aabb. intersects_plane( & plane_inside) ) ;
624
- assert ! ( !aabb. intersects_plane( & plane_outside) ) ;
625
- assert ! ( aabb. intersects_plane( & plane_intersect) ) ;
626
- assert ! ( !aabb. intersects_plane( & plane_parallel) ) ;
623
+ assert ! ( aabb. intersects_plane( plane_inside) ) ;
624
+ assert ! ( !aabb. intersects_plane( plane_outside) ) ;
625
+ assert ! ( aabb. intersects_plane( plane_intersect) ) ;
626
+ assert ! ( !aabb. intersects_plane( plane_parallel) ) ;
627
627
}
628
628
629
629
#[ test]
0 commit comments