taisei/src/move.c

28 lines
673 B
C
Raw Normal View History

/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
*/
#include "taisei.h"
#include "move.h"
2019-07-25 02:31:02 +02:00
#include "util/miscmath.h"
2019-07-25 02:31:02 +02:00
complex move_update(complex *restrict pos, MoveParams *restrict p) {
complex v = p->velocity;
2019-07-25 02:31:02 +02:00
*pos += v;
p->velocity = p->acceleration + p->retention * v;
2019-07-25 02:31:02 +02:00
if(p->attraction_norm || p->attraction) {
complex av = p->attraction_point - *pos;
p->velocity += p->attraction * av;
p->velocity += p->attraction_norm * cnormalize(av);
}
return v;
}