public virtual void HandleCollisions(bool queryNeighborHood, VoxelHandle[] neighborHood, ChunkManager chunks, float dt) { if (CollideMode == CollisionMode.None) { return; } int y = (int)Position.Y; if (CurrentVoxel.IsValid && !CurrentVoxel.IsEmpty) { var currentBox = CurrentVoxel.GetBoundingBox(); if (currentBox.Contains(Position) == ContainmentType.Contains) { ResolveTerrainCollisionGradientMethod(); OnTerrainCollision(CurrentVoxel); return; } } if (queryNeighborHood) { int i = 0; foreach (var v in VoxelHelpers.EnumerateManhattanCube(CurrentVoxel.Coordinate).Select(c => new VoxelHandle(chunks, c))) { neighborHood[i] = v; i++; } } foreach (var v in neighborHood) { if (!v.IsValid || v.IsEmpty) { continue; } if (CollideMode == CollisionMode.UpDown && (int)v.Coordinate.Y == y) { continue; } if (CollideMode == CollisionMode.Sides && (int)v.Coordinate.Y != y) { continue; } if (Collide(v.GetBoundingBox(), dt)) { OnTerrainCollision(v); } } }