mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Fix mask optimize
This commit is contained in:
parent
69e1c53076
commit
2670e66ce2
@ -1118,7 +1118,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||||
new BoundedHeightMask(
|
new BoundedHeightMask(
|
||||||
Math.max(origin.getBlockY() - depth + 1, getMinimumPoint().getBlockY()),
|
Math.max(origin.getBlockY() - depth + 1, getMinimumPoint().getBlockY()),
|
||||||
Math.min(getMaximumPoint().getBlockY(), origin.getBlockY())),
|
Math.min(getMaxY(), origin.getBlockY())),
|
||||||
Masks.negate(new ExistingBlockMask(this)));
|
Masks.negate(new ExistingBlockMask(this)));
|
||||||
|
|
||||||
// Want to replace blocks
|
// Want to replace blocks
|
||||||
|
@ -180,12 +180,22 @@ public class BlockMask extends ABlockMask {
|
|||||||
public Mask tryCombine(Mask mask) {
|
public Mask tryCombine(Mask mask) {
|
||||||
if (mask instanceof ABlockMask) {
|
if (mask instanceof ABlockMask) {
|
||||||
ABlockMask other = (ABlockMask) mask;
|
ABlockMask other = (ABlockMask) mask;
|
||||||
|
boolean modified = false;
|
||||||
|
boolean hasAny = false;
|
||||||
for (int i = 0; i < ordinals.length; i++) {
|
for (int i = 0; i < ordinals.length; i++) {
|
||||||
if (ordinals[i]) {
|
if (ordinals[i]) {
|
||||||
ordinals[i] = other.test(BlockState.getFromOrdinal(i));
|
boolean result = other.test(BlockState.getFromOrdinal(i));
|
||||||
|
hasAny |= result;
|
||||||
|
modified |= !result;
|
||||||
|
ordinals[i] = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
if (modified) {
|
||||||
|
if (!hasAny) {
|
||||||
|
return Masks.alwaysFalse();
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -194,12 +204,17 @@ public class BlockMask extends ABlockMask {
|
|||||||
public Mask tryOr(Mask mask) {
|
public Mask tryOr(Mask mask) {
|
||||||
if (mask instanceof ABlockMask) {
|
if (mask instanceof ABlockMask) {
|
||||||
ABlockMask other = (ABlockMask) mask;
|
ABlockMask other = (ABlockMask) mask;
|
||||||
|
boolean modified = false;
|
||||||
for (int i = 0; i < ordinals.length; i++) {
|
for (int i = 0; i < ordinals.length; i++) {
|
||||||
if (!ordinals[i]) {
|
if (!ordinals[i]) {
|
||||||
ordinals[i] = other.test(BlockState.getFromOrdinal(i));
|
boolean result = other.test(BlockState.getFromOrdinal(i));
|
||||||
|
modified |= result;
|
||||||
|
ordinals[i] = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
if (modified) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -144,10 +144,10 @@ public class MaskIntersection extends AbstractMask {
|
|||||||
Set<Map.Entry<Mask, Mask>> failedCombines = new HashSet<>();
|
Set<Map.Entry<Mask, Mask>> failedCombines = new HashSet<>();
|
||||||
// Combine the masks
|
// Combine the masks
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
while (changed |= combineMasks(pairingFunction(), failedCombines));
|
while (combineMasks(pairingFunction(), failedCombines)) changed = true;
|
||||||
// Optimize / combine
|
// Optimize / combine
|
||||||
do changed |= optimizeMasks(optimized);
|
do changed |= optimizeMasks(optimized);
|
||||||
while (changed |= combineMasks(pairingFunction(), failedCombines) && --maxIteration > 0);
|
while (combineMasks(pairingFunction(), failedCombines) && --maxIteration > 0);
|
||||||
|
|
||||||
if (maxIteration == 0) {
|
if (maxIteration == 0) {
|
||||||
getLogger(MaskIntersection.class).debug("Failed optimize MaskIntersection");
|
getLogger(MaskIntersection.class).debug("Failed optimize MaskIntersection");
|
||||||
@ -169,6 +169,7 @@ public class MaskIntersection extends AbstractMask {
|
|||||||
outer:
|
outer:
|
||||||
for (Mask mask : masks) {
|
for (Mask mask : masks) {
|
||||||
for (Mask other : masks) {
|
for (Mask other : masks) {
|
||||||
|
if (mask == other) continue;
|
||||||
AbstractMap.SimpleEntry<Mask, Mask> pair = new AbstractMap.SimpleEntry<>(mask, other);
|
AbstractMap.SimpleEntry<Mask, Mask> pair = new AbstractMap.SimpleEntry<>(mask, other);
|
||||||
if (failedCombines.contains(pair)) continue;
|
if (failedCombines.contains(pair)) continue;
|
||||||
Mask combined = pairing.apply(pair);
|
Mask combined = pairing.apply(pair);
|
||||||
|
Loading…
Reference in New Issue
Block a user