TDME2  1.9.200
CollisionDetection.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 
5 #include <tdme/tdme.h>
9 #include <tdme/math/fwd-tdme.h>
10 #include <tdme/math/Vector3.h>
11 
13 
14 /**
15  * Collision detection
16  * @author Andreas Drewke
17  */
19 {
20 public:
21 
22  /**
23  * Returns if axis aligned bounding boxes do collide
24  * Will not provide hit points
25  * @param b1 axis aligned bounding box 1
26  * @param b2 axis aligned bounding box 2
27  * @return collision
28  */
29  inline static bool doCollideAABBvsAABBFast(BoundingBox* b1, BoundingBox* b2) {
30  // see
31  // http://www.gamedev.net/topic/567310-platform-game-collision-detection/
32  const auto& b1Min = b1->getMin();
33  const auto& b1Max = b1->getMax();
34  const auto& b2Min = b2->getMin();
35  const auto& b2Max = b2->getMax();
36 
37  // face distances
38  if (b2Max[0] - b1Min[0] < 0.0f) return false; // b2 collides into b1 on x
39  if (b2Max[1] - b1Min[1] < 0.0f) return false; // b2 collides into b1 on y
40  if (b2Max[2] - b1Min[2] < 0.0f) return false; // b2 collides into b1 on z
41  if (b1Max[0] - b2Min[0] < 0.0f) return false; // b1 collides into b2 on x
42  if (b1Max[1] - b2Min[1] < 0.0f) return false; // b1 collides into b2 on y
43  if (b1Max[2] - b2Min[2] < 0.0f) return false; // b1 collides into b2 on z
44 
45  // yarrr
46  return true;
47  }
48 
49 };
static bool doCollideAABBvsAABBFast(BoundingBox *b1, BoundingBox *b2)
Returns if axis aligned bounding boxes do collide Will not provide hit points.
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:26