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