1
0

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.
This commit is contained in:
madmaxoft 2014-03-28 18:03:37 +01:00
parent 113343d336
commit 8557549cfa
4 changed files with 68 additions and 13 deletions

View File

@ -258,12 +258,11 @@ g_APIDesc =
</ol>
</p>
<p>
Special strategies:
</p>
<h3>Special strategies</h3>
<p>For each strategy, evaluate the table rows from top downwards, the first match wins.</p>
<p>
<strong>msLake</strong> (evaluate top-down, first match wins):
<strong>msLake</strong> - used for merging areas with lava and water lakes, in the appropriate generator.
</p>
<table><tbody><tr>
<th colspan="2"> area block </th><th> </th><th> Notes </th>
@ -293,6 +292,23 @@ g_APIDesc =
<td> A </td><td> * </td><td> A </td><td> Everything else is left as it is </td>
</tr>
</tbody></table>
<p>
<strong>msSpongePrint</strong> - used for most prefab-generators to merge the prefabs. Similar to
msImprint, but uses the sponge block as the NOP block instead, so that the prefabs may carve out air
pockets, too.
</p>
<table><tbody><tr>
<th colspan="2"> area block </th><th> </th><th> Notes </th>
</tr><tr>
<th> this </th><th> Src </th><th> result </th><th> </th>
</tr><tr>
<td> A </td><td> sponge </td><td> A </td><td> Sponge is the NOP block </td>
</tr><tr>
<td> * </td><td> B </td><td> B </td><td> Everything else overwrites anything </td>
</tr>
</tbody></table>
]],
}, -- Merge strategies
}, -- AdditionalInfo

View File

@ -54,7 +54,7 @@ template<typename Combinator> void InternalMergeBlocks(
/// Combinator used for cBlockArea::msOverwrite merging
static void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
static inline void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
a_DstType = a_SrcType;
a_DstMeta = a_SrcMeta;
@ -65,7 +65,7 @@ static void MergeCombinatorOverwrite(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType,
/// Combinator used for cBlockArea::msFillAir merging
static void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
static inline void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
if (a_DstType == E_BLOCK_AIR)
{
@ -80,7 +80,7 @@ static void MergeCombinatorFillAir(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, N
/// Combinator used for cBlockArea::msImprint merging
static void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
static inline void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
if (a_SrcType != E_BLOCK_AIR)
{
@ -95,7 +95,7 @@ static void MergeCombinatorImprint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, N
/// Combinator used for cBlockArea::msLake merging
static void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
static inline void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
// Sponge is the NOP block
if (a_SrcType == E_BLOCK_SPONGE)
@ -158,6 +158,21 @@ static void MergeCombinatorLake(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBB
/** Combinator used for cBlockArea::msSpongePrint merging */
static inline void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
// Sponge overwrites nothing, everything else overwrites anything
if (a_SrcType != E_BLOCK_SPONGE)
{
a_DstType = a_SrcType;
a_DstMeta = a_SrcMeta;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cBlockArea:
@ -680,6 +695,21 @@ void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_R
break;
} // case msLake
case msSpongePrint:
{
InternalMergeBlocks(
m_BlockTypes, a_Src.GetBlockTypes(),
DstMetas, SrcMetas,
SizeX, SizeY, SizeZ,
SrcOffX, SrcOffY, SrcOffZ,
DstOffX, DstOffY, DstOffZ,
a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
m_Size.x, m_Size.y, m_Size.z,
MergeCombinatorSpongePrint
);
break;
} // case msSpongePrint
default:
{
LOGWARNING("Unknown block area merge strategy: %d", a_Strategy);

View File

@ -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);

View File

@ -127,7 +127,7 @@ const cPrefab::sDef g_NetherFortPrefabs1[] =
7, /* 1, 2, 3 CCW rotations */
// Merge strategy:
cBlockArea::msImprint,
cBlockArea::msSpongePrint,
}, // BalconyCorridor
@ -253,7 +253,7 @@ const cPrefab::sDef g_NetherFortPrefabs1[] =
7, /* 1, 2, 3 CCW rotations */
// Merge strategy:
cBlockArea::msImprint,
cBlockArea::msSpongePrint,
},
} ; // g_NetherFortPrefabs1
@ -421,7 +421,7 @@ const cPrefab::sDef g_NetherFortStartingPrefabs1[] =
7, /* 1, 2, 3 CCW rotations */
// Merge strategy:
cBlockArea::msImprint,
cBlockArea::msSpongePrint,
},
} ; // g_NetherFortStartingPrefabs1