summaryrefslogtreecommitdiffstats
path: root/src/Tracer.cpp
diff options
context:
space:
mode:
authorWoazboat <f.kargl@posteo.de>2015-04-29 00:14:42 +0200
committerWoazboat <f.kargl@posteo.de>2015-05-08 15:12:32 +0200
commit0d003a2d2a8807983f23372dd15eabd403cd4b1c (patch)
treec45796e694f00eb7c772e11d2881ff77d27fc78a /src/Tracer.cpp
parentRemoved redundant temp iterator. std::list.erase already returns (diff)
downloadcuberite-0d003a2d2a8807983f23372dd15eabd403cd4b1c.tar
cuberite-0d003a2d2a8807983f23372dd15eabd403cd4b1c.tar.gz
cuberite-0d003a2d2a8807983f23372dd15eabd403cd4b1c.tar.bz2
cuberite-0d003a2d2a8807983f23372dd15eabd403cd4b1c.tar.lz
cuberite-0d003a2d2a8807983f23372dd15eabd403cd4b1c.tar.xz
cuberite-0d003a2d2a8807983f23372dd15eabd403cd4b1c.tar.zst
cuberite-0d003a2d2a8807983f23372dd15eabd403cd4b1c.zip
Diffstat (limited to 'src/Tracer.cpp')
-rw-r--r--src/Tracer.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/Tracer.cpp b/src/Tracer.cpp
index e604f4a5b..bd5fcebc5 100644
--- a/src/Tracer.cpp
+++ b/src/Tracer.cpp
@@ -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;
}