diff options
author | Tycho <work.tycho+git@gmail.com> | 2014-03-02 21:29:20 +0100 |
---|---|---|
committer | Tycho <work.tycho+git@gmail.com> | 2014-03-02 21:29:20 +0100 |
commit | 6536233f4d0bb9411895ce78d1c57e37a7aac044 (patch) | |
tree | 627e625ba9d583857c8efdc41087ed1a8f84062d | |
parent | Reverted BlockVine (diff) | |
download | cuberite-6536233f4d0bb9411895ce78d1c57e37a7aac044.tar cuberite-6536233f4d0bb9411895ce78d1c57e37a7aac044.tar.gz cuberite-6536233f4d0bb9411895ce78d1c57e37a7aac044.tar.bz2 cuberite-6536233f4d0bb9411895ce78d1c57e37a7aac044.tar.lz cuberite-6536233f4d0bb9411895ce78d1c57e37a7aac044.tar.xz cuberite-6536233f4d0bb9411895ce78d1c57e37a7aac044.tar.zst cuberite-6536233f4d0bb9411895ce78d1c57e37a7aac044.zip |
-rw-r--r-- | src/Blocks/MetaRotater.h | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/src/Blocks/MetaRotater.h b/src/Blocks/MetaRotater.h index b83ed177a..5493c87e2 100644 --- a/src/Blocks/MetaRotater.h +++ b/src/Blocks/MetaRotater.h @@ -1,7 +1,18 @@ +// MetaRotater.h + +// Provides a mixin for rotations and reflections + #pragma once -template<class Base, NIBBLETYPE BitFilter, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched = false> +/* +Provides a mixin for rotations and reflections following the standard pattern of apply mask then use case. + +Usage: +Inherit from this class providing your base class as Base, the BitMask for the direction bits in bitmask and the masked value for the directions in North, East, South, West. There is also an aptional parameter AssertIfNotMatched. Set this if it is invalid for a block to exist in any other state. +*/ + +template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched = false> class cMetaRotater : public Base { public: @@ -19,18 +30,18 @@ public: }; -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) +template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched> +NIBBLETYPE cMetaRotater<Base, BitMask, North, East, South, West, AssertIfNotMatched>::MetaRotateCW(NIBBLETYPE a_Meta) { - NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); - switch (a_Meta & BitFilter) + NIBBLETYPE OtherMeta = a_Meta & (~BitMask); + switch (a_Meta & BitMask) { case South: return West | OtherMeta; case West: return North | OtherMeta; case North: return East | OtherMeta; case East: return South | OtherMeta; } - if(AssertIfNotMatched) + if (AssertIfNotMatched) { ASSERT(!"Invalid Meta value"); return a_Meta; @@ -38,18 +49,18 @@ NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West, AssertIfNotMa } -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) +template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched> +NIBBLETYPE cMetaRotater<Base, BitMask, North, East, South, West, AssertIfNotMatched>::MetaRotateCCW(NIBBLETYPE a_Meta) { - NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); - switch (a_Meta & BitFilter) + NIBBLETYPE OtherMeta = a_Meta & (~BitMask); + switch (a_Meta & BitMask) { case South: return East | OtherMeta; case East: return North | OtherMeta; case North: return West | OtherMeta; case West: return South | OtherMeta; } - if(AssertIfNotMatched) + if (AssertIfNotMatched) { ASSERT(!"Invalid Meta value"); return a_Meta; @@ -58,11 +69,11 @@ NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West, AssertIfNotMa -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) +template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched> +NIBBLETYPE cMetaRotater<Base, BitMask, North, East, South, West, AssertIfNotMatched>::MetaMirrorXY(NIBBLETYPE a_Meta) { - NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); - switch (a_Meta & BitFilter) + NIBBLETYPE OtherMeta = a_Meta & (~BitMask); + switch (a_Meta & BitMask) { case South: return North | OtherMeta; case North: return South | OtherMeta; @@ -74,11 +85,11 @@ NIBBLETYPE cMetaRotater<Base, BitFilter, North, East, South, West, AssertIfNotMa -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) +template<class Base, NIBBLETYPE BitMask, NIBBLETYPE North, NIBBLETYPE East, NIBBLETYPE South, NIBBLETYPE West, bool AssertIfNotMatched> +NIBBLETYPE cMetaRotater<Base, BitMask, North, East, South, West, AssertIfNotMatched>::MetaMirrorYZ(NIBBLETYPE a_Meta) { - NIBBLETYPE OtherMeta = a_Meta & (~BitFilter); - switch (a_Meta & BitFilter) + NIBBLETYPE OtherMeta = a_Meta & (~BitMask); + switch (a_Meta & BitMask) { case West: return East | OtherMeta; case East: return West | OtherMeta; |