1
0

cBlockArea: Added the msMask merge strategy.

This commit is contained in:
madmaxoft 2014-04-01 20:50:10 +02:00
parent 0d916a3e2f
commit 1229795ff0
3 changed files with 59 additions and 3 deletions

View File

@ -200,6 +200,8 @@ g_APIDesc =
msFillAir = { Notes = "Dst is overwritten by Src only where Src has air blocks" },
msImprint = { Notes = "Src overwrites Dst anywhere where Dst has non-air blocks" },
msLake = { Notes = "Special mode for merging lake images" },
msSpongePrint = { Notes = "Similar to msImprint, sponge block doesn't overwrite anything, all other blocks overwrite everything"},
msMask = { Notes = "The blocks that are exactly the same are kept in Dst, all differing blocks are replaced by air"},
},
ConstantGroups =
{
@ -293,7 +295,6 @@ g_APIDesc =
</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
@ -306,10 +307,26 @@ g_APIDesc =
</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>
<td> * </td><td> B </td><td> B </td><td> Everything else overwrites anything </td>
</tr>
</tbody></table>
]],
<p>
<strong>msMask</strong> - the blocks that are the same in the other area are kept, all the
differing blocks are replaced with air. Meta is used in the comparison, too, two blocks of the
same type but different meta are considered different and thus replaced with air.
</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> A </td><td> A </td><td> Same blocks are kept </td>
</tr><tr>
<td> A </td><td> non-A </td><td> air </td><td> Differing blocks are replaced with air </td>
</tr>
</tbody></table>
]],
}, -- Merge strategies
}, -- AdditionalInfo
}, -- cBlockArea

View File

@ -173,6 +173,21 @@ static inline void MergeCombinatorSpongePrint(BLOCKTYPE & a_DstType, BLOCKTYPE a
/** Combinator used for cBlockArea::msMask merging */
static inline void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
{
// If the blocks are the same, keep the dest; otherwise replace with air
if ((a_SrcType != a_DstType) || (a_SrcMeta != a_DstMeta))
{
a_DstType = E_BLOCK_AIR;
a_DstMeta = 0;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cBlockArea:
@ -710,6 +725,21 @@ void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_R
break;
} // case msSpongePrint
case msMask:
{
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,
MergeCombinatorMask
);
break;
} // case msMask
default:
{
LOGWARNING("Unknown block area merge strategy: %d", a_Strategy);

View File

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