Example #1
0
        public void Sphere_CollideWithPoint()
        {
            var sphere = new Sphere(Vector3.Zero, 5.0f);

            // represents the movement path
            var transition = new Transition();

            transition.SpherePath.GlobalCurrCenter.Add(new Sphere(new Vector3(20, 20, 20), 5.0f));

            // the point we are checking against is represented with this sphere...
            var checkPos = new Sphere(new Vector3(10, 10, 10), 0);

            var disp      = Vector3.Zero;
            var radsum    = 10.0f;
            var sphereNum = 0;

            var transitionState = sphere.CollideWithPoint(transition, checkPos, disp, radsum, sphereNum);

            Assert.IsTrue(transitionState == TransitionState.Collided);

            transition.ObjectInfo.State |= ObjectInfoState.PerfectClip;
            transitionState              = sphere.CollideWithPoint(transition, checkPos, disp, radsum, sphereNum);
            Assert.IsTrue(transitionState == TransitionState.Collided);

            // should redirect to location not currently in path
            checkPos.Center = new Vector3(30, 30, 30);
            transitionState = sphere.CollideWithPoint(transition, checkPos, disp, radsum, sphereNum);
            Assert.IsTrue(transitionState == TransitionState.Collided);

            // not enough distance to make it this time
            transition.SpherePath.GlobalCurrCenter[0] = new Sphere(new Vector3(1, 1, 1), 5.0f);
            transitionState = sphere.CollideWithPoint(transition, checkPos, disp, radsum, sphereNum);
            Assert.IsTrue(transitionState == TransitionState.Collided);
        }