File tree 3 files changed +38
-42
lines changed
3 files changed +38
-42
lines changed Original file line number Diff line number Diff line change @@ -43,13 +43,11 @@ pub fn snapped(mut value: f32, step: f32) -> f32 {
43
43
44
44
pub fn sign ( value : f32 ) -> f32 {
45
45
if value == 0.0 {
46
- 0.0
46
+ 0.0
47
+ } else if value < 0.0 {
48
+ -1.0
47
49
} else {
48
- if value < 0.0 {
49
- -1.0
50
- } else {
51
- 1.0
52
- }
50
+ 1.0
53
51
}
54
52
}
55
53
Original file line number Diff line number Diff line change @@ -209,18 +209,18 @@ impl Vector2 {
209
209
210
210
pub fn max_axis_index ( self ) -> Vector2Axis {
211
211
if self . x < self . y {
212
- Vector2Axis :: Y
213
- } else {
214
- Vector2Axis :: X
215
- }
212
+ Vector2Axis :: Y
213
+ } else {
214
+ Vector2Axis :: X
215
+ }
216
216
}
217
217
218
218
pub fn min_axis_index ( self ) -> Vector2Axis {
219
219
if self . x < self . y {
220
- Vector2Axis :: X
221
- } else {
222
- Vector2Axis :: Y
223
- }
220
+ Vector2Axis :: X
221
+ } else {
222
+ Vector2Axis :: Y
223
+ }
224
224
}
225
225
226
226
pub fn move_toward ( self , to : Self , delta : f32 ) -> Self {
@@ -258,9 +258,11 @@ impl Vector2 {
258
258
}
259
259
260
260
pub fn sign ( self ) -> Self {
261
- Self :: new ( sign ( self . x ) , sign ( self . y ) )
261
+ Self :: new ( sign ( self . x ) , sign ( self . y ) )
262
262
}
263
263
264
+ // TODO compare with gdnative implementation:
265
+ // https://github.com/godot-rust/gdnative/blob/master/gdnative-core/src/core_types/vector3.rs#L335-L343
264
266
pub fn slerp ( self , to : Self , weight : f32 ) -> Self {
265
267
let start_length_sq = self . length_squared ( ) ;
266
268
let end_length_sq = to. length_squared ( ) ;
Original file line number Diff line number Diff line change @@ -211,35 +211,31 @@ impl Vector3 {
211
211
}
212
212
213
213
pub fn max_axis_index ( self ) -> Vector3Axis {
214
- if self . x < y {
215
- if self . y < self . z {
216
- Vector3Axis :: Z
217
- } else {
218
- Vector3Axis :: Y
219
- }
220
- } else {
221
- if self . x < self . z {
222
- Vector3Axis :: Z
223
- } else {
224
- Vector3Axis :: X
225
- }
226
- }
214
+ if self . x < self . y {
215
+ if self . y < self . z {
216
+ Vector3Axis :: Z
217
+ } else {
218
+ Vector3Axis :: Y
219
+ }
220
+ } else if self . x < self . z {
221
+ Vector3Axis :: Z
222
+ } else {
223
+ Vector3Axis :: X
224
+ }
227
225
}
228
226
229
227
pub fn min_axis_index ( self ) -> Vector3Axis {
230
- if self . x < self . y {
231
- if self . x < self . z {
232
- Vector3Axis :: X
233
- } else {
234
- Vector3Axis :: Z
235
- }
236
- } else {
237
- if self . y < self . z {
238
- Vector3Axis :: Y
239
- } else {
240
- Vector3Axis :: Z
241
- }
242
- }
228
+ if self . x < self . y {
229
+ if self . x < self . z {
230
+ Vector3Axis :: X
231
+ } else {
232
+ Vector3Axis :: Z
233
+ }
234
+ } else if self . y < self . z {
235
+ Vector3Axis :: Y
236
+ } else {
237
+ Vector3Axis :: Z
238
+ }
243
239
}
244
240
245
241
pub fn move_toward ( self , to : Self , delta : f32 ) -> Self {
@@ -281,7 +277,7 @@ impl Vector3 {
281
277
}
282
278
283
279
pub fn sign ( self ) -> Self {
284
- Self :: new ( sign ( self . x ) , sign ( self . y ) , sign ( self . z ) )
280
+ Self :: new ( sign ( self . x ) , sign ( self . y ) , sign ( self . z ) )
285
281
}
286
282
287
283
pub fn signed_angle_to ( self , to : Self , axis : Self ) -> f32 {
You can’t perform that action at this time.
0 commit comments