diff options
author | Tycho <work.tycho+git@gmail.com> | 2014-03-01 18:47:27 +0100 |
---|---|---|
committer | Tycho <work.tycho+git@gmail.com> | 2014-03-01 18:47:27 +0100 |
commit | 0acfbdd91283c96fd0f371f51029a72d6c9cd3de (patch) | |
tree | 24a03b356cc4c4cae4057f425f3f187931ee5014 /src | |
parent | Added some Metadate rotaters using templated Mixin (diff) | |
download | cuberite-0acfbdd91283c96fd0f371f51029a72d6c9cd3de.tar cuberite-0acfbdd91283c96fd0f371f51029a72d6c9cd3de.tar.gz cuberite-0acfbdd91283c96fd0f371f51029a72d6c9cd3de.tar.bz2 cuberite-0acfbdd91283c96fd0f371f51029a72d6c9cd3de.tar.lz cuberite-0acfbdd91283c96fd0f371f51029a72d6c9cd3de.tar.xz cuberite-0acfbdd91283c96fd0f371f51029a72d6c9cd3de.tar.zst cuberite-0acfbdd91283c96fd0f371f51029a72d6c9cd3de.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Blocks/MetaRotater.h | 96 |
1 files changed, 51 insertions, 45 deletions
diff --git a/src/Blocks/MetaRotater.h b/src/Blocks/MetaRotater.h index f1656f1bd..b83ed177a 100644 --- a/src/Blocks/MetaRotater.h +++ b/src/Blocks/MetaRotater.h @@ -1,7 +1,7 @@ #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 { public: @@ -19,64 +19,70 @@ public: }; -template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West> -NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West>::MetaRotateCW(NIBBLETYPE a_Meta) +template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched> +NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West, AssertIfNotMatched>::MetaRotateCW(NIBBLETYPE a_Meta) { -NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); -switch (a_Meta & BitFilter) -{ -case South: return West | OtherMeta; -case West: return North | OtherMeta; -case North: return East | OtherMeta; -case East: return South | OtherMeta; -} -ASSERT(!"Invalid Meta value"); -return a_Meta; + NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); + switch (a_Meta & BitFilter) + { + case South: return West | OtherMeta; + case West: return North | OtherMeta; + case North: return East | OtherMeta; + case East: return South | OtherMeta; + } + if(AssertIfNotMatched) + { + ASSERT(!"Invalid Meta value"); + return a_Meta; + } } -template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West> -NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West>::MetaRotateCCW(NIBBLETYPE a_Meta) +template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched> +NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West, AssertIfNotMatched>::MetaRotateCCW(NIBBLETYPE a_Meta) { -NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); -switch (a_Meta & BitFilter) -{ -case South: return East | OtherMeta; -case East: return North | OtherMeta; -case North: return West | OtherMeta; -case West: return South | OtherMeta; -} -ASSERT(!"Invalid Meta value"); -return a_Meta; + NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); + switch (a_Meta & BitFilter) + { + case South: return East | OtherMeta; + case East: return North | OtherMeta; + case North: return West | OtherMeta; + case West: return South | OtherMeta; + } + if(AssertIfNotMatched) + { + ASSERT(!"Invalid Meta value"); + return a_Meta; + } } -template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West> -NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West>::MetaMirrorXY(NIBBLETYPE a_Meta) +template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched> +NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West, AssertIfNotMatched>::MetaMirrorXY(NIBBLETYPE a_Meta) { -NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); -switch (a_Meta & BitFilter) -{ -case South: return North | OtherMeta; -case North: return South | OtherMeta; -} -// Not Facing North or South; No change. -return a_Meta; + NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); + switch (a_Meta & BitFilter) + { + case South: return North | OtherMeta; + case North: return South | OtherMeta; + } + // Not Facing North or South; No change. + return a_Meta; } -template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West> -NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West>::MetaMirrorYZ(NIBBLETYPE a_Meta) +template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched> +NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West, AssertIfNotMatched>::MetaMirrorYZ(NIBBLETYPE a_Meta) { -NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); -switch (a_Meta & BitFilter) -{ -case West: return East | OtherMeta; -case East: return West | OtherMeta; -} -// Not Facing East or West; No change. -return a_Meta; + NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); + switch (a_Meta & BitFilter) + { + case West: return East | OtherMeta; + case East: return West | OtherMeta; + } + // Not Facing East or West; No change. + return a_Meta; } |