From 9bb61e6e2e23fc8a66dbc95d918f23b89ba60314 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 20 Jan 2014 09:17:24 -0800 Subject: Seperated BlockArea From World If anyone can come up with a better name for the interface I'll change it, It contians to methods which do compleatly unrelated things --- src/BlockArea.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index 075cc99ec..ae23c76c6 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -12,13 +12,10 @@ #pragma once +#include "ForEachChunkProvider.h" - -// fwd: World.h -class cWorld; - // fwd: FastNBT.h class cParsedNBT; @@ -68,13 +65,13 @@ public: void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ); /// Reads an area of blocks specified. Returns true if successful. All coords are inclusive. - bool Read(cWorld * a_World, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas); + bool Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas); // TODO: Write() is not too good an interface: if it fails, there's no way to repeat only for the parts that didn't write // A better way may be to return a list of cBlockAreas for each part that didn't succeed writing, so that the caller may try again /// Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all - bool Write(cWorld * a_World, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas); + bool Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas); /// Copies this object's contents into the specified BlockArea. void CopyTo(cBlockArea & a_Into) const; -- cgit v1.2.3 From 4f09e8df6ecf20bd50573b7bf40c46f5ade21124 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 20 Jan 2014 09:59:12 -0800 Subject: Moved Schematic file methods to seperate class --- src/BlockArea.h | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index ae23c76c6..59bc0f241 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -15,14 +15,6 @@ #include "ForEachChunkProvider.h" - -// fwd: FastNBT.h -class cParsedNBT; - - - - - // tolua_begin class cBlockArea { @@ -82,12 +74,6 @@ public: /// For testing purposes only, dumps the area into a file. void DumpToRawFile(const AString & a_FileName); - /// Loads an area from a .schematic file. Returns true if successful - bool LoadFromSchematicFile(const AString & a_FileName); - - /// Saves the area into a .schematic file. Returns true if successful - bool SaveToSchematicFile(const AString & a_FileName); - /// Crops the internal contents by the specified amount of blocks from each border. void Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ); @@ -230,6 +216,7 @@ public: protected: friend class cChunkDesc; + friend class cSchematicFileSerializer; class cChunkReader : public cChunkDataCallback @@ -288,9 +275,6 @@ protected: // Expand helpers: void ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); void ExpandNibbles (NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); - - /// Loads the area from a schematic file uncompressed and parsed into a NBT tree. Returns true if successful. - bool LoadFromSchematicNBT(cParsedNBT & a_NBT); /// Sets the specified datatypes at the specified location. void RelSetData( -- cgit v1.2.3 From a3fa52ec739d6640f7dc4d481de77d633111cf46 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 20 Feb 2014 10:48:29 +0100 Subject: Fixed bindings for cBlockArea:Get(Rel)BlockTypeMeta(). They no longer require the ghost output params. --- src/BlockArea.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index 59bc0f241..b4a161f32 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -184,9 +184,15 @@ public: void SetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); + + // tolua_end + + // These need manual exporting, tolua generates the binding as requiring 2 extra input params void GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const; void GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const; + // tolua_begin + int GetSizeX(void) const { return m_SizeX; } int GetSizeY(void) const { return m_SizeY; } int GetSizeZ(void) const { return m_SizeZ; } -- cgit v1.2.3 From ea84f8cf89b36b97ae410dcd4fe65d309884cad1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 23 Feb 2014 14:08:05 +0100 Subject: Added cBlockArea::GetVolume, exported to Lua API. --- src/BlockArea.h | 57 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index b4a161f32..5ef814d0e 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -24,7 +24,7 @@ class cBlockArea public: - /// What data is to be queried (bit-mask) + /** What data is to be queried (bit-mask) */ enum { baTypes = 1, @@ -44,7 +44,7 @@ public: cBlockArea(void); ~cBlockArea(); - /// Clears the data stored to reclaim memory + /** Clears the data stored to reclaim memory */ void Clear(void); /** Creates a new area of the specified size and contents. @@ -53,31 +53,31 @@ public: */ void Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes = baTypes | baMetas); - /// Resets the origin. No other changes are made, contents are untouched. + /** Resets the origin. No other changes are made, contents are untouched. */ void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ); - /// Reads an area of blocks specified. Returns true if successful. All coords are inclusive. + /** Reads an area of blocks specified. Returns true if successful. All coords are inclusive. */ bool Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas); // TODO: Write() is not too good an interface: if it fails, there's no way to repeat only for the parts that didn't write // A better way may be to return a list of cBlockAreas for each part that didn't succeed writing, so that the caller may try again - /// Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all + /** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all */ bool Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas); - /// Copies this object's contents into the specified BlockArea. + /** Copies this object's contents into the specified BlockArea. */ void CopyTo(cBlockArea & a_Into) const; - /// Copies the contents from the specified BlockArea into this object. + /** Copies the contents from the specified BlockArea into this object. */ void CopyFrom(const cBlockArea & a_From); - /// For testing purposes only, dumps the area into a file. + /** For testing purposes only, dumps the area into a file. */ void DumpToRawFile(const AString & a_FileName); - /// Crops the internal contents by the specified amount of blocks from each border. + /** Crops the internal contents by the specified amount of blocks from each border. */ void Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ); - /// Expands the internal contents by the specified amount of blocks from each border + /** Expands the internal contents by the specified amount of blocks from each border */ void Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); /** Merges another block area into this one, using the specified block combinating strategy @@ -117,49 +117,49 @@ public: */ void Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy); - /// Fills the entire block area with the specified data + /** Fills the entire block area with the specified data */ void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f); - /// Fills a cuboid inside the block area with the specified data + /** Fills a cuboid inside the block area with the specified data */ void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f ); - /// Draws a line from between two points with the specified data + /** Draws a line from between two points with the specified data */ void RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int a_RelY2, int a_RelZ2, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f ); - /// Rotates the entire area counter-clockwise around the Y axis + /** Rotates the entire area counter-clockwise around the Y axis */ void RotateCCW(void); - /// Rotates the entire area clockwise around the Y axis + /** Rotates the entire area clockwise around the Y axis */ void RotateCW(void); - /// Mirrors the entire area around the XY plane + /** Mirrors the entire area around the XY plane */ void MirrorXY(void); - /// Mirrors the entire area around the XZ plane + /** Mirrors the entire area around the XZ plane */ void MirrorXZ(void); - /// Mirrors the entire area around the YZ plane + /** Mirrors the entire area around the YZ plane */ void MirrorYZ(void); - /// Rotates the entire area counter-clockwise around the Y axis, doesn't use blockhandlers for block meta + /** Rotates the entire area counter-clockwise around the Y axis, doesn't use blockhandlers for block meta */ void RotateCCWNoMeta(void); - /// Rotates the entire area clockwise around the Y axis, doesn't use blockhandlers for block meta + /** Rotates the entire area clockwise around the Y axis, doesn't use blockhandlers for block meta */ void RotateCWNoMeta(void); - /// Mirrors the entire area around the XY plane, doesn't use blockhandlers for block meta + /** Mirrors the entire area around the XY plane, doesn't use blockhandlers for block meta */ void MirrorXYNoMeta(void); - /// Mirrors the entire area around the XZ plane, doesn't use blockhandlers for block meta + /** Mirrors the entire area around the XZ plane, doesn't use blockhandlers for block meta */ void MirrorXZNoMeta(void); - /// Mirrors the entire area around the YZ plane, doesn't use blockhandlers for block meta + /** Mirrors the entire area around the YZ plane, doesn't use blockhandlers for block meta */ void MirrorYZNoMeta(void); // Setters: @@ -197,11 +197,14 @@ public: int GetSizeY(void) const { return m_SizeY; } int GetSizeZ(void) const { return m_SizeZ; } + /** Returns the volume of the area, as number of blocks */ + int GetVolume(void) const { return m_SizeX * m_SizeY * m_SizeZ; } + int GetOriginX(void) const { return m_OriginX; } int GetOriginY(void) const { return m_OriginY; } int GetOriginZ(void) const { return m_OriginZ; } - /// Returns the datatypes that are stored in the object (bitmask of baXXX values) + /** Returns the datatypes that are stored in the object (bitmask of baXXX values) */ int GetDataTypes(void) const; bool HasBlockTypes (void) const { return (m_BlockTypes != NULL); } @@ -212,7 +215,7 @@ public: // tolua_end // Clients can use these for faster access to all blocktypes. Be careful though! - /// Returns the internal pointer to the block types + /** Returns the internal pointer to the block types */ BLOCKTYPE * GetBlockTypes (void) const { return m_BlockTypes; } NIBBLETYPE * GetBlockMetas (void) const { return m_BlockMetas; } // NOTE: one byte per block! NIBBLETYPE * GetBlockLight (void) const { return m_BlockLight; } // NOTE: one byte per block! @@ -263,7 +266,7 @@ protected: NIBBLETYPE * m_BlockLight; // Each light value is stored as a separate byte for faster access NIBBLETYPE * m_BlockSkyLight; // Each light value is stored as a separate byte for faster access - /// Clears the data stored and prepares a fresh new block area with the specified dimensions + /** Clears the data stored and prepares a fresh new block area with the specified dimensions */ bool SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes); // Basic Setters: @@ -282,7 +285,7 @@ protected: void ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); void ExpandNibbles (NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); - /// Sets the specified datatypes at the specified location. + /** Sets the specified datatypes at the specified location. */ void RelSetData( int a_RelX, int a_RelY, int a_RelZ, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, -- cgit v1.2.3 From 9ab766189d6330988db190ddecd386d7c58d47b6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 24 Feb 2014 23:17:12 +0100 Subject: Added useful parameter overloads to cBlockArea Lua API. --- src/BlockArea.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index 5ef814d0e..0703f195e 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -15,6 +15,16 @@ #include "ForEachChunkProvider.h" + + +// fwd: +class cCuboid; +class Vector3i; + + + + + // tolua_begin class cBlockArea { @@ -56,15 +66,27 @@ public: /** Resets the origin. No other changes are made, contents are untouched. */ void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ); + /** Resets the origin. No other changes are made, contents are untouched. */ + void SetOrigin(const Vector3i & a_Origin); + /** Reads an area of blocks specified. Returns true if successful. All coords are inclusive. */ bool Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas); + /** Reads an area of blocks specified. Returns true if successful. The bounds are included in the read area. */ + bool Read(cForEachChunkProvider * a_ForEachChunkProvider, const cCuboid & a_Bounds, int a_DataTypes = baTypes | baMetas); + + /** Reads an area of blocks specified. Returns true if successful. The bounds are included in the read area. */ + bool Read(cForEachChunkProvider * a_ForEachChunkProvider, const Vector3i & a_Point1, const Vector3i & a_Point2, int a_DataTypes = baTypes | baMetas); + // TODO: Write() is not too good an interface: if it fails, there's no way to repeat only for the parts that didn't write // A better way may be to return a list of cBlockAreas for each part that didn't succeed writing, so that the caller may try again /** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all */ bool Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas); + /** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all */ + bool Write(cForEachChunkProvider * a_ForEachChunkProvider, const Vector3i & a_MinCoords, int a_DataTypes = baTypes | baMetas); + /** Copies this object's contents into the specified BlockArea. */ void CopyTo(cBlockArea & a_Into) const; @@ -117,6 +139,10 @@ public: */ void Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy); + /** Merges another block area into this one, using the specified block combinating strategy. + See Merge() above for details. */ + void Merge(const cBlockArea & a_Src, const Vector3i & a_RelMinCoords, eMergeStrategy a_Strategy); + /** Fills the entire block area with the specified data */ void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f); @@ -126,12 +152,24 @@ public: NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f ); + /** Fills a cuboid inside the block area with the specified data. a_Cuboid must be sorted. */ + void FillRelCuboid(const cCuboid & a_RelCuboid, + int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, + NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f + ); + /** Draws a line from between two points with the specified data */ void RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int a_RelY2, int a_RelZ2, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f ); + /** Draws a line from between two points with the specified data */ + void RelLine(const Vector3i & a_Point1, const Vector3i & a_Point2, + int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, + NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f + ); + /** Rotates the entire area counter-clockwise around the Y axis */ void RotateCCW(void); -- cgit v1.2.3 From 0cce0478d846114f49c4b8fe201aee7a1bb06b22 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 10 Mar 2014 17:07:46 +0100 Subject: This allows a blockarea to have an Offset. --- src/BlockArea.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index 0703f195e..d89c9b372 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -209,6 +209,8 @@ public: void SetBlockLight (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockLight); void SetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockSkyLight); void SetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockSkyLight); + void SetOffset (int a_OffsetX, int a_OffsetY, int a_OffsetZ); + void SetOffset (Vector3i a_Offset); // Getters: BLOCKTYPE GetRelBlockType (int a_RelX, int a_RelY, int a_RelZ) const; @@ -219,6 +221,7 @@ public: NIBBLETYPE GetBlockLight (int a_BlockX, int a_BlockY, int a_BlockZ) const; NIBBLETYPE GetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ) const; NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ) const; + Vector3i GetOffset (void) const {return m_Offset;} void SetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); @@ -299,6 +302,8 @@ protected: int m_SizeY; int m_SizeZ; + Vector3i m_Offset; + BLOCKTYPE * m_BlockTypes; NIBBLETYPE * m_BlockMetas; // Each meta is stored as a separate byte for faster access NIBBLETYPE * m_BlockLight; // Each light value is stored as a separate byte for faster access -- cgit v1.2.3 From 541175d8a08515568d75a8d6b57bc4841e273c4a Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 11 Mar 2014 14:44:21 +0100 Subject: Using ```const Vector3i &``` --- src/BlockArea.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index d89c9b372..75b8db3a6 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -210,7 +210,7 @@ public: void SetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockSkyLight); void SetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockSkyLight); void SetOffset (int a_OffsetX, int a_OffsetY, int a_OffsetZ); - void SetOffset (Vector3i a_Offset); + void SetOffset (const Vector3i & a_Offset); // Getters: BLOCKTYPE GetRelBlockType (int a_RelX, int a_RelY, int a_RelZ) const; @@ -221,7 +221,7 @@ public: NIBBLETYPE GetBlockLight (int a_BlockX, int a_BlockY, int a_BlockZ) const; NIBBLETYPE GetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ) const; NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ) const; - Vector3i GetOffset (void) const {return m_Offset;} + const Vector3i & GetOffset (void) const {return m_Offset;} void SetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); -- cgit v1.2.3 From e213e5f9fcb3681a5f383546e17b9800d4a4804a Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 11 Mar 2014 18:23:21 +0100 Subject: Renamed m_Offset to m_WEOffset --- src/BlockArea.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index 75b8db3a6..76424d02f 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -221,7 +221,7 @@ public: NIBBLETYPE GetBlockLight (int a_BlockX, int a_BlockY, int a_BlockZ) const; NIBBLETYPE GetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ) const; NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ) const; - const Vector3i & GetOffset (void) const {return m_Offset;} + const Vector3i & GetOffset (void) const {return m_WEOffset;} void SetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); @@ -302,7 +302,8 @@ protected: int m_SizeY; int m_SizeZ; - Vector3i m_Offset; + // Used for schematics that are created by the WorldEdit plugin. The offset is used for player-relative pasting. + Vector3i m_WEOffset; BLOCKTYPE * m_BlockTypes; NIBBLETYPE * m_BlockMetas; // Each meta is stored as a separate byte for faster access -- cgit v1.2.3 From 950614da7e700b8847f0dcc0bac9d76367801a3f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 12 Mar 2014 07:46:14 +0100 Subject: Renamed cBlockArea Offset to WEOffset. Even in getters / setters. --- src/BlockArea.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index 76424d02f..31918ce8c 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -209,8 +209,8 @@ public: void SetBlockLight (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockLight); void SetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_BlockSkyLight); void SetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_BlockSkyLight); - void SetOffset (int a_OffsetX, int a_OffsetY, int a_OffsetZ); - void SetOffset (const Vector3i & a_Offset); + void SetWEOffset (int a_OffsetX, int a_OffsetY, int a_OffsetZ); + void SetWEOffset (const Vector3i & a_Offset); // Getters: BLOCKTYPE GetRelBlockType (int a_RelX, int a_RelY, int a_RelZ) const; @@ -221,7 +221,7 @@ public: NIBBLETYPE GetBlockLight (int a_BlockX, int a_BlockY, int a_BlockZ) const; NIBBLETYPE GetRelBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ) const; NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ) const; - const Vector3i & GetOffset (void) const {return m_WEOffset;} + const Vector3i & GetWEOffset (void) const {return m_WEOffset;} void SetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); @@ -302,7 +302,8 @@ protected: int m_SizeY; int m_SizeZ; - // Used for schematics that are created by the WorldEdit plugin. The offset is used for player-relative pasting. + /** An extra data value sometimes stored in the .schematic file. Used mainly by the WorldEdit plugin. + cBlockArea doesn't use this value in any way. */ Vector3i m_WEOffset; BLOCKTYPE * m_BlockTypes; -- cgit v1.2.3 From b4bf13aa4f004a7819e262679a295d8ca886557b Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 11 Mar 2014 16:01:17 +0200 Subject: Unified Vector classes --- src/BlockArea.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index 0703f195e..0e52a5de0 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -13,13 +13,13 @@ #pragma once #include "ForEachChunkProvider.h" +#include "Vector3.h" // fwd: class cCuboid; -class Vector3i; -- cgit v1.2.3 From 87e0bd54b426bafb6b267725b0e1a94511a38f4e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 25 Mar 2014 21:59:25 +0100 Subject: BlockArea: Switched internal coords to Vector3i. --- src/BlockArea.h | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index e0e8fe972..22d55e2c9 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -43,6 +43,8 @@ public: baSkyLight = 8, } ; + /** The per-block strategy to use when merging another block area into this object. + See the Merge function for the description of these */ enum eMergeStrategy { msOverwrite, @@ -232,18 +234,24 @@ public: void GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const; void GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const; + // GetSize() is already exported manually to return 3 numbers, can't auto-export + const Vector3i & GetSize(void) const { return m_Size; } + + // GetOrigin() is already exported manually to return 3 numbers, can't auto-export + const Vector3i & GetOrigin(void) const { return m_Origin; } + // tolua_begin - int GetSizeX(void) const { return m_SizeX; } - int GetSizeY(void) const { return m_SizeY; } - int GetSizeZ(void) const { return m_SizeZ; } + int GetSizeX(void) const { return m_Size.x; } + int GetSizeY(void) const { return m_Size.y; } + int GetSizeZ(void) const { return m_Size.z; } /** Returns the volume of the area, as number of blocks */ - int GetVolume(void) const { return m_SizeX * m_SizeY * m_SizeZ; } + int GetVolume(void) const { return m_Size.x * m_Size.y * m_Size.z; } - int GetOriginX(void) const { return m_OriginX; } - int GetOriginY(void) const { return m_OriginY; } - int GetOriginZ(void) const { return m_OriginZ; } + int GetOriginX(void) const { return m_Origin.x; } + int GetOriginY(void) const { return m_Origin.y; } + int GetOriginZ(void) const { return m_Origin.z; } /** Returns the datatypes that are stored in the object (bitmask of baXXX values) */ int GetDataTypes(void) const; @@ -261,7 +269,7 @@ public: NIBBLETYPE * GetBlockMetas (void) const { return m_BlockMetas; } // NOTE: one byte per block! NIBBLETYPE * GetBlockLight (void) const { return m_BlockLight; } // NOTE: one byte per block! NIBBLETYPE * GetBlockSkyLight(void) const { return m_BlockSkyLight; } // NOTE: one byte per block! - int GetBlockCount(void) const { return m_SizeX * m_SizeY * m_SizeZ; } + int GetBlockCount(void) const { return m_Size.x * m_Size.y * m_Size.z; } int MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const; protected: @@ -276,9 +284,7 @@ protected: protected: cBlockArea & m_Area; - int m_OriginX; - int m_OriginY; - int m_OriginZ; + Vector3i m_Origin; int m_CurrentChunkX; int m_CurrentChunkZ; @@ -295,12 +301,8 @@ protected: typedef NIBBLETYPE * NIBBLEARRAY; - int m_OriginX; - int m_OriginY; - int m_OriginZ; - int m_SizeX; - int m_SizeY; - int m_SizeZ; + Vector3i m_Origin; + Vector3i m_Size; /** An extra data value sometimes stored in the .schematic file. Used mainly by the WorldEdit plugin. cBlockArea doesn't use this value in any way. */ -- cgit v1.2.3 From 87de5960785e0e007eaee0a8dbb77c64e20e7c8c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 25 Mar 2014 22:05:45 +0100 Subject: BlockArea: Create() can take the size as Vector3i, too. --- src/BlockArea.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index 22d55e2c9..d28325d7d 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -59,12 +59,18 @@ public: /** Clears the data stored to reclaim memory */ void Clear(void); - /** Creates a new area of the specified size and contents. - Origin is set to all zeroes. + /** Creates a new area of the specified size and contents. + Origin is set to all zeroes. BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light. */ void Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes = baTypes | baMetas); + /** Creates a new area of the specified size and contents. + Origin is set to all zeroes. + BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light. + */ + void Create(const Vector3i & a_Size, int a_DataTypes = baTypes | baMetas); + /** Resets the origin. No other changes are made, contents are untouched. */ void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ); -- cgit v1.2.3 From 8557549cfac260867112be96e24b2c0e059db47e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 28 Mar 2014 18:03:37 +0100 Subject: Implemented the msSpongePrint merge strategy. Similar to msImprint, but allows prefabs to carve out air pockets, too. The sponge block is used as the NOP block. --- src/BlockArea.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index d28325d7d..d37f0d182 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -51,6 +51,7 @@ public: msFillAir, msImprint, msLake, + msSpongePrint, } ; cBlockArea(void); @@ -127,8 +128,8 @@ public: - msFillAir overwrites only those blocks that were air - msImprint overwrites with only those blocks that are non-air - Special strategies: - msLake (evaluate top-down, first match wins): + Special strategies (evaluate top-down, first match wins): + msLake: | area block | | | this | Src | result | +----------+--------+--------+ @@ -143,6 +144,14 @@ public: | mycelium | stone | stone | ... and mycelium | A | stone | A | ... but nothing else | A | * | A | Everything else is left as it is + + msSpongePrint: + Used for most generators, it allows carving out air pockets, too, and uses the Sponge as the NOP block + | area block | | + | this | Src | result | + +----------+--------+--------+ + | A | sponge | A | Sponge is the NOP block + | * | B | B | Everything else overwrites anything */ void Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy); -- cgit v1.2.3 From c4e07631c803debf1047a5607c96d9bf5c1e5f95 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 31 Mar 2014 19:47:18 +0200 Subject: Added new merge strategy "msDifference" --- src/BlockArea.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index d37f0d182..0bb272fd9 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -52,6 +52,7 @@ public: msImprint, msLake, msSpongePrint, + msDifference, } ; cBlockArea(void); -- cgit v1.2.3 From 1229795ff0fd82412e780fffc9f37a2d6eed5522 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 1 Apr 2014 20:50:10 +0200 Subject: cBlockArea: Added the msMask merge strategy. --- src/BlockArea.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index d37f0d182..34a0ef926 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -52,6 +52,7 @@ public: msImprint, msLake, msSpongePrint, + msMask, } ; cBlockArea(void); @@ -152,6 +153,14 @@ public: +----------+--------+--------+ | A | sponge | A | Sponge is the NOP block | * | B | B | Everything else overwrites anything + + msMask: + Combines two areas, the blocks that are the same are kept, differing ones are reset to air + | area block | | + | this | Src | result | + +------+-------+--------+ + | A | A | A | Same blocks are kept + | A | non-A | air | Everything else is replaced with air */ void Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy); -- cgit v1.2.3