move: fix attraction_exponent != 1 case

Was broken by 672ea996. The optimizations were indeed dubious after all.
This commit is contained in:
Andrei Alexeyev 2023-02-24 03:29:54 +01:00
parent 46ad7b183b
commit 14a370e940
No known key found for this signature in database
GPG key ID: 72D26128040B9690

View file

@ -23,8 +23,10 @@ cmplx move_update(cmplx *restrict pos, MoveParams *restrict p) {
if(LIKELY(o.attraction_exponent == 1)) {
o.velocity += o.attraction * av;
} else {
real m = sqrt(creal(av) * creal(av) + cimag(av) * cimag(av));
m = pow(m, o.attraction_exponent) / m;
real m = cabs2(av);
assume(m >= 0);
m = pow(m, o.attraction_exponent - 0.5);
assume(isfinite(m));
o.velocity += o.attraction * (av * m);
}
}