1
0

Final implementation of MetaRotater

This commit is contained in:
Tycho 2014-03-01 09:47:27 -08:00
parent 84913299f4
commit 0acfbdd912

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West> template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched = false>
class cMetaRotater : public Base class cMetaRotater : public Base
{ {
public: public:
@ -19,8 +19,8 @@ public:
}; };
template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West> template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched>
NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West>::MetaRotateCW(NIBBLETYPE a_Meta) NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West, AssertIfNotMatched>::MetaRotateCW(NIBBLETYPE a_Meta)
{ {
NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); NIBBLETYPE OtherMeta = a_Meta & (~BitFilter);
switch (a_Meta & BitFilter) switch (a_Meta & BitFilter)
@ -30,13 +30,16 @@ case West: return North | OtherMeta;
case North: return East | OtherMeta; case North: return East | OtherMeta;
case East: return South | OtherMeta; case East: return South | OtherMeta;
} }
if(AssertIfNotMatched)
{
ASSERT(!"Invalid Meta value"); ASSERT(!"Invalid Meta value");
return a_Meta; return a_Meta;
} }
}
template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West> template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched>
NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West>::MetaRotateCCW(NIBBLETYPE a_Meta) NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West, AssertIfNotMatched>::MetaRotateCCW(NIBBLETYPE a_Meta)
{ {
NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); NIBBLETYPE OtherMeta = a_Meta & (~BitFilter);
switch (a_Meta & BitFilter) switch (a_Meta & BitFilter)
@ -46,14 +49,17 @@ case East: return North | OtherMeta;
case North: return West | OtherMeta; case North: return West | OtherMeta;
case West: return South | OtherMeta; case West: return South | OtherMeta;
} }
if(AssertIfNotMatched)
{
ASSERT(!"Invalid Meta value"); ASSERT(!"Invalid Meta value");
return a_Meta; return a_Meta;
} }
}
template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West> template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched>
NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West>::MetaMirrorXY(NIBBLETYPE a_Meta) NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West, AssertIfNotMatched>::MetaMirrorXY(NIBBLETYPE a_Meta)
{ {
NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); NIBBLETYPE OtherMeta = a_Meta & (~BitFilter);
switch (a_Meta & BitFilter) switch (a_Meta & BitFilter)
@ -68,8 +74,8 @@ return a_Meta;
template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West> template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched>
NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West>::MetaMirrorYZ(NIBBLETYPE a_Meta) NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West, AssertIfNotMatched>::MetaMirrorYZ(NIBBLETYPE a_Meta)
{ {
NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); NIBBLETYPE OtherMeta = a_Meta & (~BitFilter);
switch (a_Meta & BitFilter) switch (a_Meta & BitFilter)