From 146824cb68193fd20a1f1dd441f8ceb7803e363a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 13 Apr 2014 17:26:15 +0200 Subject: NetherFortPrefabs: Fixed a connector in MidStaircase. --- src/Generating/Prefabs/NetherFortPrefabs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Generating') diff --git a/src/Generating/Prefabs/NetherFortPrefabs.cpp b/src/Generating/Prefabs/NetherFortPrefabs.cpp index 29b35a5a4..164bd9557 100644 --- a/src/Generating/Prefabs/NetherFortPrefabs.cpp +++ b/src/Generating/Prefabs/NetherFortPrefabs.cpp @@ -3367,7 +3367,7 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Connectors: "1: 12, 1, 6: 5\n" /* Type 1, direction X+ */ - "1: -1, 1, 6: 4\n" /* Type 1, direction X- */, + "1: 0, 1, 6: 4\n" /* Type 1, direction X- */, // AllowedRotations: 7, /* 1, 2, 3 CCW rotations */ -- cgit v1.2.3 From b5ea5fbf905c0917594188635b11d577d4e27f5c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 13 Apr 2014 17:27:36 +0200 Subject: Added support for per-piece per-placement weights in cPieceGenerator. Ref.: #753. --- src/Generating/PieceGenerator.cpp | 56 ++++++++++++++++++++------------------- src/Generating/PieceGenerator.h | 20 +++++++++++++- 2 files changed, 48 insertions(+), 28 deletions(-) (limited to 'src/Generating') diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index 8999a5ff7..8e9a48be6 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -392,14 +392,17 @@ bool cPieceGenerator::TryPlacePieceAtConnector( Connections.reserve(AvailablePieces.size()); Vector3i ConnPos = a_Connector.m_Pos; // The position at which the new connector should be placed - 1 block away from the connector AddFaceDirection(ConnPos.x, ConnPos.y, ConnPos.z, a_Connector.m_Direction); - - /* - // DEBUG: - printf("Placing piece at connector pos {%d, %d, %d}, direction %s\n", ConnPos.x, ConnPos.y, ConnPos.z, BlockFaceToString(a_Connector.m_Direction).c_str()); - //*/ - + int WeightTotal = 0; for (cPieces::iterator itrP = AvailablePieces.begin(), endP = AvailablePieces.end(); itrP != endP; ++itrP) { + // Get the relative chance of this piece being generated in this path: + int Weight = m_PiecePool.GetPieceWeight(a_ParentPiece, a_Connector, **itrP); + if (Weight <= 0) + { + continue; + } + + // Try fitting each of the piece's connector: cPiece::cConnectors Connectors = (*itrP)->GetConnectors(); for (cPiece::cConnectors::iterator itrC = Connectors.begin(), endC = Connectors.end(); itrC != endC; ++itrC) { @@ -419,7 +422,9 @@ bool cPieceGenerator::TryPlacePieceAtConnector( // Doesn't fit in this rotation continue; } - Connections.push_back(cConnection(**itrP, *itrC, NumCCWRotations)); + // Fits, add it to list of possibile connections: + Connections.push_back(cConnection(**itrP, *itrC, NumCCWRotations, Weight)); + WeightTotal += Weight; } // for itrC - Connectors[] } // for itrP - AvailablePieces[] if (Connections.empty()) @@ -427,21 +432,23 @@ bool cPieceGenerator::TryPlacePieceAtConnector( // No available connections, bail out return false; } + ASSERT(WeightTotal > 0); - // Choose a random connection from the list: - int rnd = m_Noise.IntNoise3DInt(a_Connector.m_Pos.x, a_Connector.m_Pos.y, a_Connector.m_Pos.z) / 7; - cConnection & Conn = Connections[rnd % Connections.size()]; + // Choose a random connection from the list, based on the weights: + int rnd = (m_Noise.IntNoise3DInt(a_Connector.m_Pos.x, a_Connector.m_Pos.y, a_Connector.m_Pos.z) / 7) % WeightTotal; + size_t ChosenIndex = 0; + for (cConnections::const_iterator itr = Connections.begin(), end = Connections.end(); itr != end; ++itr, ++ChosenIndex) + { + rnd -= itr->m_Weight; + if (rnd <= 0) + { + // This is the piece to choose + break; + } + } + cConnection & Conn = Connections[ChosenIndex]; // Place the piece: - /* - // DEBUG - printf("Chosen connector at {%d, %d, %d}, direction %s, needs %d rotations\n", - Conn.m_Connector.m_Pos.x, Conn.m_Connector.m_Pos.y, Conn.m_Connector.m_Pos.z, - BlockFaceToString(Conn.m_Connector.m_Direction).c_str(), - Conn.m_NumCCWRotations - ); - //*/ - Vector3i NewPos = Conn.m_Piece->RotatePos(Conn.m_Connector.m_Pos, Conn.m_NumCCWRotations); ConnPos -= NewPos; cPlacedPiece * PlacedPiece = new cPlacedPiece(&a_ParentPiece, *(Conn.m_Piece), ConnPos, Conn.m_NumCCWRotations); @@ -449,12 +456,6 @@ bool cPieceGenerator::TryPlacePieceAtConnector( // Add the new piece's connectors to the list of free connectors: cPiece::cConnectors Connectors = Conn.m_Piece->GetConnectors(); - - /* - // DEBUG: - printf("Adding %u connectors to the pool\n", Connectors.size() - 1); - //*/ - for (cPiece::cConnectors::const_iterator itr = Connectors.begin(), end = Connectors.end(); itr != end; ++itr) { if (itr->m_Pos.Equals(Conn.m_Connector.m_Pos)) @@ -524,10 +525,11 @@ void cPieceGenerator::DebugConnectorPool(const cPieceGenerator::cFreeConnectors /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cPieceGenerator::cConnection: -cPieceGenerator::cConnection::cConnection(cPiece & a_Piece, cPiece::cConnector & a_Connector, int a_NumCCWRotations) : +cPieceGenerator::cConnection::cConnection(cPiece & a_Piece, cPiece::cConnector & a_Connector, int a_NumCCWRotations, int a_Weight) : m_Piece(&a_Piece), m_Connector(a_Connector), - m_NumCCWRotations(a_NumCCWRotations) + m_NumCCWRotations(a_NumCCWRotations), + m_Weight(a_Weight) { } diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index bef9d3463..f4433b947 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -85,6 +85,13 @@ typedef std::vector cPieces; +// fwd: +class cPlacedPiece; + + + + + /** This class is an interface that provides pieces for the generator. It can keep track of what pieces were placed and adjust the returned piece vectors. */ class cPiecePool @@ -101,6 +108,16 @@ public: Multiple starting points are supported, one of the returned piece will be chosen. */ virtual cPieces GetStartingPieces(void) = 0; + /** Returns the relative weight with which the a_NewPiece is to be selected for placing under a_PlacedPiece through a_ExistingConnector. + This allows the pool to tweak the piece's chances, based on the previous pieces in the tree and the connector used. + The higher the number returned, the higher the chance the piece will be chosen. 0 means the piece will never be chosen. + */ + virtual int GetPieceWeight( + const cPlacedPiece & a_PlacedPiece, + const cPiece::cConnector & a_ExistingConnector, + const cPiece & a_NewPiece + ) { return 1; } + /** Called after a piece is placed, to notify the pool that it has been used. The pool may adjust the pieces it will return the next time. */ virtual void PiecePlaced(const cPiece & a_Piece) = 0; @@ -157,8 +174,9 @@ protected: cPiece * m_Piece; // The piece being connected cPiece::cConnector m_Connector; // The piece's connector being used (relative non-rotated coords) int m_NumCCWRotations; // Number of rotations necessary to match the two connectors + int m_Weight; // Relative chance that this connection will be chosen - cConnection(cPiece & a_Piece, cPiece::cConnector & a_Connector, int a_NumCCWRotations); + cConnection(cPiece & a_Piece, cPiece::cConnector & a_Connector, int a_NumCCWRotations, int a_Weight); }; typedef std::vector cConnections; -- cgit v1.2.3 From be091800f8a39024935b9692a7dae5964979d997 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Apr 2014 17:31:29 +0200 Subject: Prefabs can have per-piece per-placement weights. Fixes #753. Also upgraded NetherFortPrefabs to lates Gallery contents. --- src/Generating/NetherFortGen.cpp | 9 + src/Generating/NetherFortGen.h | 1 + src/Generating/Prefab.cpp | 74 +++- src/Generating/Prefab.h | 68 ++- src/Generating/Prefabs/NetherFortPrefabs.cpp | 632 +++++++++++++++++++++++++-- 5 files changed, 752 insertions(+), 32 deletions(-) (limited to 'src/Generating') diff --git a/src/Generating/NetherFortGen.cpp b/src/Generating/NetherFortGen.cpp index b6ec46986..7dc702e3a 100644 --- a/src/Generating/NetherFortGen.cpp +++ b/src/Generating/NetherFortGen.cpp @@ -258,6 +258,15 @@ cPieces cNetherFortGen::GetStartingPieces(void) +int cNetherFortGen::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) +{ + return ((const cPrefab &)a_NewPiece).GetPieceWeight(a_PlacedPiece, a_ExistingConnector); +} + + + + + void cNetherFortGen::PiecePlaced(const cPiece & a_Piece) { UNUSED(a_Piece); diff --git a/src/Generating/NetherFortGen.h b/src/Generating/NetherFortGen.h index 10ba01396..b82b6adf3 100644 --- a/src/Generating/NetherFortGen.h +++ b/src/Generating/NetherFortGen.h @@ -77,6 +77,7 @@ protected: // cPiecePool overrides: virtual cPieces GetPiecesWithConnector(int a_ConnectorType) override; virtual cPieces GetStartingPieces(void) override; + virtual int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector, const cPiece & a_NewPiece) override; virtual void PiecePlaced(const cPiece & a_Piece) override; virtual void Reset(void) override; } ; diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 131b6acb2..b1964e2a0 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -105,13 +105,17 @@ cPrefab::cPrefab(const cPrefab::sDef & a_Def) : m_Size(a_Def.m_SizeX, a_Def.m_SizeY, a_Def.m_SizeZ), m_HitBox(0, 0, 0, a_Def.m_SizeX - 1, a_Def.m_SizeY - 1, a_Def.m_SizeZ - 1), m_AllowedRotations(a_Def.m_AllowedRotations), - m_MergeStrategy(a_Def.m_MergeStrategy) + m_MergeStrategy(a_Def.m_MergeStrategy), + m_ShouldExtendFloor(a_Def.m_ShouldExtendFloor), + m_DefaultWeight(a_Def.m_DefaultWeight), + m_AddWeightIfSame(a_Def.m_AddWeightIfSame) { m_BlockArea[0].Create(m_Size); CharMap cm; ParseCharMap(cm, a_Def.m_CharMap); ParseBlockImage(cm, a_Def.m_Image); ParseConnectors(a_Def.m_Connectors); + ParseDepthWeight(a_Def.m_DepthWeight); // 1 CCW rotation: if ((m_AllowedRotations & 0x01) != 0) @@ -170,6 +174,26 @@ bool cPrefab::HasConnectorType(int a_ConnectorType) const +int cPrefab::GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector) const +{ + // Use the default or per-depth weight: + cDepthWeight::const_iterator itr = m_DepthWeight.find(a_PlacedPiece.GetDepth() + 1); + int res = (itr == m_DepthWeight.end()) ? m_DefaultWeight : itr->second; + + // If the piece is the same as the parent, apply the m_AddWeightIfSame modifier: + const cPiece * ParentPiece = &a_PlacedPiece.GetPiece(); + const cPiece * ThisPiece = this; + if (ThisPiece == ParentPiece) + { + res += m_AddWeightIfSame; + } + return res; +} + + + + + void cPrefab::ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef) { ASSERT(a_CharMapDef != NULL); @@ -277,6 +301,54 @@ void cPrefab::ParseConnectors(const char * a_ConnectorsDef) +void cPrefab::ParseDepthWeight(const char * a_DepthWeightDef) +{ + // The member needn't be defined at all, if so, skip: + if (a_DepthWeightDef == NULL) + { + return; + } + + // Split into individual records: "Record | Record | Record" + AStringVector Defs = StringSplitAndTrim(a_DepthWeightDef, "|"); + + // Add each record's contents: + for (AStringVector::const_iterator itr = Defs.begin(), end = Defs.end(); itr != end; ++itr) + { + // Split into components: "Depth : Weight" + AStringVector Components = StringSplitAndTrim(*itr, ":"); + if (Components.size() != 2) + { + LOGWARNING("Bad prefab DepthWeight record: \"%s\", skipping.", itr->c_str()); + continue; + } + + // Parse depth: + int Depth = atoi(Components[0].c_str()); + if ((Depth == 0) && (Components[0] != "0")) + { + LOGWARNING("Bad prefab DepthWeight record, cannot parse depth \"%s\", skipping.", Components[0].c_str()); + continue; + } + + // Parse weight: + int Weight = atoi(Components[1].c_str()); + if ((Weight == 0) && (Components[1] != "0")) + { + LOGWARNING("Bad prefab DepthWeight record, cannot parse weight \"%s\", skipping.", Components[1].c_str()); + continue; + } + + // Save to map: + ASSERT(m_DepthWeight.find(Depth) == m_DepthWeight.end()); // Not a duplicate + m_DepthWeight[Depth] = Weight; + } // for itr - Defs[] +} + + + + + cPiece::cConnectors cPrefab::GetConnectors(void) const { return m_Connectors; diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index 04c4f09da..dbf882e21 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -37,11 +37,47 @@ public: int m_SizeX; int m_SizeY; int m_SizeZ; + + /** The mapping between characters in m_Image and the blocktype / blockmeta. + Format: "Char: BlockType: BlockMeta \n Char: BlockType : BlockMeta \n ..." */ const char * m_CharMap; + + /** The actual image to be used for the prefab. Organized YZX (Y changes the least often). + Each character represents a single block, the type is mapped through m_CharMap. */ const char * m_Image; + + /** List of connectors. + Format: "Type: X, Y, Z : Direction \n Type : X, Y, Z : Direction \n ...". + Type is an arbitrary number, Direction is the BlockFace constant value (0 .. 5). */ const char * m_Connectors; + + /** Bitmask specifying the allowed rotations. + N rotations CCW are allowed if bit N is set. */ int m_AllowedRotations; + + /** The merge strategy to use while drawing the prefab. */ cBlockArea::eMergeStrategy m_MergeStrategy; + + /** If set to true, the prefab will extend its lowermost blocks until a solid block is found, + thus creating a foundation for the prefab. This is used for houses to be "on the ground", as well as + nether fortresses not to float. */ + bool m_ShouldExtendFloor; + + /** Chance of this piece being used, if no other modifier is active. */ + int m_DefaultWeight; + + /** Chances of this piece being used, per depth of the generated piece tree. + The starting piece has a depth of 0, the pieces connected to it are depth 1, etc. + The specified depth stands for the depth of the new piece (not the existing already-placed piece), + so valid depths start at 1. + Format: "Depth : Weight | Depth : Weight | Depth : Weight ..." + Depths that are not specified will use the m_DefaultWeight value. */ + const char * m_DepthWeight; + + /** The weight to add to this piece's base per-depth chance if the previous piece is the same. + Can be positive or negative. + This is used e. g. to make nether bridges prefer spanning multiple segments or to penalize turrets next to each other. */ + int m_AddWeightIfSame; }; cPrefab(const sDef & a_Def); @@ -51,6 +87,10 @@ public: /** Returns true if the prefab has any connector of the specified type. */ bool HasConnectorType(int a_ConnectorType) const; + + /** Returns the weight (chance) of this prefab generating as the next piece after the specified placed piece. + PiecePool implementations can use this for their GetPieceWeight() implementations. */ + int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector) const; protected: /** Packs complete definition of a single block, for per-letter assignment. */ @@ -60,9 +100,12 @@ protected: NIBBLETYPE m_BlockMeta; }; - /** Maps letters in the sDef::m_Image onto a number, BlockType * 16 | BlockMeta */ + /** Maps letters in the sDef::m_Image onto a sBlockTypeDef block type definition. */ typedef sBlockTypeDef CharMap[256]; + /** Maps generator tree depth to weight. */ + typedef std::map cDepthWeight; + /** The cBlockArea that contains the block definitions for the prefab. The index identifies the number of CCW rotations applied (0 = no rotation, 1 = 1 CCW rotation, ...). */ @@ -82,6 +125,26 @@ protected: /** The merge strategy to use when drawing the prefab into a block area */ cBlockArea::eMergeStrategy m_MergeStrategy; + + /** If set to true, the prefab will extend its lowermost blocks until a solid block is found, + thus creating a foundation for the prefab. This is used for houses to be "on the ground", as well as + nether fortresses not to float. */ + bool m_ShouldExtendFloor; + + /** Chance of this piece being used, if no other modifier is active. */ + int m_DefaultWeight; + + /** Chances of this piece being used, per depth of the generated piece tree. + The starting piece has a depth of 0, the pieces connected to it are depth 1, etc. + The specified depth stands for the depth of the new piece (not the existing already-placed piece), + so valid depths start at 1. + Depths that are not specified will use the m_DefaultWeight value. */ + cDepthWeight m_DepthWeight; + + /** The weight to add to this piece's base per-depth chance if the previous piece is the same. + Can be positive or negative. + This is used e. g. to make nether bridges prefer spanning multiple segments or to penalize turrets next to each other. */ + int m_AddWeightIfSame; // cPiece overrides: @@ -98,6 +161,9 @@ protected: /** Parses the connectors definition text into m_Connectors member. */ void ParseConnectors(const char * a_ConnectorsDef); + + /** Parses the per-depth weight into m_DepthWeight member. */ + void ParseDepthWeight(const char * a_DepthWeightDef); }; diff --git a/src/Generating/Prefabs/NetherFortPrefabs.cpp b/src/Generating/Prefabs/NetherFortPrefabs.cpp index 164bd9557..7a46df5d8 100644 --- a/src/Generating/Prefabs/NetherFortPrefabs.cpp +++ b/src/Generating/Prefabs/NetherFortPrefabs.cpp @@ -133,10 +133,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 0, 2, 2: 4\n" /* Type 1, direction X- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 20, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // BalconyCorridor @@ -274,10 +286,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 0, 2, 4: 4\n" /* Type 1, direction X- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 20, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // BalconyTee2 @@ -378,10 +402,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "0: 0, 1, 3: 4\n" /* Type 0, direction X- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // BlazePlatform @@ -510,10 +546,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "0: 0, 5, 3: 4\n" /* Type 0, direction X- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // BlazePlatformOverhang @@ -694,10 +742,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "0: 7, 5, 14: 3\n" /* Type 0, direction Z+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 5, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // BridgeCircleCrossing @@ -879,10 +939,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "0: 14, 5, 7: 5\n" /* Type 0, direction X+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 10, + + // DepthWeight: + "1:1000", + + // AddWeightIfSame: + 0, }, // BridgeCrossing @@ -957,10 +1029,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "0: 0, 5, 2: 4\n" /* Type 0, direction X- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "1:0", + + // AddWeightIfSame: + 0, }, // BridgeCrumble1 @@ -1041,10 +1125,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 0, 5, 2: 4\n" /* Type 1, direction X- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "1:0", + + // AddWeightIfSame: + 0, }, // BridgeCrumble2 @@ -1204,14 +1300,262 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "0: 2, 4, 15: 3\n" /* Type 0, direction Z+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 10, + + // DepthWeight: + "", + + // AddWeightIfSame: + 1000, }, // BridgeDoubleCrumble + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // BridgeFunnelDown: + // The data has been exported from the gallery Nether, area index 0, ID 2, created by Aloe_vera + { + // Size: + 15, 12, 12, // SizeX = 15, SizeY = 12, SizeZ = 12 + + // Block definitions: + ".: 0: 0\n" /* air */ + "a:112: 0\n" /* netherbrick */ + "b:114: 6\n" /* netherbrickstairs */ + "c:114: 4\n" /* netherbrickstairs */ + "d:114: 5\n" /* netherbrickstairs */ + "e: 44:14\n" /* step */ + "f:114: 7\n" /* netherbrickstairs */ + "m: 19: 0\n" /* sponge */, + + // Block data: + // Level 0 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "aammmmmmmmmmmaa" + /* 2 */ "aammmmmmmmmmmaa" + /* 3 */ "aammmmmmmmmmmaa" + /* 4 */ "mmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmaaammmmmm" + /* 10 */ "mmmmmmaaammmmmm" + /* 11 */ "mmmmmmaaammmmmm" + + // Level 1 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "aammmmmmmmmmmaa" + /* 2 */ "aammmmmmmmmmmaa" + /* 3 */ "aammmmmmmmmmmaa" + /* 4 */ "mmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmbbbmmmmmm" + /* 9 */ "mmmmmmaaammmmmm" + /* 10 */ "mmmmmmaaammmmmm" + /* 11 */ "mmmmmmaaammmmmm" + + // Level 2 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "aammmmmmmmmmmaa" + /* 2 */ "aammmmmmmmmmmaa" + /* 3 */ "aammmmmmmmmmmaa" + /* 4 */ "mmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmcbbbdmmmmm" + /* 8 */ "mmmmmcaaadmmmmm" + /* 9 */ "mmmmmcaaadmmmmm" + /* 10 */ "mmmmmcaaadmmmmm" + /* 11 */ "mmmmmcaaadmmmmm" + + // Level 3 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "aammmmmmmmmmmaa" + /* 2 */ "aammmmmmmmmmmaa" + /* 3 */ "aammmmmmmmmmmaa" + /* 4 */ "mmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmaaaaammmmm" + /* 8 */ "mmmmmaaaaammmmm" + /* 9 */ "mmmmmaaaaammmmm" + /* 10 */ "mmmmmaaaaammmmm" + /* 11 */ "mmmmmaaaaammmmm" + + // Level 4 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "aammmmmmmmmmmaa" + /* 2 */ "aammmmmmmmmmmaa" + /* 3 */ "aammmmmmmmmmmaa" + /* 4 */ "mmmmmmmmmmmmmmm" + /* 5 */ "mmmmmmmmmmmmmmm" + /* 6 */ "mmmmcbbbbbdmmmm" + /* 7 */ "mmmmaaaaaaammmm" + /* 8 */ "mmmma.....ammmm" + /* 9 */ "mmmmaa...aammmm" + /* 10 */ "mmmmma...ammmmm" + /* 11 */ "mmmmma...ammmmm" + + // Level 5 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "aadmmmmmmmmmcaa" + /* 2 */ "aadmmmmmmmmmcaa" + /* 3 */ "aadmmmmmmmmmcaa" + /* 4 */ "mmmmmmmmmmmmmmm" + /* 5 */ "mmmcbbbbbbbdmmm" + /* 6 */ "mmmaaaaaaaaaamm" + /* 7 */ "mmma.......ammm" + /* 8 */ "mmmaa.....aammm" + /* 9 */ "mmmmam...mammmm" + /* 10 */ "mmmmmm...mmmmmm" + /* 11 */ "mmmmmm...mmmmmm" + + // Level 6 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "aaademmmmmecaaa" + /* 2 */ "aaademmmmmecaaa" + /* 3 */ "aaademmmmmecaaa" + /* 4 */ "mmaaabbbbbaaaam" + /* 5 */ "mmaaaaaaaaaaaam" + /* 6 */ "mma.........amm" + /* 7 */ "mmaa.......aamm" + /* 8 */ "mmmam.....mammm" + /* 9 */ "mmmmmm...mmmmmm" + /* 10 */ "mmmmmm...mmmmmm" + /* 11 */ "mmmmmm...mmmmmm" + + // Level 7 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "bbbbbbbbbbbbbbb" + /* 1 */ "aaaaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaaaa" + /* 4 */ "faaaaaaaaaaaaaa" + /* 5 */ "ma...........am" + /* 6 */ "maa.........aam" + /* 7 */ "mmam.......mamm" + /* 8 */ "mmmmm.....mmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmm" + + // Level 8 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "aaaaaaaaaaaaaaa" + /* 1 */ "aaaaaaaaaaaaaaa" + /* 2 */ "aaaaaaaaaaaaaaa" + /* 3 */ "aaaaaaaaaaaaaaa" + /* 4 */ "a.............a" + /* 5 */ "aa...........aa" + /* 6 */ "mam.........mam" + /* 7 */ "mmmm.......mmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmm" + + // Level 9 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "aaaaaaaaaaaaaaa" + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "a.............a" + /* 5 */ "am............a" + /* 6 */ "mmm.........mmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmm" + + // Level 10 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "m.............m" + /* 5 */ "mm............m" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmm" + + // Level 11 + /* z\x* 11111 */ + /* * 012345678901234 */ + /* 0 */ "mmmmmmmmmmmmmmm" + /* 1 */ "..............." + /* 2 */ "..............." + /* 3 */ "..............." + /* 4 */ "m.............m" + /* 5 */ "mmmmmmmmmmmmmmm" + /* 6 */ "mmmmmmmmmmmmmmm" + /* 7 */ "mmmmmmmmmmmmmmm" + /* 8 */ "mmmmmmmmmmmmmmm" + /* 9 */ "mmmmmmmmmmmmmmm" + /* 10 */ "mmmmmmmmmmmmmmm" + /* 11 */ "mmmmmmmmmmmmmmm", + + // Connectors: + "0: 7, 4, 11: 3\n" /* Type 0, direction Z+ */ + "0: 0, 9, 2: 4\n" /* Type 0, direction X- */ + "0: 14, 9, 2: 5\n" /* Type 0, direction X+ */, + + // AllowedRotations: + 7, /* 1, 2, 3 CCW rotation allowed */ + + // Merge strategy: + cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 5, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, + }, // BridgeFunnelDown + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // BridgeLevelCrossing: // The data has been exported from the gallery Nether, area index 45, ID 304, created by Aloe_vera @@ -1514,10 +1858,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "", // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // BridgeLevelCrossing @@ -1617,10 +1973,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "0: 14, 5, 2: 5\n" /* Type 0, direction X+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 500, + + // DepthWeight: + "", + + // AddWeightIfSame: + 1000, }, // BridgeSegment @@ -1761,10 +2129,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "0: 14, 5, 2: 5\n" /* Type 0, direction X+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 10, + + // DepthWeight: + "1:500", + + // AddWeightIfSame: + 0, }, // BridgeTee @@ -1844,10 +2224,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 0, 1, 2: 4\n" /* Type 1, direction X- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 200, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // Corridor11 @@ -1927,10 +2319,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 0, 1, 2: 4\n" /* Type 1, direction X- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 200, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // Corridor13 @@ -2048,10 +2452,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 10, 1, 2: 5\n" /* Type 1, direction X+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // CorridorCorner5 @@ -2170,10 +2586,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 2, 1, 10: 3\n" /* Type 1, direction Z+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // CorridorCornerChest5 @@ -2304,10 +2732,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 8, 8, 2: 5\n" /* Type 1, direction X+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // CorridorStairs @@ -2367,11 +2807,11 @@ const cPrefab::sDef g_NetherFortPrefabs[] = // Level 4 /* z\x* 1111 */ /* * 01234567890123 */ - /* 0 */ "aaaaaaaaaaaaaa" + /* 0 */ "aabaaaaaaaabaa" /* 1 */ ".............." /* 2 */ ".............." /* 3 */ ".............." - /* 4 */ "aaaaaaaaaaaaaa" + /* 4 */ "aabaaaaaaaabaa" // Level 5 /* z\x* 1111 */ @@ -2387,10 +2827,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 13, 1, 2: 5\n" /* Type 1, direction X+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // DarkCorridor @@ -2625,10 +3077,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 9, 1, 0: 2\n" /* Type 1, direction Z- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // LavaStaircase @@ -2938,10 +3402,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 0, 9, 7: 4\n" /* Type 1, direction X- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // LavaStaircaseBig @@ -3200,10 +3676,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "", // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // LavaStairsBridge @@ -3370,10 +3858,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 0, 1, 6: 4\n" /* Type 1, direction X- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // MidStaircase @@ -3497,10 +3997,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "0: 3, 1, 0: 2\n" /* Type 0, direction Z- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // StairsToOpen1 @@ -3624,10 +4136,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "0: 3, 1, 0: 2\n" /* Type 0, direction Z- */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // StairsToOpen2 @@ -3722,10 +4246,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 12, 1, 4: 5\n" /* Type 1, direction X+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // Tee2x4 @@ -3832,10 +4368,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "1: 12, 1, 6: 5\n" /* Type 1, direction X+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // Tee4x4 @@ -3921,10 +4469,22 @@ const cPrefab::sDef g_NetherFortPrefabs[] = "0: 3, 1, 6: 3\n" /* Type 0, direction Z+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + -99, }, // Turret }; // g_NetherFortPrefabs @@ -4108,10 +4668,22 @@ const cPrefab::sDef g_NetherFortStartingPrefabs[] = "1: 6, 1, 12: 3\n" /* Type 1, direction Z+ */, // AllowedRotations: - 7, /* 1, 2, 3 CCW rotations */ + 7, /* 1, 2, 3 CCW rotation allowed */ // Merge strategy: cBlockArea::msSpongePrint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 100, + + // DepthWeight: + "", + + // AddWeightIfSame: + 0, }, // CentralRoom }; -- cgit v1.2.3 From afb20132fe966efa1b90ee9497b6881a5b8df25c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Apr 2014 17:50:52 +0200 Subject: Added Prefab initializers to SELFTEST code. --- src/Generating/Prefab.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/Generating') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index b1964e2a0..69bea69e8 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -91,7 +91,19 @@ static const cPrefab::sDef g_TestPrefabDef = 7, /* 1, 2, 3 CCW rotations */ // Merge strategy: - cBlockArea::msImprint + cBlockArea::msImprint, + + // ShouldExtendFloor: + false, + + // DefaultWeight: + 10, + + // DepthWeight: + "", + + // AddWeightIfSame: + 1000, }; static cPrefab g_TestPrefab(g_TestPrefabDef); -- cgit v1.2.3 From 6779010242bbdda5582706f93baaef1f288d5742 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Apr 2014 22:03:13 +0200 Subject: Added area flooring. Fixes #743. --- src/Generating/Prefab.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'src/Generating') diff --git a/src/Generating/Prefab.cpp b/src/Generating/Prefab.cpp index 69bea69e8..7d1762036 100644 --- a/src/Generating/Prefab.cpp +++ b/src/Generating/Prefab.cpp @@ -158,12 +158,53 @@ cPrefab::cPrefab(const cPrefab::sDef & a_Def) : void cPrefab::Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const { + // Draw the basic image: Vector3i Placement = a_Placement->GetCoords(); int ChunkStartX = a_Dest.GetChunkX() * cChunkDef::Width; int ChunkStartZ = a_Dest.GetChunkZ() * cChunkDef::Width; Placement.Move(-ChunkStartX, 0, -ChunkStartZ); - a_Dest.WriteBlockArea(m_BlockArea[a_Placement->GetNumCCWRotations()], Placement.x, Placement.y, Placement.z, m_MergeStrategy); + const cBlockArea & Image = m_BlockArea[a_Placement->GetNumCCWRotations()]; + a_Dest.WriteBlockArea(Image, Placement.x, Placement.y, Placement.z, m_MergeStrategy); + // If requested, draw the floor (from the bottom of the prefab down to the nearest non-air) + int MaxX = Image.GetSizeX(); + int MaxZ = Image.GetSizeZ(); + for (int z = 0; z < MaxZ; z++) + { + int RelZ = Placement.z + z; + if ((RelZ < 0) || (RelZ >= cChunkDef::Width)) + { + // Z coord outside the chunk + continue; + } + for (int x = 0; x < MaxX; x++) + { + int RelX = Placement.x + x; + if ((RelX < 0) || (RelX >= cChunkDef::Width)) + { + // X coord outside the chunk + continue; + } + BLOCKTYPE BlockType; + NIBBLETYPE BlockMeta; + Image.GetRelBlockTypeMeta(x, 0, z, BlockType, BlockMeta); + if ((BlockType == E_BLOCK_AIR) || (BlockType == E_BLOCK_SPONGE)) + { + // Do not expand air nor sponge blocks + continue; + } + for (int y = Placement.y - 1; y >= 0; y--) + { + BLOCKTYPE ExistingBlock = a_Dest.GetBlockType(RelX, y, RelZ); + if (ExistingBlock != E_BLOCK_AIR) + { + // End the expansion for this column, reached the end + break; + } + a_Dest.SetBlockTypeMeta(RelX, y, RelZ, BlockType, BlockMeta); + } // for y + } // for x + } // for z } -- cgit v1.2.3 From 6d3bde52216020c59c7f1851d090bae1d1954f39 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Apr 2014 14:35:33 +0200 Subject: Added performance test of the nether fort generator. --- src/Generating/NetherFortGen.cpp | 34 ++++++++++++++++++++++++++++++++++ src/Generating/NetherFortGen.h | 1 + 2 files changed, 35 insertions(+) (limited to 'src/Generating') diff --git a/src/Generating/NetherFortGen.cpp b/src/Generating/NetherFortGen.cpp index 7dc702e3a..d90fdeb0a 100644 --- a/src/Generating/NetherFortGen.cpp +++ b/src/Generating/NetherFortGen.cpp @@ -70,6 +70,40 @@ public: +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Performance test of the NetherFort generator: + +/* +#include "OSSupport/Timer.h" +static class cNetherFortPerfTest +{ +public: + cNetherFortPerfTest(void) + { + cTimer Timer; + long long StartTime = Timer.GetNowTime(); + + const int GridSize = 512; + const int MaxDepth = 12; + const int NumIterations = 100; + for (int i = 0; i < NumIterations; i++) + { + cNetherFortGen FortGen(i, GridSize, MaxDepth); + delete new cNetherFortGen::cNetherFort(FortGen, 0, 0, GridSize, MaxDepth, i); + } + + long long EndTime = Timer.GetNowTime(); + printf("%d forts took %lld msec (%f sec) to generate\n", NumIterations, EndTime - StartTime, ((double)(EndTime - StartTime)) / 1000); + exit(0); + } + +} g_PerfTest; +//*/ + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cNetherFortGen: diff --git a/src/Generating/NetherFortGen.h b/src/Generating/NetherFortGen.h index b82b6adf3..d51596b9e 100644 --- a/src/Generating/NetherFortGen.h +++ b/src/Generating/NetherFortGen.h @@ -26,6 +26,7 @@ public: virtual ~cNetherFortGen(); protected: + friend class cNetherFortPerfTest; // fwd: NetherFortGen.cpp class cNetherFort; // fwd: NetherFortGen.cpp typedef std::list cNetherForts; -- cgit v1.2.3