21 #include <GameObject.h> 26 #include <SFML/System/Clock.hpp> 27 #include "BFBroadPhase.h" 29 BFBroadPhase::BFBroadPhase() {
34 std::vector<GameObject*> sceneObjects = scene->getGameObjects();
35 CollisionPairList collisionPairs;
37 for (
auto i = sceneObjects.begin(); i != sceneObjects.end(); i++) {
38 for (
auto j = i + 1; j != sceneObjects.end(); j++) {
42 if(isPossiblyColliding(gameObject1,gameObject2)) {
43 collisionPairs.push_back(std::pair<GameObject *, GameObject *>(gameObject1, gameObject2));
48 return collisionPairs;
53 bool noDynamic = !gameObject1->isDynamicObject() && !gameObject2->isDynamicObject();
54 bool neverCollides = !gameObject1->collidesWith(gameObject2->getIdentifier())
55 && !gameObject2->collidesWith(gameObject1->getIdentifier());
56 if(noDynamic || neverCollides || gameObject1->isDirty() || gameObject2->isDirty() || gameObject1 == gameObject2) {
59 bool sphereInt = sphereIntersection(gameObject1->getTransformedSphere(),gameObject2->getTransformedSphere());
62 AABB aabb1 = gameObject1->getTransformedAABB();
63 AABB aabb2 = gameObject2->getTransformedAABB();
65 bool aabb = AabbAabbintersection(&aabb1, &aabb2);
virtual CollisionPairList computeCollisionPairs(Scene *scene) override
A class for containing all information about a object in the game world.