Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AABB.c
Go to the documentation of this file.
1 class SCR_AABB : Managed
4 {
5  vector m_vMin;
6  vector m_vMax;
7  vector m_vDimensions; // width, height, depth
8 
9  //------------------------------------------------------------------------------------------------
10  bool DetectCollision2D(SCR_AABB other)
11  {
12  return
13  m_vMin[0] < other.m_vMin[0] + other.m_vDimensions[0] &&
14  m_vMin[0] + m_vDimensions[0] > other.m_vMin[0] &&
15  m_vMin[2] < other.m_vMin[2] + other.m_vDimensions[2] &&
16  m_vMin[2] + m_vDimensions[2] > other.m_vMin[2];
17  }
18 
19  //------------------------------------------------------------------------------------------------
20  void SCR_AABB(notnull array<vector> points)
21  {
22  if (points.IsEmpty())
23  return;
24 
25  m_vMin = { float.MAX, float.MAX, float.MAX };
26  m_vMax = { -float.MAX, -float.MAX, -float.MAX };
27 
28  foreach (vector point : points)
29  {
30  for (int i = 0; i < 3; i++)
31  {
32  if (point[i] < m_vMin[i])
33  m_vMin[i] = point[i];
34 
35  if (point[i] > m_vMax[i])
36  m_vMax[i] = point[i];
37  }
38  }
39 
40  m_vDimensions = m_vMax - m_vMin;
41  }
42 }
SCR_AABB
Definition: SCR_AABB.c:3