fmt: just fmt (rust only)
Build TDK Pinball / build (macos-latest) (push) Canceled after 0s
Build TDK Pinball / build (ubuntu-latest) (push) Canceled after 0s
Build TDK Pinball / build (windows-latest) (push) Canceled after 0s
Build TDK Pinball / build (macos-latest) (push) Canceled after 0s
Build TDK Pinball / build (ubuntu-latest) (push) Canceled after 0s
Build TDK Pinball / build (windows-latest) (push) Canceled after 0s
This commit is contained in:
@@ -73,11 +73,7 @@ impl CollisionMaterial {
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn circle(
|
||||
normal_rebound: f64,
|
||||
tangent_coupling: f64,
|
||||
normal_kick: f64,
|
||||
) -> Self {
|
||||
pub const fn circle(normal_rebound: f64, tangent_coupling: f64, normal_kick: f64) -> Self {
|
||||
Self {
|
||||
normal_rebound,
|
||||
tangent_coupling,
|
||||
@@ -173,8 +169,7 @@ impl MilliVec {
|
||||
// `maximum / speed` is mathematically equivalent, but can differ by
|
||||
// one millipixel because each Real48 operation is rounded
|
||||
// independently.
|
||||
let excess = Real48::from_i32(speed.wrapping_sub(maximum))
|
||||
.divide(Real48::from_i32(speed));
|
||||
let excess = Real48::from_i32(speed.wrapping_sub(maximum)).divide(Real48::from_i32(speed));
|
||||
self.x = self
|
||||
.x
|
||||
.wrapping_sub(Real48::from_i32(self.x).multiply(excess).round_i32());
|
||||
@@ -262,11 +257,7 @@ fn tangent_velocity(velocity: MilliVec, normal_x: Real48, normal_y: Real48, leng
|
||||
.round_i32()
|
||||
}
|
||||
|
||||
fn cross_at_endpoint(
|
||||
point: MilliVec,
|
||||
current: MilliVec,
|
||||
predicted: MilliVec,
|
||||
) -> i32 {
|
||||
fn cross_at_endpoint(point: MilliVec, current: MilliVec, predicted: MilliVec) -> i32 {
|
||||
predicted
|
||||
.x
|
||||
.wrapping_sub(point.x)
|
||||
@@ -383,9 +374,7 @@ pub fn line_collision_candidate_at(
|
||||
let vertical_units = normal_y.divide(THOUSAND);
|
||||
let distance = Real48::from_i32(old_position.x.wrapping_sub(start.x))
|
||||
.multiply(vertical_units)
|
||||
.subtract(
|
||||
Real48::from_i32(old_position.y.wrapping_sub(start.y)).multiply(horizontal_units),
|
||||
)
|
||||
.subtract(Real48::from_i32(old_position.y.wrapping_sub(start.y)).multiply(horizontal_units))
|
||||
.divide(length_units);
|
||||
let distance = if distance.compare(ZERO).is_lt() {
|
||||
ZERO.subtract(distance)
|
||||
@@ -525,10 +514,7 @@ pub fn capture_collision_candidate(
|
||||
let radius_milli = (radius * 1_000.0).round() as i32;
|
||||
let delta = MilliVec {
|
||||
x: center.x.wrapping_sub(old_position.x),
|
||||
y: center
|
||||
.y
|
||||
.wrapping_sub(old_position.y)
|
||||
.wrapping_sub(2_000),
|
||||
y: center.y.wrapping_sub(old_position.y).wrapping_sub(2_000),
|
||||
};
|
||||
let surface_distance = milli_distance(delta).wrapping_sub(radius_milli);
|
||||
let normal_x = Real48::from_i32(center.y.wrapping_sub(old_position.y));
|
||||
@@ -541,9 +527,7 @@ pub fn capture_collision_candidate(
|
||||
return None;
|
||||
}
|
||||
let normal_velocity = normal_velocity(velocity, normal_x, normal_y, length);
|
||||
if normal_velocity >= 0
|
||||
|| normal_velocity.wrapping_abs() < surface_distance.wrapping_abs()
|
||||
{
|
||||
if normal_velocity >= 0 || normal_velocity.wrapping_abs() < surface_distance.wrapping_abs() {
|
||||
return None;
|
||||
}
|
||||
Some(StaticCollisionCandidate {
|
||||
@@ -681,8 +665,14 @@ mod tests {
|
||||
#[test]
|
||||
fn float_views_roundtrip_every_gameplay_velocity_millipixel() {
|
||||
for value in -10_000..=10_000 {
|
||||
let milli = MilliVec { x: value, y: -value };
|
||||
assert_eq!(MilliVec::from_velocity_per_second(milli.to_velocity_per_second()), milli);
|
||||
let milli = MilliVec {
|
||||
x: value,
|
||||
y: -value,
|
||||
};
|
||||
assert_eq!(
|
||||
MilliVec::from_velocity_per_second(milli.to_velocity_per_second()),
|
||||
milli
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -697,8 +687,7 @@ mod tests {
|
||||
if speed <= maximum {
|
||||
continue;
|
||||
}
|
||||
let excess = Real48::from_i32(speed - maximum)
|
||||
.divide(Real48::from_i32(speed));
|
||||
let excess = Real48::from_i32(speed - maximum).divide(Real48::from_i32(speed));
|
||||
let expected = MilliVec {
|
||||
x: x.wrapping_sub(Real48::from_i32(x).multiply(excess).round_i32()),
|
||||
y: y.wrapping_sub(Real48::from_i32(y).multiply(excess).round_i32()),
|
||||
@@ -716,7 +705,10 @@ mod tests {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert!(mismatches.is_empty(), "speed-clamp mismatches: {mismatches:?}");
|
||||
assert!(
|
||||
mismatches.is_empty(),
|
||||
"speed-clamp mismatches: {mismatches:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -783,7 +775,9 @@ mod tests {
|
||||
|
||||
assert_eq!(candidate.surface_distance, -800);
|
||||
assert_ne!(
|
||||
candidate.resolve(MilliVec { x: 1_000, y: 0 }, Real48::ZERO).velocity,
|
||||
candidate
|
||||
.resolve(MilliVec { x: 1_000, y: 0 }, Real48::ZERO)
|
||||
.velocity,
|
||||
MilliVec { x: 1_000, y: 0 }
|
||||
);
|
||||
}
|
||||
@@ -887,16 +881,15 @@ mod tests {
|
||||
fn surface_distance_orders_candidate_contacts() {
|
||||
let old = MilliVec::default();
|
||||
let velocity = MilliVec { x: 10_000, y: 0 };
|
||||
let near =
|
||||
line_collision_response(
|
||||
old,
|
||||
velocity,
|
||||
vec2(2.0, 1.0),
|
||||
vec2(2.0, -1.0),
|
||||
CollisionMaterial::line(0.6, 0.1),
|
||||
Real48::ZERO,
|
||||
)
|
||||
.expect("near rail should be crossed");
|
||||
let near = line_collision_response(
|
||||
old,
|
||||
velocity,
|
||||
vec2(2.0, 1.0),
|
||||
vec2(2.0, -1.0),
|
||||
CollisionMaterial::line(0.6, 0.1),
|
||||
Real48::ZERO,
|
||||
)
|
||||
.expect("near rail should be crossed");
|
||||
let far = line_collision_response(
|
||||
old,
|
||||
velocity,
|
||||
|
||||
Reference in New Issue
Block a user