diff options
author | ccolin | 2021-01-02 02:04:57 +0100 |
---|---|---|
committer | ccolin | 2021-01-02 02:04:57 +0100 |
commit | 241f7ff0755933f47b1f97239ea3f0b48e8352e3 (patch) | |
tree | 41cec8e36b318049bde4df8c54dba3d5b95538ee | |
parent | a23067c1811576654bc8482748c8b1e3c6247dc2 (diff) |
fix collision detection
-rw-r--r-- | src/drone_controller.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/drone_controller.cc b/src/drone_controller.cc index 588ac23..f6edfb6 100644 --- a/src/drone_controller.cc +++ b/src/drone_controller.cc @@ -2,6 +2,7 @@ #include "opengl_widget.hh" #include <QJsonArray> +#include <QDebug> DroneController::DroneController(const QJsonObject &json) @@ -99,15 +100,18 @@ void DroneController::seek(int frame) { void DroneController::computeCollisions(double sphere_radius) { double sqDist = sphere_radius * sphere_radius * 2; for (int i = 0; i < duration; i++) { - for (const Drone &a : drones) { - for (const Drone &b : drones) { + for (Drone &a : drones) { + a.setTo(i); + for (Drone &b : drones) { + b.setTo(i); if (&a == &b) continue; if (collides(a, b, sqDist)) { - emit collision(a.getId(), b.getId(), frame); + emit collision(a.getId(), b.getId(), i); } } } } + seek(frame); } |