fix collision detection
This commit is contained in:
parent
a23067c181
commit
241f7ff075
@ -2,6 +2,7 @@
|
|||||||
#include "opengl_widget.hh"
|
#include "opengl_widget.hh"
|
||||||
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
DroneController::DroneController(const QJsonObject &json)
|
DroneController::DroneController(const QJsonObject &json)
|
||||||
@ -99,15 +100,18 @@ void DroneController::seek(int frame) {
|
|||||||
void DroneController::computeCollisions(double sphere_radius) {
|
void DroneController::computeCollisions(double sphere_radius) {
|
||||||
double sqDist = sphere_radius * sphere_radius * 2;
|
double sqDist = sphere_radius * sphere_radius * 2;
|
||||||
for (int i = 0; i < duration; i++) {
|
for (int i = 0; i < duration; i++) {
|
||||||
for (const Drone &a : drones) {
|
for (Drone &a : drones) {
|
||||||
for (const Drone &b : drones) {
|
a.setTo(i);
|
||||||
|
for (Drone &b : drones) {
|
||||||
|
b.setTo(i);
|
||||||
if (&a == &b) continue;
|
if (&a == &b) continue;
|
||||||
if (collides(a, b, sqDist)) {
|
if (collides(a, b, sqDist)) {
|
||||||
emit collision(a.getId(), b.getId(), frame);
|
emit collision(a.getId(), b.getId(), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
seek(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user