From 3d1bd544b08ab67a6d1e9c89fa66ad3c28426360 Mon Sep 17 00:00:00 2001 From: Woazboat Date: Wed, 29 Apr 2015 00:14:42 +0200 Subject: [PATCH] Changed Tracer::m_NormalTable to static array Was previously instantiated for every trace --- src/Tracer.cpp | 17 +++++++++++------ src/Tracer.h | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Tracer.cpp b/src/Tracer.cpp index aa8689814..ad662aca7 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -15,16 +15,21 @@ const float FLOAT_EPSILON = 0.0001f; //TODO: Stash this in some header where it can be reused +const std::array cTracer::m_NormalTable = +{ + 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 +}; + + 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); } diff --git a/src/Tracer.h b/src/Tracer.h index 821131539..ec23b340e 100644 --- a/src/Tracer.h +++ b/src/Tracer.h @@ -3,6 +3,8 @@ #include "Vector3.h" +#include + @@ -65,7 +67,7 @@ private: int SigNum( float a_Num); cWorld* m_World; - Vector3f m_NormalTable[6]; + static const std::array m_NormalTable; Vector3f dir; Vector3f tDelta;