Esempio n. 1
0
        public void ShouldNotCollideDifferentSize()
        {
            PE.Sphere rb1 = new PE.Sphere(new PE.Vec3(0), 0.5, 1);
            PE.Sphere rb2 = new PE.Sphere(new PE.Vec3(5, 0, 0), 4, 1);

            PE.HGrid       hgrid = new PE.HGrid();
            PE.HGridObject obj1  = new PE.HGridObject(rb1, rb1.x, (float)rb1.r);
            PE.HGridObject obj2  = new PE.HGridObject(rb2, rb2.x, (float)rb2.r);

            hgrid.AddObject(obj1);
            hgrid.AddObject(obj2);

            List <PE.Sphere> collisions = hgrid.CheckObjAgainstGrid(obj1);

            Console.Write(collisions.Count);
            Assert.IsTrue(collisions.Count == 0);
        }
Esempio n. 2
0
        public void ShouldNotBeEmpty()
        {
            PE.Sphere rb1 = new PE.Sphere(new PE.Vec3(0), 0.5, 1);
            PE.Sphere rb2 = new PE.Sphere(new PE.Vec3(0), 0.5, 1);

            PE.HGrid       hgrid = new PE.HGrid();
            PE.HGridObject obj1  = new PE.HGridObject(rb1, rb1.x, (float)rb1.r);
            PE.HGridObject obj2  = new PE.HGridObject(rb2, rb2.x, (float)rb2.r);

            hgrid.AddObject(obj1);
            hgrid.AddObject(obj2);

            hgrid.RemoveObject(obj1);
            bool empty = hgrid.isEmpty();

            Assert.IsTrue(!empty);
        }
Esempio n. 3
0
        public void ShouldMultipleObjectsCollide()
        {
            PE.Sphere rb1 = new PE.Sphere(new PE.Vec3(1), 0.5, 1);
            PE.Sphere rb2 = new PE.Sphere(new PE.Vec3(2), 0.5, 1);
            PE.Sphere rb3 = new PE.Sphere(new PE.Vec3(3, 0, 0), 0.5, 1);
            PE.Sphere rb4 = new PE.Sphere(new PE.Vec3(0), 4, 1);

            PE.HGrid       hgrid = new PE.HGrid();
            PE.HGridObject obj1  = new PE.HGridObject(rb1, rb1.x, (float)rb1.r);
            PE.HGridObject obj2  = new PE.HGridObject(rb2, rb2.x, (float)rb2.r);
            PE.HGridObject obj3  = new PE.HGridObject(rb3, rb3.x, (float)rb3.r);
            PE.HGridObject obj4  = new PE.HGridObject(rb4, rb4.x, (float)rb4.r);

            hgrid.AddObject(obj1);
            hgrid.AddObject(obj2);
            hgrid.AddObject(obj3);
            hgrid.AddObject(obj4);

            List <PE.Sphere> collisions = hgrid.CheckObjAgainstGrid(obj4);

            Console.Write(collisions.Count);
            Assert.IsTrue(collisions.Count == 3);
        }