use of org.valkyrienskies.mod.common.util.datastructures.IBitOctree in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class WorldWaterCollider method updateCollisionCacheSequential.
private void updateCollisionCacheSequential(ChunkCache cache, int chunkX, int chunkZ, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, AxisAlignedBB shipBB, TIntList output) {
int arrayChunkX = chunkX - cache.chunkX;
int arrayChunkZ = chunkZ - cache.chunkZ;
if (!(arrayChunkX < 0 || arrayChunkZ < 0 || arrayChunkX > cache.chunkArray.length - 1 || arrayChunkZ > cache.chunkArray[0].length - 1) && cache.chunkArray[arrayChunkX][arrayChunkZ] != null) {
final Vector3d temp1 = new Vector3d();
final Vector3d temp2 = new Vector3d();
Chunk chunk = cache.chunkArray[arrayChunkX][arrayChunkZ];
for (int storageY = minY >> 4; storageY <= maxY >> 4; storageY++) {
ExtendedBlockStorage extendedblockstorage = chunk.storageArrays[storageY];
if (extendedblockstorage != null) {
int minStorageX = chunkX << 4;
int minStorageY = storageY << 4;
int minStorageZ = chunkZ << 4;
int maxStorageX = minStorageX + 15;
int maxStorageY = Math.min(maxY, minStorageY + 15);
int maxStorageZ = minStorageZ + 15;
ITerrainOctreeProvider provider = (ITerrainOctreeProvider) extendedblockstorage.data;
IBitOctree octree = provider.getLiquidOctree();
for (int x = minStorageX; x <= maxStorageX; x++) {
for (int y = minStorageY; y <= maxStorageY; y++) {
for (int z = minStorageZ; z <= maxStorageZ; z++) {
checkIfCollidesWithinRangeCheckRadius(x, y, z, octree, temp1, temp2, shipBB, output);
}
}
}
}
}
}
}
use of org.valkyrienskies.mod.common.util.datastructures.IBitOctree in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class WorldWaterCollider method checkForCollisionFast.
private boolean checkForCollisionFast(final Chunk chunk, final int localX, final int localY, final int localZ, final int x, final int y, final int z, final TIntList output) {
if (chunk.storageArrays[localY >> 4] != null) {
ITerrainOctreeProvider provider = (ITerrainOctreeProvider) chunk.storageArrays[localY >> 4].getData();
IBitOctree octreeInLocal = provider.getSolidOctree();
if (octreeInLocal.get(localX & 15, localY & 15, localZ & 15)) {
int hash = SpatialDetector.getHashWithRespectTo(x, y, z, centerPotentialHit);
// Sometimes we end up adding to the hits array in multiple threads at once,
// crashing the physics.
output.add(hash);
return true;
}
}
return false;
}
Aggregations