Skip to content

Commit 289944a

Browse files
committed
Fix CI and math ops
1 parent b3f3575 commit 289944a

File tree

15 files changed

+106
-132
lines changed

15 files changed

+106
-132
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
- uses: dtolnay/rust-toolchain@stable
6767
- uses: Swatinem/rust-cache@v2
6868
- name: Run cargo test
69-
run: cargo test --no-default-features --features enhanced-determinism,collider-from-mesh,serialize,debug-plugin,avian2d/2d,avian3d/3d,avian2d/f64,avian3d/f64,default-collider,parry-f64,bevy_scene,bevy_picking,diagnostic_ui
69+
run: cargo test --no-default-features --features std,enhanced-determinism,collider-from-mesh,serialize,debug-plugin,avian2d/2d,avian3d/3d,avian2d/f64,avian3d/f64,default-collider,parry-f64,bevy_scene,bevy_picking,diagnostic_ui
7070

7171
lints:
7272
name: Lints

clippy.toml

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,78 @@
11
disallowed-methods = [
22
# f32
3-
{ path = "f32::powi", reason = "use ops::FloatPow::squared, ops::FloatPow::cubed, or ops::powf instead for libm determinism" },
4-
{ path = "f32::log", reason = "use ops::ln, ops::log2, or ops::log10 instead for libm determinism" },
3+
{ path = "f32::powi", reason = "use math_ops::FloatPow::squared, math_ops::FloatPow::cubed, or math_ops::powf instead for libm determinism" },
4+
{ path = "f32::log", reason = "use math_ops::ln, math_ops::log2, or math_ops::log10 instead for libm determinism" },
55
{ path = "f32::abs_sub", reason = "deprecated and deeply confusing method" },
6-
{ path = "f32::powf", reason = "use ops::powf instead for libm determinism" },
7-
{ path = "f32::exp", reason = "use ops::exp instead for libm determinism" },
8-
{ path = "f32::exp2", reason = "use ops::exp2 instead for libm determinism" },
9-
{ path = "f32::ln", reason = "use ops::ln instead for libm determinism" },
10-
{ path = "f32::log2", reason = "use ops::log2 instead for libm determinism" },
11-
{ path = "f32::log10", reason = "use ops::log10 instead for libm determinism" },
12-
{ path = "f32::cbrt", reason = "use ops::cbrt instead for libm determinism" },
13-
{ path = "f32::hypot", reason = "use ops::hypot instead for libm determinism" },
14-
{ path = "f32::sin", reason = "use ops::sin instead for libm determinism" },
15-
{ path = "f32::cos", reason = "use ops::cos instead for libm determinism" },
16-
{ path = "f32::tan", reason = "use ops::tan instead for libm determinism" },
17-
{ path = "f32::asin", reason = "use ops::asin instead for libm determinism" },
18-
{ path = "f32::acos", reason = "use ops::acos instead for libm determinism" },
19-
{ path = "f32::atan", reason = "use ops::atan instead for libm determinism" },
20-
{ path = "f32::atan2", reason = "use ops::atan2 instead for libm determinism" },
21-
{ path = "f32::sin_cos", reason = "use ops::sin_cos instead for libm determinism" },
22-
{ path = "f32::exp_m1", reason = "use ops::exp_m1 instead for libm determinism" },
23-
{ path = "f32::ln_1p", reason = "use ops::ln_1p instead for libm determinism" },
24-
{ path = "f32::sinh", reason = "use ops::sinh instead for libm determinism" },
25-
{ path = "f32::cosh", reason = "use ops::cosh instead for libm determinism" },
26-
{ path = "f32::tanh", reason = "use ops::tanh instead for libm determinism" },
27-
{ path = "f32::asinh", reason = "use ops::asinh instead for libm determinism" },
28-
{ path = "f32::acosh", reason = "use ops::acosh instead for libm determinism" },
29-
{ path = "f32::atanh", reason = "use ops::atanh instead for libm determinism" },
6+
{ path = "f32::powf", reason = "use math_ops::powf instead for libm determinism" },
7+
{ path = "f32::exp", reason = "use math_ops::exp instead for libm determinism" },
8+
{ path = "f32::exp2", reason = "use math_ops::exp2 instead for libm determinism" },
9+
{ path = "f32::ln", reason = "use math_ops::ln instead for libm determinism" },
10+
{ path = "f32::log2", reason = "use math_ops::log2 instead for libm determinism" },
11+
{ path = "f32::log10", reason = "use math_ops::log10 instead for libm determinism" },
12+
{ path = "f32::cbrt", reason = "use math_ops::cbrt instead for libm determinism" },
13+
{ path = "f32::hypot", reason = "use math_ops::hypot instead for libm determinism" },
14+
{ path = "f32::sin", reason = "use math_ops::sin instead for libm determinism" },
15+
{ path = "f32::cos", reason = "use math_ops::cos instead for libm determinism" },
16+
{ path = "f32::tan", reason = "use math_ops::tan instead for libm determinism" },
17+
{ path = "f32::asin", reason = "use math_ops::asin instead for libm determinism" },
18+
{ path = "f32::acos", reason = "use math_ops::acos instead for libm determinism" },
19+
{ path = "f32::atan", reason = "use math_ops::atan instead for libm determinism" },
20+
{ path = "f32::atan2", reason = "use math_ops::atan2 instead for libm determinism" },
21+
{ path = "f32::sin_cos", reason = "use math_ops::sin_cos instead for libm determinism" },
22+
{ path = "f32::exp_m1", reason = "use math_ops::exp_m1 instead for libm determinism" },
23+
{ path = "f32::ln_1p", reason = "use math_ops::ln_1p instead for libm determinism" },
24+
{ path = "f32::sinh", reason = "use math_ops::sinh instead for libm determinism" },
25+
{ path = "f32::cosh", reason = "use math_ops::cosh instead for libm determinism" },
26+
{ path = "f32::tanh", reason = "use math_ops::tanh instead for libm determinism" },
27+
{ path = "f32::asinh", reason = "use math_ops::asinh instead for libm determinism" },
28+
{ path = "f32::acosh", reason = "use math_ops::acosh instead for libm determinism" },
29+
{ path = "f32::atanh", reason = "use math_ops::atanh instead for libm determinism" },
3030
# f64
31-
{ path = "f64::powi", reason = "use ops::FloatPow::squared, ops::FloatPow::cubed, or ops::powf instead for libm determinism" },
32-
{ path = "f64::log", reason = "use ops::ln, ops::log2, or ops::log10 instead for libm determinism" },
31+
{ path = "f64::powi", reason = "use math_ops::FloatPow::squared, math_ops::FloatPow::cubed, or math_ops::powf instead for libm determinism" },
32+
{ path = "f64::log", reason = "use math_ops::ln, math_ops::log2, or math_ops::log10 instead for libm determinism" },
3333
{ path = "f64::abs_sub", reason = "deprecated and deeply confusing method" },
34-
{ path = "f64::powf", reason = "use ops::powf instead for libm determinism" },
35-
{ path = "f64::exp", reason = "use ops::exp instead for libm determinism" },
36-
{ path = "f64::exp2", reason = "use ops::exp2 instead for libm determinism" },
37-
{ path = "f64::ln", reason = "use ops::ln instead for libm determinism" },
38-
{ path = "f64::log2", reason = "use ops::log2 instead for libm determinism" },
39-
{ path = "f64::log10", reason = "use ops::log10 instead for libm determinism" },
40-
{ path = "f64::cbrt", reason = "use ops::cbrt instead for libm determinism" },
41-
{ path = "f64::hypot", reason = "use ops::hypot instead for libm determinism" },
42-
{ path = "f64::sin", reason = "use ops::sin instead for libm determinism" },
43-
{ path = "f64::cos", reason = "use ops::cos instead for libm determinism" },
44-
{ path = "f64::tan", reason = "use ops::tan instead for libm determinism" },
45-
{ path = "f64::asin", reason = "use ops::asin instead for libm determinism" },
46-
{ path = "f64::acos", reason = "use ops::acos instead for libm determinism" },
47-
{ path = "f64::atan", reason = "use ops::atan instead for libm determinism" },
48-
{ path = "f64::atan2", reason = "use ops::atan2 instead for libm determinism" },
49-
{ path = "f64::sin_cos", reason = "use ops::sin_cos instead for libm determinism" },
50-
{ path = "f64::exp_m1", reason = "use ops::exp_m1 instead for libm determinism" },
51-
{ path = "f64::ln_1p", reason = "use ops::ln_1p instead for libm determinism" },
52-
{ path = "f64::sinh", reason = "use ops::sinh instead for libm determinism" },
53-
{ path = "f64::cosh", reason = "use ops::cosh instead for libm determinism" },
54-
{ path = "f64::tanh", reason = "use ops::tanh instead for libm determinism" },
55-
{ path = "f64::asinh", reason = "use ops::asinh instead for libm determinism" },
56-
{ path = "f64::acosh", reason = "use ops::acosh instead for libm determinism" },
57-
{ path = "f64::atanh", reason = "use ops::atanh instead for libm determinism" },
34+
{ path = "f64::powf", reason = "use math_ops::powf instead for libm determinism" },
35+
{ path = "f64::exp", reason = "use math_ops::exp instead for libm determinism" },
36+
{ path = "f64::exp2", reason = "use math_ops::exp2 instead for libm determinism" },
37+
{ path = "f64::ln", reason = "use math_ops::ln instead for libm determinism" },
38+
{ path = "f64::log2", reason = "use math_ops::log2 instead for libm determinism" },
39+
{ path = "f64::log10", reason = "use math_ops::log10 instead for libm determinism" },
40+
{ path = "f64::cbrt", reason = "use math_ops::cbrt instead for libm determinism" },
41+
{ path = "f64::hypot", reason = "use math_ops::hypot instead for libm determinism" },
42+
{ path = "f64::sin", reason = "use math_ops::sin instead for libm determinism" },
43+
{ path = "f64::cos", reason = "use math_ops::cos instead for libm determinism" },
44+
{ path = "f64::tan", reason = "use math_ops::tan instead for libm determinism" },
45+
{ path = "f64::asin", reason = "use math_ops::asin instead for libm determinism" },
46+
{ path = "f64::acos", reason = "use math_ops::acos instead for libm determinism" },
47+
{ path = "f64::atan", reason = "use math_ops::atan instead for libm determinism" },
48+
{ path = "f64::atan2", reason = "use math_ops::atan2 instead for libm determinism" },
49+
{ path = "f64::sin_cos", reason = "use math_ops::sin_cos instead for libm determinism" },
50+
{ path = "f64::exp_m1", reason = "use math_ops::exp_m1 instead for libm determinism" },
51+
{ path = "f64::ln_1p", reason = "use math_ops::ln_1p instead for libm determinism" },
52+
{ path = "f64::sinh", reason = "use math_ops::sinh instead for libm determinism" },
53+
{ path = "f64::cosh", reason = "use math_ops::cosh instead for libm determinism" },
54+
{ path = "f64::tanh", reason = "use math_ops::tanh instead for libm determinism" },
55+
{ path = "f64::asinh", reason = "use math_ops::asinh instead for libm determinism" },
56+
{ path = "f64::acosh", reason = "use math_ops::acosh instead for libm determinism" },
57+
{ path = "f64::atanh", reason = "use math_ops::atanh instead for libm determinism" },
5858
# These methods have defined precision, but are only available from the standard library,
5959
# not in core. Using these substitutes allows for no_std compatibility.
6060
# f32
61-
{ path = "f32::rem_euclid", reason = "use ops::rem_euclid instead for no_std compatibility" },
62-
{ path = "f32::abs", reason = "use ops::abs instead for no_std compatibility" },
63-
{ path = "f32::sqrt", reason = "use ops::sqrt instead for no_std compatibility" },
64-
{ path = "f32::copysign", reason = "use ops::copysign instead for no_std compatibility" },
65-
{ path = "f32::round", reason = "use ops::round instead for no_std compatibility" },
66-
{ path = "f32::floor", reason = "use ops::floor instead for no_std compatibility" },
67-
{ path = "f32::ceil", reason = "use ops::ceil instead for no_std compatibility" },
68-
{ path = "f32::fract", reason = "use ops::fract instead for no_std compatibility" },
61+
{ path = "f32::rem_euclid", reason = "use math_ops::rem_euclid instead for no_std compatibility" },
62+
{ path = "f32::abs", reason = "use math_ops::abs instead for no_std compatibility" },
63+
{ path = "f32::sqrt", reason = "use math_ops::sqrt instead for no_std compatibility" },
64+
{ path = "f32::copysign", reason = "use math_ops::copysign instead for no_std compatibility" },
65+
{ path = "f32::round", reason = "use math_ops::round instead for no_std compatibility" },
66+
{ path = "f32::floor", reason = "use math_ops::floor instead for no_std compatibility" },
67+
{ path = "f32::ceil", reason = "use math_ops::ceil instead for no_std compatibility" },
68+
{ path = "f32::fract", reason = "use math_ops::fract instead for no_std compatibility" },
6969
# f64
70-
{ path = "f64::rem_euclid", reason = "use ops::rem_euclid instead for no_std compatibility" },
71-
{ path = "f64::abs", reason = "use ops::abs instead for no_std compatibility" },
72-
{ path = "f64::sqrt", reason = "use ops::sqrt instead for no_std compatibility" },
73-
{ path = "f64::copysign", reason = "use ops::copysign instead for no_std compatibility" },
74-
{ path = "f64::round", reason = "use ops::round instead for no_std compatibility" },
75-
{ path = "f64::floor", reason = "use ops::floor instead for no_std compatibility" },
76-
{ path = "f64::ceil", reason = "use ops::ceil instead for no_std compatibility" },
77-
{ path = "f64::fract", reason = "use ops::fract instead for no_std compatibility" },
70+
{ path = "f64::rem_euclid", reason = "use math_ops::rem_euclid instead for no_std compatibility" },
71+
{ path = "f64::abs", reason = "use math_ops::abs instead for no_std compatibility" },
72+
{ path = "f64::sqrt", reason = "use math_ops::sqrt instead for no_std compatibility" },
73+
{ path = "f64::copysign", reason = "use math_ops::copysign instead for no_std compatibility" },
74+
{ path = "f64::round", reason = "use math_ops::round instead for no_std compatibility" },
75+
{ path = "f64::floor", reason = "use math_ops::floor instead for no_std compatibility" },
76+
{ path = "f64::ceil", reason = "use math_ops::ceil instead for no_std compatibility" },
77+
{ path = "f64::fract", reason = "use math_ops::fract instead for no_std compatibility" },
7878
]

