diff --git a/TrueCraft.Client/Modules/HighlightModule.cs b/TrueCraft.Client/Modules/HighlightModule.cs index fd750e7..ff02e84 100644 --- a/TrueCraft.Client/Modules/HighlightModule.cs +++ b/TrueCraft.Client/Modules/HighlightModule.cs @@ -56,7 +56,7 @@ namespace TrueCraft.Client.Modules var cast = VoxelCast.Cast(Game.Client.World, new TRay(Game.Camera.Position, new TVector3(direction.X, direction.Y, direction.Z)), - Game.BlockRepository, (int)TrueCraftGame.Reach); + Game.BlockRepository, TrueCraftGame.Reach, TrueCraftGame.Reach + 2); if (cast == null) HighlightedBlock = -Coordinates3D.One; diff --git a/TrueCraft.Client/TrueCraftGame.cs b/TrueCraft.Client/TrueCraftGame.cs index b631709..e8a827c 100644 --- a/TrueCraft.Client/TrueCraftGame.cs +++ b/TrueCraft.Client/TrueCraftGame.cs @@ -46,7 +46,7 @@ namespace TrueCraft.Client private GameTime GameTime { get; set; } private DebugInfoModule DebugInfoModule { get; set; } - public static readonly double Reach = 3; + public static readonly int Reach = 3; public IBlockRepository BlockRepository { diff --git a/TrueCraft.Client/VoxelCast.cs b/TrueCraft.Client/VoxelCast.cs index 9fdb467..ae5279b 100644 --- a/TrueCraft.Client/VoxelCast.cs +++ b/TrueCraft.Client/VoxelCast.cs @@ -15,17 +15,17 @@ namespace TrueCraft.Client // Thanks to http://gamedev.stackexchange.com/questions/47362/cast-ray-to-select-block-in-voxel-game public static Tuple Cast(ReadOnlyWorld world, - Ray ray, IBlockRepository repository, int max) + Ray ray, IBlockRepository repository, int posmax, int negmax) { // TODO: There are more efficient ways of doing this, fwiw - double min = max * 2; + double min = negmax * 2; var pick = -Coordinates3D.One; - for (int x = -max; x <= max; x++) + for (int x = -posmax; x <= posmax; x++) { - for (int y = -max; y <= max; y++) + for (int y = -negmax; y <= posmax; y++) { - for (int z = -max; z <= max; z++) + for (int z = -posmax; z <= posmax; z++) { var coords = (Coordinates3D)(new Vector3(x, y, z) + ray.Position).Round(); if (!world.IsValidPosition(coords))