From f9f73ca5d5beb59d59c18b02562b96f7db515806 Mon Sep 17 00:00:00 2001 From: Niels Breuker Date: Fri, 22 Mar 2024 12:46:11 +0100 Subject: Replaced magic numbers where constants are available --- src/Generating/ChunkDesc.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/Generating/ChunkDesc.h') diff --git a/src/Generating/ChunkDesc.h b/src/Generating/ChunkDesc.h index d10159dc9..d066660f1 100644 --- a/src/Generating/ChunkDesc.h +++ b/src/Generating/ChunkDesc.h @@ -87,6 +87,24 @@ public: /** Sets the shape in a_Shape to match the heightmap stored currently in m_HeightMap. */ void GetShapeFromHeight(Shape & a_Shape) const; + /** Returns the index into the internal shape array for the specified coords */ + inline static size_t MakeShapeIndex(int a_X, int a_Y, int a_Z) + { + return static_cast(a_Y + a_X * cChunkDef::Height + a_Z * cChunkDef::Height * cChunkDef::Width); + } + + inline static void SetShapeIsSolidAt(Shape & a_Shape, int a_X, int a_Y, int a_Z, bool a_IsSolid) + { + auto index = MakeShapeIndex(a_X, a_Y, a_Z); + a_Shape[index] = a_IsSolid ? 1 : 0; + } + + inline static bool GetShapeIsSolidAt(const Shape & a_Shape, int a_X, int a_Y, int a_Z) + { + auto index = MakeShapeIndex(a_X, a_Y, a_Z); + return a_Shape[index]; + } + // tolua_begin // Default generation: -- cgit v1.2.3