public void SingleHitsTest()
        {
            var maxHits           = 4;
            var rayStart          = new Vector3(0f, 2f, 0f);
            var cubeCommand       = new SpherecastCommand(cubeCollider.transform.position + rayStart, 1f, Vector3.down);
            var meshCubeCommand   = new SpherecastCommand(meshCubeCollider.transform.position + rayStart, 1f, Vector3.down);
            var meshConvexCommand = new SpherecastCommand(meshConvexCollider.transform.position + rayStart, 1f, Vector3.down);
            var emptyCommand      = new SpherecastCommand(new Vector3(30f, 0f, 0f) + rayStart, 1f, Vector3.down);

            var commandsArray = new SpherecastCommand[] { cubeCommand, meshCubeCommand, emptyCommand, meshConvexCommand };

            commands    = new NativeArray <SpherecastCommand>(commandsArray, Allocator.TempJob);
            commandHits = new NativeArray <RaycastHit>(commands.Length * maxHits, Allocator.TempJob);

            raycastAllCommand = new SpherecastAllCommand(commands, commandHits, maxHits);

            raycastAllCommand.Schedule(default(JobHandle)).Complete();

            Assert.AreEqual(cubeCollider, commandHits[maxHits * 0].collider);
            Assert.AreEqual(meshCubeCollider, commandHits[maxHits * 1].collider);
            Assert.AreEqual(null, commandHits[maxHits * 2].collider);

            var physicsHits = new RaycastHit[maxHits];

            for (int i = 0; i < commands.Length; i++)
            {
                var unityHitsCount = Physics.SphereCastNonAlloc(commands[i].origin, commands[i].radius, commands[i].direction, physicsHits);

                for (int j = 0; j < unityHitsCount; j++)
                {
                    var physicsHit = physicsHits[j];
                    var commandHit = commandHits[i * maxHits + j];
                    RaycastHitEquality.AssertEqual(physicsHit, commandHit);
                }
                if (unityHitsCount < maxHits)
                {
                    Assert.AreEqual(null, commandHits[i * maxHits + unityHitsCount].collider);
                }
            }
        }
        public void FromInsideHitsTest()
        {
            var maxHits           = 4;
            var direction         = new Vector3(1f, 1f).normalized;
            var cubeCommand       = new SpherecastCommand(cubeCollider.transform.position, 0.1f, direction);
            var meshCubeCommand   = new SpherecastCommand(meshCubeCollider.transform.position, 0.1f, direction);
            var meshConvexCommand = new SpherecastCommand(meshConvexCollider.transform.position, 0.1f, direction);

            var commandsArray = new SpherecastCommand[] { cubeCommand, meshCubeCommand, meshConvexCommand };

            commands    = new NativeArray <SpherecastCommand>(commandsArray, Allocator.TempJob);
            commandHits = new NativeArray <RaycastHit>(commands.Length * maxHits, Allocator.TempJob);

            raycastAllCommand = new SpherecastAllCommand(commands, commandHits, maxHits);

            raycastAllCommand.Schedule(default(JobHandle)).Complete();

            for (int i = 0; i < commands.Length; i++)
            {
                Assert.IsNull(commandHits[i * maxHits].collider, "SpherecastCommand behaviour changed, spherecasting from inside now returns collision");
            }
        }
        public void NeedForMinStepTest()
        {
            var maxHits           = 4;
            var rayStart          = new Vector3(0f, 4f, 0f);
            var meshConvexCommand = new SpherecastCommand(meshConvexCollider.transform.position + rayStart, 0.1f, Vector3.down);

            var commandsArray = new SpherecastCommand[] { meshConvexCommand };

            commands    = new NativeArray <SpherecastCommand>(commandsArray, Allocator.TempJob);
            commandHits = new NativeArray <RaycastHit>(commands.Length * maxHits, Allocator.TempJob);

            //setting minStep to 0f
            raycastAllCommand = new SpherecastAllCommand(commands, commandHits, maxHits);

            raycastAllCommand.Schedule(default(JobHandle)).Complete();

            Assert.AreEqual(meshConvexCollider, commandHits[0].collider);

            var physicsHits = new RaycastHit[maxHits];

            for (int i = 0; i < commands.Length; i++)
            {
                var unityHitsCount = Physics.SphereCastNonAlloc(commands[i].origin, commands[i].radius, commands[i].direction, physicsHits);

                for (int j = 0; j < unityHitsCount; j++)
                {
                    var physicsHit = physicsHits[j];
                    var commandHit = commandHits[i * maxHits + j];
                    RaycastHitEquality.AssertEqual(physicsHit, commandHit);
                }
                if (unityHitsCount < maxHits)
                {
                    Assert.IsNull(commandHits[i * maxHits + unityHitsCount].collider, "RaycastHit in corner point behaviour changed, minStep may be required");
                }
            }
        }