Bubba-3D  0.9.0
Awesome game engine!
ExactOctreeCollider.cpp
1 /*
2  * This file is part of Bubba-3D.
3  *
4  * Bubba-3D is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Bubba-3D is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with Bubba-3D. If not, see http://www.gnu.org/licenses/.
16  */
17 #include <Collider.h>
18 #include "GameObject.h"
19 #include "ExactOctreeCollider.h"
20 
21 CollisionPairList ExactOctreeCollider::computeExactCollision(CollisionPairList possibleCollision) {
22  CollisionPairList exactCollisions;
23 
24  for(auto i = possibleCollision.begin(); i != possibleCollision.end(); i++ ) {
25  CollisionPair pair = *i;
26 
27  GameObject *object1 = pair.first;
28  GameObject *object2 = pair.second;
29 
30  chag::float4x4 object1ModelMatrix = object1->getModelMatrix();
31  chag::float4x4 object2ModelMatrix = object2->getModelMatrix();
32 
33  Octree* object1Oct = object1->getOctree();
34  Octree* object2Oct = object2->getOctree();
35 
36  if (octreeOctreeIntersection(object1Oct,&object1ModelMatrix,object2Oct, &object2ModelMatrix)) {
37  exactCollisions.push_back(CollisionPair(object1, object2));
38  }
39  }
40 
41  return exactCollisions;
42 }
43 
CollisionPairList computeExactCollision(CollisionPairList possibleCollision) override
Definition: Octree.h:32
Octree * getOctree()
Definition: GameObject.cpp:274
A class for containing all information about a object in the game world.
Definition: GameObject.h:67