diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2015-04-26 01:38:41 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2015-06-06 13:21:19 +0200 |
commit | 84534dfeb288dd12d998f3f192ee162a1def5367 (patch) | |
tree | a8debc1723cafc6066d46edfc02888218ba7cb4d /src/ChunkDef.h | |
parent | Provides improvements to redstone wire (diff) | |
download | cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.tar cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.tar.gz cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.tar.bz2 cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.tar.lz cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.tar.xz cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.tar.zst cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.zip |
Diffstat (limited to '')
-rw-r--r-- | src/ChunkDef.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/ChunkDef.h b/src/ChunkDef.h index fb3451db1..a1273bd23 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -96,6 +96,19 @@ public: a_Z = a_Z - a_ChunkZ * Width; } + inline static Vector3i AbsoluteToRelative(Vector3i a_BlockPosition) + { + int ChunkX, ChunkZ; + BlockToChunk(a_BlockPosition.x, a_BlockPosition.z, ChunkX, ChunkZ); + + return {a_BlockPosition.x - ChunkX * Width, a_BlockPosition.y, a_BlockPosition.z - ChunkZ * Width}; + } + + inline static Vector3i AbsoluteToRelative(Vector3i a_BlockPosition, int a_ChunkX, int a_ChunkZ) + { + return {a_BlockPosition.x - a_ChunkX * Width, a_BlockPosition.y, a_BlockPosition.z - a_ChunkZ * Width}; + } + /** Converts relative block coordinates into absolute coordinates with a known chunk location */ inline static Vector3i RelativeToAbsolute(const Vector3i & a_RelBlockPosition, int a_ChunkX, int a_ChunkZ) { |