move: add velocity arg to move_towards; add move_from_towards

This commit is contained in:
Andrei Alexeyev 2023-02-15 23:01:08 +01:00
parent 8b3e6d5569
commit ac57f58de2
No known key found for this signature in database
GPG key ID: 72D26128040B9690

View file

@ -50,14 +50,31 @@ INLINE MoveParams move_asymptotic_simple(cmplx vel, double boost_factor) {
return move_asymptotic(vel * (1 + boost_factor), vel, retention);
}
INLINE MoveParams move_towards(cmplx target, cmplx attraction) {
INLINE MoveParams move_towards(cmplx vel, cmplx target, cmplx attraction) {
return (MoveParams) {
.velocity = vel,
.attraction = attraction,
.attraction_point = target,
.attraction_exponent = 1
};
}
#define _move_towards_nargs3 move_towards
attr_deprecated(
"Use move_towards(velocity, target, attraction) or "
"move_from_towards(origin, target, attraction) instead")
INLINE MoveParams _move_towards_nargs2(cmplx target, cmplx attraction) {
return move_towards(0, target, attraction);
}
#define move_towards(...) \
MACROHAX_OVERLOAD_NARGS(_move_towards_nargs, __VA_ARGS__)(__VA_ARGS__)
INLINE MoveParams move_from_towards(cmplx origin, cmplx target, cmplx attraction) {
return move_next(origin, move_towards(0, target, attraction));
}
INLINE MoveParams move_towards_power(cmplx target, cmplx attraction, real exponent) {
return (MoveParams) {
.attraction = attraction,