Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -23,10 +23,7 @@ import com.comphenix.tinyprotocol.Reflection;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class BlockIdWrapper18 extends BlockIdWrapper14 {
|
public class BlockIdWrapper18 extends BlockIdWrapper14 {
|
||||||
|
|
||||||
@@ -39,7 +36,7 @@ public class BlockIdWrapper18 extends BlockIdWrapper14 {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void untrackEntity(Player player, Entity entity) {
|
public void untrackEntity(Player player, Entity entity) {
|
||||||
hiddenEntities.get(player).put(entity.getUniqueId(), Collections.emptySet());
|
hiddenEntities.get(player).put(entity.getUniqueId(), new HashSet<>(1));
|
||||||
super.untrackEntity(player, entity);
|
super.untrackEntity(player, entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,11 +47,11 @@ public class Hull {
|
|||||||
private final Region region;
|
private final Region region;
|
||||||
private final boolean groundVisible;
|
private final boolean groundVisible;
|
||||||
private final IntVector primaryDirection;
|
private final IntVector primaryDirection;
|
||||||
|
private final IntVector[] directions;
|
||||||
private final IntVector[] branchDirections;
|
private final IntVector[] branchDirections;
|
||||||
|
|
||||||
private final BitSet occluding;
|
private final BitSet occluding;
|
||||||
private final BitSet visibility;
|
private final BitSet visibility;
|
||||||
private final BitSet primaryVisible;
|
|
||||||
private final Int2IntOpenHashMap visibilityDirections = new Int2IntOpenHashMap(); // Contains the visible directions of each occluding visible block
|
private final Int2IntOpenHashMap visibilityDirections = new Int2IntOpenHashMap(); // Contains the visible directions of each occluding visible block
|
||||||
private final Set<IntVector> uncoveredSurface = new HashSet<>();
|
private final Set<IntVector> uncoveredSurface = new HashSet<>();
|
||||||
|
|
||||||
@@ -65,12 +65,15 @@ public class Hull {
|
|||||||
this.primaryDirection = new IntVector(0, 0, team.isBlue() == (Config.BlueToRedZ > 0) ? -1 : 1);
|
this.primaryDirection = new IntVector(0, 0, team.isBlue() == (Config.BlueToRedZ > 0) ? -1 : 1);
|
||||||
this.occluding = new BitSet(region.volume());
|
this.occluding = new BitSet(region.volume());
|
||||||
this.visibility = new BitSet(region.volume());
|
this.visibility = new BitSet(region.volume());
|
||||||
this.primaryVisible = new BitSet(region.volume());
|
|
||||||
|
|
||||||
branchDirections = IntStream.range(0, 27)
|
directions = IntStream.range(0, 27)
|
||||||
.mapToObj(v -> new IntVector(v%3 -1, (v/3)%3 -1, v/9 -1))
|
.mapToObj(v -> new IntVector(v%3 -1, (v/3)%3 -1, v/9 -1))
|
||||||
|
.filter(v -> v.sqLength() > 0)
|
||||||
|
.filter(v -> v.sqLength() <= 2)
|
||||||
|
.toArray(IntVector[]::new);
|
||||||
|
branchDirections = Arrays.stream(directions)
|
||||||
.filter(v -> v.x*primaryDirection.x + v.y*primaryDirection.y + v.z*primaryDirection.z >= 0) // Not pointing away from primary direction
|
.filter(v -> v.x*primaryDirection.x + v.y*primaryDirection.y + v.z*primaryDirection.z >= 0) // Not pointing away from primary direction
|
||||||
.filter(v -> v.x*v.x + v.y*v.y + v.z*v.z == 2) // Diagonal
|
.filter(v -> v.sqLength() == 2) // Diagonal
|
||||||
.toArray(IntVector[]::new);
|
.toArray(IntVector[]::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +142,6 @@ public class Hull {
|
|||||||
visibility.clear();
|
visibility.clear();
|
||||||
occluding.clear();
|
occluding.clear();
|
||||||
visibilityDirections.clear();
|
visibilityDirections.clear();
|
||||||
primaryVisible.clear();
|
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
region.forEach((x, y, z) -> {
|
region.forEach((x, y, z) -> {
|
||||||
@@ -165,9 +167,9 @@ public class Hull {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
List<IntVector> uncovered = new ArrayList<>();
|
List<IntVector> uncovered = new ArrayList<>();
|
||||||
int directions = visibilityDirections.remove(id);
|
int visibleDirections = visibilityDirections.remove(id);
|
||||||
for(IntVector direction : branchDirections) {
|
for(IntVector direction : directions) {
|
||||||
if((directionId(direction) & directions) != 0)
|
if((directionId(direction) & visibleDirections) != 0)
|
||||||
updateBlocks(uncovered, root, direction);
|
updateBlocks(uncovered, root, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,14 +255,11 @@ public class Hull {
|
|||||||
visibilityDirections.compute(id, (pos, v) -> (v == null ? 0 : v) | directionId(direction));
|
visibilityDirections.compute(id, (pos, v) -> (v == null ? 0 : v) | directionId(direction));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(primaryVisible.get(id))
|
|
||||||
return;
|
|
||||||
|
|
||||||
updateBlocks(uncovered, block.add(direction), direction);
|
updateBlocks(uncovered, block.add(direction), direction);
|
||||||
if(!direction.equals(primaryDirection))
|
if(!direction.equals(primaryDirection))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
primaryVisible.set(id);
|
|
||||||
for(IntVector branchDirection : branchDirections)
|
for(IntVector branchDirection : branchDirections)
|
||||||
updateBlocks(uncovered, block.add(branchDirection), branchDirection);
|
updateBlocks(uncovered, block.add(branchDirection), branchDirection);
|
||||||
}
|
}
|
||||||
@@ -299,6 +298,10 @@ public class Hull {
|
|||||||
return add(v.x, v.y, v.z);
|
return add(v.x, v.y, v.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int sqLength() {
|
||||||
|
return x*x + y*y + z*z;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return y << 24 ^ x << 12 ^ z;
|
return y << 24 ^ x << 12 ^ z;
|
||||||
|
|||||||
Reference in New Issue
Block a user