Search in sources :

Example 6 with ITerrainOctreeProvider

use of org.valkyrienskies.mod.common.util.datastructures.ITerrainOctreeProvider 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;
}
Also used : ITerrainOctreeProvider(org.valkyrienskies.mod.common.util.datastructures.ITerrainOctreeProvider) IBitOctree(org.valkyrienskies.mod.common.util.datastructures.IBitOctree)

Aggregations

IBitOctree (org.valkyrienskies.mod.common.util.datastructures.IBitOctree)6 ITerrainOctreeProvider (org.valkyrienskies.mod.common.util.datastructures.ITerrainOctreeProvider)6 Chunk (net.minecraft.world.chunk.Chunk)4 ExtendedBlockStorage (net.minecraft.world.chunk.storage.ExtendedBlockStorage)4 Vector3d (org.joml.Vector3d)3 Vector3dc (org.joml.Vector3dc)2 ShipTransform (org.valkyrienskies.mod.common.ships.ship_transform.ShipTransform)2 IBlockState (net.minecraft.block.state.IBlockState)1 BlockPos (net.minecraft.util.math.BlockPos)1 PhysicsCalculations (org.valkyrienskies.mod.common.physics.PhysicsCalculations)1