raSystem  1.0 bata
raOctree.h
Go to the documentation of this file.
1 #pragma once
2 
3  class RAPI raOctree
4  {
5  public:
6  template<class VertexType, bool bIndexed, typename IndexType>
8 
9  raOctree(raVector3& bbMin, raVector3& bbMax, raOctree* pParent);
10  ~raOctree(void);
11 
12  virtual bool Intersects(const raVector3* pRayPos,
13  const raVector3* pRayDir,
14  float* pDist);
15 
16  private:
17  raVector3 m_bbMin;
18  raVector3 m_bbMax;
19 
20  raOctree** m_pChildren;
21  raArray<raVector3> m_Points;
22 
23  bool IsPointInOctant(raVector3 p);
24  void CreateChildNodes();
25  };
26  template<class VertexType, bool bIndexed, typename IndexType>
28  m_bbMin(pEntity->m_bbMin), m_bbMax(pEntity->m_bbMax)
29  {
30  for (UINT64 idx = 0; idx < pEntity->m_nIndices; idx += 3)
31  {
32  raVector3 p[3];
33  for(int i = 0; i < 3; i++)
34  {
35  p[i] = ((VertexType*)pEntity->m_pVertices +
36  pEntity->m_pIndices[idx + i])->position;
37  m_Points.Add(p[i]);
38  }
39  }
40  CreateChildNodes();
41  }
#define RAPI
Definition: raMain.h:11
IndexType * m_pIndices
Definition: raEntity.h:40
VertexType * m_pVertices
Definition: raEntity.h:39
raOctree(const raEntity< VertexType, bIndexed, IndexType > *pEntity)
Definition: raOctree.h:27
DWORD m_nIndices
Definition: raEntity.h:37
HRESULT Add(const TYPE &value)
Definition: raArray.h:119