1
0

Changed Tracer::m_NormalTable to static array

Was previously instantiated for every trace
This commit is contained in:
Woazboat 2015-04-29 00:14:42 +02:00
parent e240cab523
commit 0d003a2d2a
2 changed files with 23 additions and 8 deletions

View File

@ -13,16 +13,29 @@
const std::array<const Vector3f, 6>& cTracer::m_NormalTable(void)
{
static std::array<const Vector3f, 6>* table =
new std::array<const Vector3f, 6>
{
{
Vector3f(-1, 0, 0), // 1: -x
Vector3f( 0, 0, -1), // 2: -z
Vector3f( 1, 0, 0), // 3: +x
Vector3f( 0, 0, 1), // 4: +z
Vector3f( 0, 1, 0), // 5: +y
Vector3f( 0, -1, 0) // 6: -y
}
};
return *table;
};
cTracer::cTracer(cWorld * a_World):
m_World(a_World)
{
m_NormalTable[0].Set(-1, 0, 0);
m_NormalTable[1].Set( 0, 0, -1);
m_NormalTable[2].Set( 1, 0, 0);
m_NormalTable[3].Set( 0, 0, 1);
m_NormalTable[4].Set( 0, 1, 0);
m_NormalTable[5].Set( 0, -1, 0);
}
@ -241,7 +254,7 @@ bool cTracer::Trace(const Vector3f & a_Start, const Vector3f & a_Direction, int
int Normal = GetHitNormal(a_Start, End, pos);
if (Normal > 0)
{
HitNormal = m_NormalTable[Normal-1];
HitNormal = m_NormalTable()[Normal - 1];
}
return true;
}

View File

@ -3,6 +3,8 @@
#include "Vector3.h"
#include <array>
@ -64,7 +66,7 @@ private:
float SigNum( float a_Num);
cWorld* m_World;
Vector3f m_NormalTable[6];
static const std::array<const Vector3f, 6> & m_NormalTable(void);
Vector3f dir;
Vector3f tDelta;