Évite les objets superposés dans l'éditeur
This commit is contained in:
parent
407bec5e7d
commit
ddde5ee5c1
|
@ -43,10 +43,23 @@ void Editor::frame() {
|
|||
|
||||
std::shared_ptr<Object> object = std::shared_ptr<Object>(new Block);
|
||||
object->setPosition(position);
|
||||
|
||||
// avant d'ajouter l'objet, on vérifie qu'il ne soit
|
||||
// pas superposé à un autre
|
||||
float overlaps = false;
|
||||
|
||||
for (unsigned int i = 0; i < objects.size(); i++) {
|
||||
if (objects[i]->getAABB()->intersects(*object->getAABB())) {
|
||||
overlaps = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!overlaps) {
|
||||
objects.push_back(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
draw();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue