Added cBlockArea::msSimpleCompare merge strategy.
This commit is contained in:
parent
fc95501f68
commit
ca90f6d280
@ -197,13 +197,14 @@ g_APIDesc =
|
||||
baMetas = { Notes = "Operations should work on block metas" },
|
||||
baLight = { Notes = "Operations should work on block (emissive) light" },
|
||||
baSkyLight = { Notes = "Operations should work on skylight" },
|
||||
msDifference = { Notes = "Block becomes air if Src and Dst are the same. Otherwise it becomes the source block." },
|
||||
msOverwrite = { Notes = "Src overwrites anything in Dst" },
|
||||
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" },
|
||||
msDifference = { Notes = "Block becomes air if 'self' and src are the same. Otherwise it becomes the src block." },
|
||||
msFillAir = { Notes = "'self' is overwritten by Src only where 'self' has air blocks" },
|
||||
msImprint = { Notes = "Src overwrites 'self' anywhere where 'self' has non-air blocks" },
|
||||
msLake = { Notes = "Special mode for merging lake images" },
|
||||
msMask = { Notes = "The blocks that are exactly the same are kept in 'self', all differing blocks are replaced by air"},
|
||||
msOverwrite = { Notes = "Src overwrites anything in 'self'" },
|
||||
msSimpleCompare = { Notes = "The blocks that are exactly the same are replaced with air, all differing blocks are replaced by stone"},
|
||||
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 =
|
||||
{
|
||||
@ -287,7 +288,7 @@ g_APIDesc =
|
||||
<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>
|
||||
<th> self </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>
|
||||
@ -321,7 +322,7 @@ g_APIDesc =
|
||||
<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>
|
||||
<th> self </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>
|
||||
@ -337,13 +338,45 @@ g_APIDesc =
|
||||
<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>
|
||||
<th> self </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>
|
||||
|
||||
<p>
|
||||
<strong>msDifference</strong> - the blocks that are the same in both areas are replaced with air, all the
|
||||
differing blocks are kept from the first area. Meta is used in the comparison, too, two blocks of the
|
||||
same type but different meta are considered different.
|
||||
</p>
|
||||
<table><tbody><tr>
|
||||
<th colspan="2"> area block </th><th> </th><th> Notes </th>
|
||||
</tr><tr>
|
||||
<th> self </th><th> Src </th><th> result </th><th> </th>
|
||||
</tr><tr>
|
||||
<td> A </td><td> A </td><td> air </td><td> Same blocks are replaced with air </td>
|
||||
</tr><tr>
|
||||
<td> A </td><td> non-A </td><td> A </td><td> Differing blocks are kept from 'self' </td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
||||
<p>
|
||||
<strong>msSimpleCompare</strong> - the blocks that are the same in both areas are replaced with air, all the
|
||||
differing blocks are replaced with stone. Meta is used in the comparison, too, two blocks of the
|
||||
same type but different meta are considered different.
|
||||
</p>
|
||||
<table><tbody><tr>
|
||||
<th colspan="2"> area block </th><th> </th><th> Notes </th>
|
||||
</tr><tr>
|
||||
<th> self </th><th> Src </th><th> result </th><th> </th>
|
||||
</tr><tr>
|
||||
<td> A </td><td> A </td><td> air </td><td> Same blocks are replaced with air </td>
|
||||
</tr><tr>
|
||||
<td> A </td><td> non-A </td><td> stone </td><td> Differing blocks are replaced with stone </td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
]],
|
||||
}, -- Merge strategies
|
||||
}, -- AdditionalInfo
|
||||
|
@ -245,6 +245,26 @@ void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBL
|
||||
|
||||
|
||||
|
||||
/** Combinator used for cBlockArea::msSimpleCompare merging */
|
||||
template <bool MetaValid>
|
||||
void MergeCombinatorSimpleCompare(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
|
||||
{
|
||||
if ((a_DstType == a_SrcType) && (!MetaValid || (a_DstMeta == a_SrcMeta)))
|
||||
{
|
||||
// The blocktypes are the same, and the blockmetas are not present or are the same
|
||||
a_DstType = E_BLOCK_AIR;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The blocktypes or blockmetas differ
|
||||
a_DstType = E_BLOCK_STONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Combinator used for cBlockArea::msMask merging */
|
||||
template <bool MetaValid>
|
||||
void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta)
|
||||
@ -2188,10 +2208,12 @@ void cBlockArea::RelSetData(
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <bool MetasValid>
|
||||
void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas)
|
||||
{
|
||||
// Block types are compulsory, block metas are voluntary
|
||||
// Block types are compulsory, block metas are optional
|
||||
if (!HasBlockTypes() || !a_Src.HasBlockTypes())
|
||||
{
|
||||
LOGWARNING("%s: cannot merge because one of the areas doesn't have blocktypes.", __FUNCTION__);
|
||||
@ -2297,6 +2319,20 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
|
||||
return;
|
||||
} // case msDifference
|
||||
|
||||
case cBlockArea::msSimpleCompare:
|
||||
{
|
||||
InternalMergeBlocks<MetasValid, MergeCombinatorSimpleCompare<MetasValid> >(
|
||||
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
|
||||
);
|
||||
return;
|
||||
} // case msSimpleCompare
|
||||
|
||||
case cBlockArea::msMask:
|
||||
{
|
||||
InternalMergeBlocks<MetasValid, MergeCombinatorMask<MetasValid> >(
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
msLake,
|
||||
msSpongePrint,
|
||||
msDifference,
|
||||
msSimpleCompare,
|
||||
msMask,
|
||||
} ;
|
||||
|
||||
@ -156,6 +157,22 @@ public:
|
||||
| A | sponge | A | Sponge is the NOP block
|
||||
| * | B | B | Everything else overwrites anything
|
||||
|
||||
msDifference:
|
||||
Used to determine the differences between two areas. Only the differring blocks are preserved:
|
||||
| area block | |
|
||||
| this | Src | result |
|
||||
+------+-------+--------+
|
||||
| A | A | air | Same blocks are replaced with air
|
||||
| A | non-A | A | Differring blocks are kept from "this"
|
||||
|
||||
msSimpleCompare:
|
||||
Used to determine the differences between two areas. Blocks that differ are replaced with stone, same blocks are replaced with air
|
||||
| area block | |
|
||||
| this | Src | result |
|
||||
+------+-------+--------+
|
||||
| A | A | air | Same blocks are replaced with air
|
||||
| A | non-A | stone | Differring blocks are replaced with stone
|
||||
|
||||
msMask:
|
||||
Combines two areas, the blocks that are the same are kept, differing ones are reset to air
|
||||
| area block | |
|
||||
|
Loading…
Reference in New Issue
Block a user