src/collision/collider/parry/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ fn scale_shape(
13261326
#[cfg(feature = "2d")]
13271327
{
13281328
if scale.x == scale.y {
1329-
Ok(SharedShape::ball(b.radius * ops::abs(scale.x)))
1329+
Ok(SharedShape::ball(b.radius * math_ops::abs(scale.x)))
13301330
} else {
13311331
// A 2D circle becomes an ellipse when scaled non-uniformly.
13321332
Ok(SharedShape::new(EllipseColliderShape(Ellipse {
@@ -1488,7 +1488,7 @@ fn scale_shape(
14881488
if scale.x == scale.y {
14891489
return Ok(SharedShape::new(RegularPolygonColliderShape(
14901490
RegularPolygon::new(
1491-
polygon.circumradius() * ops::abs(scale.x) as f32,
1491+
polygon.circumradius() * math_ops::abs(scale.x) as f32,
14921492
polygon.sides,
14931493
),
14941494
)));

src/collision/collider/parry/primitives2d.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
math::{self, FloatPow},
2+
math::{self, math_ops, FloatPow},
33
AdjustPrecision, Scalar, Vector, FRAC_PI_2, PI, TAU,
44
};
55

@@ -44,7 +44,7 @@ impl SupportMap for EllipseColliderShape {
4444
#[inline]
4545
fn local_support_point(&self, direction: &Vector2<Scalar>) -> Point2<Scalar> {
4646
let [a, b] = self.half_size.adjust_precision().to_array();
47-
let denom = ops::sqrt(direction.x.squared() * a * a + direction.y.squared() * b * b);
47+
let denom = math_ops::sqrt(direction.x.squared() * a * a + direction.y.squared() * b * b);
4848
Point2::new(a * a * direction.x / denom, b * b * direction.y / denom)
4949
}
5050
}
@@ -276,7 +276,7 @@ impl SupportMap for RegularPolygonColliderShape {
276276
};
277277

278278
// How many rotations of `external_angle` correspond to the vertex closest to the support direction.
279-
let n = ops::round(angle_from_top / external_angle) % self.sides as Scalar;
279+
let n = math_ops::round(angle_from_top / external_angle) % self.sides as Scalar;
280280

281281
// Rotate by an additional 90 degrees so that the first vertex is always at the top.
282282
let target_angle = n * external_angle + FRAC_PI_2;
@@ -305,8 +305,8 @@ impl PolygonalFeatureMap for RegularPolygonColliderShape {
305305

306306
// How many rotations of `external_angle` correspond to the vertices.
307307
let n_unnormalized = angle_from_top / external_angle;
308-
let n1 = ops::floor(n_unnormalized) % self.sides as Scalar;
309-
let n2 = math::ceil(n_unnormalized) % self.sides as Scalar;
308+
let n1 = math_ops::floor(n_unnormalized) % self.sides as Scalar;
309+
let n2 = math_ops::ceil(n_unnormalized) % self.sides as Scalar;
310310

311311
// Rotate by an additional 90 degrees so that the first vertex is always at the top.
312312
let target_angle1 = n1 * external_angle + FRAC_PI_2;
@@ -393,7 +393,7 @@ impl Shape for RegularPolygonColliderShape {
393393

394394
let half_external_angle = PI / self.sides as Scalar;
395395
let angular_inertia = mass * self.circumradius().adjust_precision().squared() / 6.0
396-
* (1.0 + 2.0 * ops::cos(half_external_angle).squared());
396+
* (1.0 + 2.0 * math_ops::cos(half_external_angle).squared());
397397

398398
MassProperties::new(Point2::origin(), mass, angular_inertia)
399399
}

src/collision/contact_types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl ContactPair {
109109

110110
for manifold in &self.manifolds {
111111
let impulse = manifold.max_normal_impulse();
112-
if ops::abs(impulse) > ops::abs(magnitude) {
112+
if math_ops::abs(impulse) > math_ops::abs(magnitude) {
113113
magnitude = impulse;
114114
normal = manifold.normal;
115115
}

src/dynamics/ccd/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ fn solve_swept_ccd(
580580

581581
#[cfg(feature = "2d")]
582582
let ang_vel_below_threshold =
583-
ops::abs(ang_vel1.0 - ang_vel2) < ccd1.angular_threshold;
583+
math_ops::abs(ang_vel1.0 - ang_vel2) < ccd1.angular_threshold;
584584
#[cfg(feature = "3d")]
585585
let ang_vel_below_threshold =
586586
(ang_vel1.0 - ang_vel2).length_squared() < ccd1.angular_threshold.squared();

src/dynamics/integrator/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,19 @@ fn integrate_velocities(
234234
if let Some(max_linear_speed) = body.max_linear_speed {
235235
let linear_speed_squared = body.lin_vel.0.length_squared();
236236
if linear_speed_squared > max_linear_speed.0.squared() {
237-
body.lin_vel.0 *= max_linear_speed.0 / ops::sqrt(linear_speed_squared);
237+
body.lin_vel.0 *= max_linear_speed.0 / math_ops::sqrt(linear_speed_squared);
238238
}
239239
}
240240
if let Some(max_angular_speed) = body.max_angular_speed {
241241
#[cfg(feature = "2d")]
242-
if ops::abs(body.ang_vel.0) > max_angular_speed.0 {
243-
body.ang_vel.0 = ops::copysign(max_angular_speed.0, body.ang_vel.0);
242+
if math_ops::abs(body.ang_vel.0) > max_angular_speed.0 {
243+
body.ang_vel.0 = math_ops::copysign(max_angular_speed.0, body.ang_vel.0);
244244
}
245245
#[cfg(feature = "3d")]
246246
{
247247
let angular_speed_squared = body.ang_vel.0.length_squared();
248248
if angular_speed_squared > max_angular_speed.0.squared() {
249-
body.ang_vel.0 *= max_angular_speed.0 / ops::sqrt(angular_speed_squared);
249+
body.ang_vel.0 *= max_angular_speed.0 / math_ops::sqrt(angular_speed_squared);
250250
}
251251
}
252252
}

src/dynamics/rigid_body/physics_material.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl CoefficientCombine {
2828
pub fn mix(&self, a: Scalar, b: Scalar) -> Scalar {
2929
match self {
3030
CoefficientCombine::Average => (a + b) * 0.5,
31-
CoefficientCombine::GeometricMean => ops::sqrt(a * b),
31+
CoefficientCombine::GeometricMean => math_ops::sqrt(a * b),
3232
CoefficientCombine::Min => a.min(b),
3333
CoefficientCombine::Multiply => a * b,
3434
CoefficientCombine::Max => a.max(b),

src/dynamics/sleeping/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ pub fn mark_sleeping_bodies(
180180

181181
// Negative thresholds indicate that sleeping is disabled.
182182
let lin_sleeping_threshold_sq =
183-
length_unit_sq * sleep_threshold.linear * ops::abs(sleep_threshold.linear);
184-
let ang_sleeping_threshold_sq = sleep_threshold.angular * ops::abs(sleep_threshold.angular);
183+
length_unit_sq * sleep_threshold.linear * math_ops::abs(sleep_threshold.linear);
184+
let ang_sleeping_threshold_sq =
185+
sleep_threshold.angular * math_ops::abs(sleep_threshold.angular);
185186

186187
// If linear and angular velocity are below the sleeping threshold,
187188
// add delta time to the time sleeping, i.e. the time that the body has remained still.

src/dynamics/solver/joints/distance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl DistanceJoint {
144144
);
145145

146146
// Avoid division by zero and unnecessary computation
147-
if ops::abs(distance) < Scalar::EPSILON {
147+
if math_ops::abs(distance) < Scalar::EPSILON {
148148
return Vector::ZERO;
149149
}
150150

0 commit comments

Comments
 (0)