From de5b1401f813985300c33c6b3166b115f9a10dd3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 8 Feb 2015 16:35:10 +0000 Subject: Comparators --- src/ChunkDef.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/ChunkDef.h') diff --git a/src/ChunkDef.h b/src/ChunkDef.h index b03a03bff..fb3451db1 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -96,6 +96,12 @@ public: a_Z = a_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) + { + return Vector3i(a_RelBlockPosition.x + a_ChunkX * Width, a_RelBlockPosition.y, a_RelBlockPosition.z + a_ChunkZ * Width); + } + /// Converts absolute block coords to chunk coords: inline static void BlockToChunk(int a_X, int a_Z, int & a_ChunkX, int & a_ChunkZ) -- cgit v1.2.3 From 84534dfeb288dd12d998f3f192ee162a1def5367 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 26 Apr 2015 00:38:41 +0100 Subject: Redstone wire and trapdoor fixes * Fixes #1887 * Fixes #1763 * Fixes #1083 --- src/ChunkDef.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/ChunkDef.h') 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) { -- cgit v1.2.3 From 171c59a01b07b7513cf7a281bbcb141e8182d274 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 2 Jun 2015 13:29:52 +0100 Subject: Changed appropriate containers to unordered_map Thanks to @worktycho for guidance! * Potential speed improvements --- src/ChunkDef.h | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'src/ChunkDef.h') diff --git a/src/ChunkDef.h b/src/ChunkDef.h index a1273bd23..57c4e6918 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -514,32 +514,3 @@ typedef cCoordWithData cCoordWithBlock; typedef std::list cCoordWithIntList; typedef std::vector cCoordWithIntVector; - - - - - -/** Generic template that can store two types of any kind of data together with a triplet of 3 coords */ -template class cCoordWithDoubleData -{ -public: - int x; - int y; - int z; - X Data; - Z DataTwo; - - cCoordWithDoubleData(int a_X, int a_Y, int a_Z) : - x(a_X), y(a_Y), z(a_Z) - { - } - - cCoordWithDoubleData(int a_X, int a_Y, int a_Z, const X & a_Data, const Z & a_DataTwo) : - x(a_X), y(a_Y), z(a_Z), Data(a_Data), DataTwo(a_DataTwo) - { - } -}; - -typedef cCoordWithDoubleData cCoordWithBlockAndBool; - -typedef std::vector cCoordWithBlockAndBoolVector; -- cgit v1.2.3