All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SplitPlanes.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Routes.h"
6 #include "MortonKey.h"
7 #include "DoublePlane.h"
8 #include "CubeMapCellHelpers.h"
9 
10 namespace Eegeo
11 {
12  namespace Routes
13  {
14  namespace Clipping
15  {
17  {
18  public:
19  SplitPlanes()
20  : m_currentKey(0)
21  , m_currentKeyValid(false)
22  , m_rightPositive(Geometry::DoublePlane::Zero())
23  , m_topPositive(Geometry::DoublePlane::Zero())
24  {
25  }
26 
27  inline void SetKey(const Streaming::MortonKey& key)
28  {
29  if (IsSameKey(key))
30  {
31  return;
32  }
33  m_currentKeyValid = true;
34  m_currentKey = key;
35  Space::CubeMapCellHelpers::CalculateCellSplitPlanes(m_currentKey, m_rightPositive, m_topPositive);
36  }
37 
38  inline const Geometry::DoublePlane& RightPositive() const
39  {
40  Eegeo_ASSERT(m_currentKeyValid);
41  return m_rightPositive;
42  }
43 
44  inline const Geometry::DoublePlane& TopPositive() const
45  {
46  Eegeo_ASSERT(m_currentKeyValid);
47  return m_topPositive;
48  }
49 
50  inline bool IsSameKey(const Streaming::MortonKey& key) const
51  {
52  return m_currentKeyValid && m_currentKey == key;
53  }
54 
55  private:
56  Streaming::MortonKey m_currentKey;
57  bool m_currentKeyValid;
58  Geometry::DoublePlane m_rightPositive;
59  Geometry::DoublePlane m_topPositive;
60  };
61  }
62  }
63 }