From 6536233f4d0bb9411895ce78d1c57e37a7aac044 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 2 Mar 2014 12:29:20 -0800 Subject: Reformated MetaRotater --- src/Blocks/MetaRotater.h | 49 +++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'src/Blocks/MetaRotater.h') 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 +/* +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 cMetaRotater : public Base { public: @@ -19,18 +30,18 @@ public: }; -template -NIBBLETYPE cMetaRotater::MetaRotateCW(NIBBLETYPE a_Meta) +template +NIBBLETYPE cMetaRotater::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 -NIBBLETYPE cMetaRotater::MetaRotateCCW(NIBBLETYPE a_Meta) +template +NIBBLETYPE cMetaRotater::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 -NIBBLETYPE cMetaRotater::MetaMirrorXY(NIBBLETYPE a_Meta) +template +NIBBLETYPE cMetaRotater::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 -NIBBLETYPE cMetaRotater::MetaMirrorYZ(NIBBLETYPE a_Meta) +template +NIBBLETYPE cMetaRotater::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; -- cgit v1.2.3