From 2df14a04962037b93352c2fc53349af54ab3b14d Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Sun, 4 Feb 2018 22:15:31 +0000 Subject: cChunk and cChunkData: Use vectors for block get and set functions (#4172) * cChunkData: Change interface to use Vector3i * cChunk: Add Vector3i overloads for bounded block get and set functions. --- src/ChunkDef.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/ChunkDef.h') diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 188ad33d8..bdba4061f 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -144,6 +144,16 @@ public: return ((a_Width >= 0) && (a_Width < Width)); } + /** Validates a chunk relative coordinate. Returns false if the coordiante is out of bounds for a chunk. */ + inline static bool IsValidRelPos(Vector3i a_RelPos) + { + return ( + IsValidWidth(a_RelPos.x) && + IsValidHeight(a_RelPos.y) && + IsValidWidth(a_RelPos.z) + ); + } + /** 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