Skip to content

Commit 292cada

Browse files
author
RealAstolfo
committed
Merge branch 'master' into astolfo-feature/builtin-vector
added the note for further investigation
2 parents 56e8cff + 188aa69 commit 292cada

File tree

3 files changed

+38
-42
lines changed

3 files changed

+38
-42
lines changed

godot-core/src/builtin/math.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ pub fn snapped(mut value: f32, step: f32) -> f32 {
4343

4444
pub fn sign(value: f32) -> f32 {
4545
if value == 0.0 {
46-
0.0
46+
0.0
47+
} else if value < 0.0 {
48+
-1.0
4749
} else {
48-
if value < 0.0 {
49-
-1.0
50-
} else {
51-
1.0
52-
}
50+
1.0
5351
}
5452
}
5553

godot-core/src/builtin/vector2.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,18 @@ impl Vector2 {
209209

210210
pub fn max_axis_index(self) -> Vector2Axis {
211211
if self.x < self.y {
212-
Vector2Axis::Y
213-
} else {
214-
Vector2Axis::X
215-
}
212+
Vector2Axis::Y
213+
} else {
214+
Vector2Axis::X
215+
}
216216
}
217217

218218
pub fn min_axis_index(self) -> Vector2Axis {
219219
if self.x < self.y {
220-
Vector2Axis::X
221-
} else {
222-
Vector2Axis::Y
223-
}
220+
Vector2Axis::X
221+
} else {
222+
Vector2Axis::Y
223+
}
224224
}
225225

226226
pub fn move_toward(self, to: Self, delta: f32) -> Self {
@@ -258,9 +258,11 @@ impl Vector2 {
258258
}
259259

260260
pub fn sign(self) -> Self {
261-
Self::new(sign(self.x),sign(self.y))
261+
Self::new(sign(self.x), sign(self.y))
262262
}
263263

264+
// TODO compare with gdnative implementation:
265+
// https://github.com/godot-rust/gdnative/blob/master/gdnative-core/src/core_types/vector3.rs#L335-L343
264266
pub fn slerp(self, to: Self, weight: f32) -> Self {
265267
let start_length_sq = self.length_squared();
266268
let end_length_sq = to.length_squared();

godot-core/src/builtin/vector3.rs

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -211,35 +211,31 @@ impl Vector3 {
211211
}
212212

213213
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+
}
227225
}
228226

229227
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+
}
243239
}
244240

245241
pub fn move_toward(self, to: Self, delta: f32) -> Self {
@@ -281,7 +277,7 @@ impl Vector3 {
281277
}
282278

283279
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))
285281
}
286282

287283
pub fn signed_angle_to(self, to: Self, axis: Self) -> f32 {

0 commit comments

Comments
 (0)