diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-25 21:14:36 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-25 21:14:36 +0100 |
commit | 7ac31319846221186dcd4e2f7e093871c2d815d0 (patch) | |
tree | 010020331fb2e9e08709c4856e08e7f3b9703f8c /source/BlockArea.cpp | |
parent | BlockArea: Implemented mirroring without meta manipulation (diff) | |
download | cuberite-7ac31319846221186dcd4e2f7e093871c2d815d0.tar cuberite-7ac31319846221186dcd4e2f7e093871c2d815d0.tar.gz cuberite-7ac31319846221186dcd4e2f7e093871c2d815d0.tar.bz2 cuberite-7ac31319846221186dcd4e2f7e093871c2d815d0.tar.lz cuberite-7ac31319846221186dcd4e2f7e093871c2d815d0.tar.xz cuberite-7ac31319846221186dcd4e2f7e093871c2d815d0.tar.zst cuberite-7ac31319846221186dcd4e2f7e093871c2d815d0.zip |
Diffstat (limited to '')
-rw-r--r-- | source/BlockArea.cpp | 82 |
1 files changed, 76 insertions, 6 deletions
diff --git a/source/BlockArea.cpp b/source/BlockArea.cpp index 229098967..c037c1115 100644 --- a/source/BlockArea.cpp +++ b/source/BlockArea.cpp @@ -969,20 +969,90 @@ void cBlockArea::MirrorYZ(void) -void cBlockArea::RotateCWNoMeta(void)
+void cBlockArea::RotateCCWNoMeta(void)
{
- ASSERT(!"Not implemented yet");
- // TODO
+ if (HasBlockTypes())
+ {
+ BLOCKTYPE * NewTypes = new BLOCKTYPE[m_SizeX * m_SizeY * m_SizeZ];
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ int NewZ = m_SizeX - x - 1;
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int NewX = z;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ NewTypes[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)];
+ } // for y
+ } // for z
+ } // for x
+ std::swap(m_BlockTypes, NewTypes);
+ delete[] NewTypes;
+ }
+ if (HasBlockTypes())
+ {
+ NIBBLETYPE * NewMetas = new NIBBLETYPE[m_SizeX * m_SizeY * m_SizeZ];
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ int NewZ = m_SizeX - x - 1;
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int NewX = z;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ NewMetas[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)];
+ } // for y
+ } // for z
+ } // for x
+ std::swap(m_BlockMetas, NewMetas);
+ delete[] NewMetas;
+ }
+ std::swap(m_SizeX, m_SizeZ);
}
-void cBlockArea::RotateCCWNoMeta(void)
+void cBlockArea::RotateCWNoMeta(void)
{
- ASSERT(!"Not implemented yet");
- // TODO
+ if (HasBlockTypes())
+ {
+ BLOCKTYPE * NewTypes = new BLOCKTYPE[m_SizeX * m_SizeY * m_SizeZ];
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int NewX = m_SizeZ - z - 1;
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ int NewZ = x;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ NewTypes[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)];
+ } // for y
+ } // for x
+ } // for z
+ std::swap(m_BlockTypes, NewTypes);
+ delete[] NewTypes;
+ }
+ if (HasBlockTypes())
+ {
+ NIBBLETYPE * NewMetas = new NIBBLETYPE[m_SizeX * m_SizeY * m_SizeZ];
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int NewX = m_SizeZ - z - 1;
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ int NewZ = x;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ NewMetas[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)];
+ } // for y
+ } // for x
+ } // for z
+ std::swap(m_BlockMetas, NewMetas);
+ delete[] NewMetas;
+ }
+ std::swap(m_SizeX, m_SizeZ);
}
|