Пример #1
0
        public void Test1()
        {
            CollisionObject object1A = new CollisionObject();
              object1A.CollisionGroup = 1;
              CollisionObject object1B = new CollisionObject();
              object1B.CollisionGroup = 1;

              CollisionObject object2A = new CollisionObject();
              object2A.CollisionGroup = 2;
              CollisionObject object2B = new CollisionObject();
              object2B.CollisionGroup = 2;

              CollisionFilter filter = new CollisionFilter();

              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object1A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object2B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object1A, object2B)));

              filter.Set(2, false);
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object1A, object1B)));
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object2A, object2B)));
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object2A, object1B)));
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object1A, object2B)));

              filter.Set(1, false);
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object1A, object1B)));
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object2A, object2B)));
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object2A, object1B)));
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object1A, object2B)));

              filter.Set(2, true);
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object1A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object2B)));
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object2A, object1B)));
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object1A, object2B)));

              filter.Set(1, true);
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object1A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object2B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object1A, object2B)));

              filter.Set(1, 1, false);
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object1A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object2B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object1A, object2B)));

              filter.Set(2, 1, false);
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object1A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object2B)));
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object2A, object1B)));
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object1A, object2B)));

              filter.Set(1, 1, true);
              filter.Set(1, 2, true);
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object1A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object2B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object1A, object2B)));

              filter.Set(object1A, object2B, false);
              filter.Set(object1B, object1A, false);
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object1A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object2B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object1B)));
              Assert.IsFalse(filter.Filter(new Pair<CollisionObject>(object1A, object2B)));

              filter.Set(object1A, object2B, true);
              filter.Set(object1B, object1A, true);
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object1A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object2B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object1A, object2B)));

              filter.Set(object1B, object1A, false);
              filter.Reset();
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object1A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object2B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object2A, object1B)));
              Assert.IsTrue(filter.Filter(new Pair<CollisionObject>(object1A, object2B)));
        }
Пример #2
0
        public void Test1()
        {
            CollisionObject object1A = new CollisionObject();

            object1A.CollisionGroup = 1;
            CollisionObject object1B = new CollisionObject();

            object1B.CollisionGroup = 1;

            CollisionObject object2A = new CollisionObject();

            object2A.CollisionGroup = 2;
            CollisionObject object2B = new CollisionObject();

            object2B.CollisionGroup = 2;

            CollisionFilter filter = new CollisionFilter();

            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object1A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object2B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object1A, object2B)));

            filter.Set(2, false);
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object1A, object1B)));
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object2A, object2B)));
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object2A, object1B)));
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object1A, object2B)));

            filter.Set(1, false);
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object1A, object1B)));
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object2A, object2B)));
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object2A, object1B)));
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object1A, object2B)));

            filter.Set(2, true);
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object1A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object2B)));
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object2A, object1B)));
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object1A, object2B)));

            filter.Set(1, true);
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object1A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object2B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object1A, object2B)));

            filter.Set(1, 1, false);
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object1A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object2B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object1A, object2B)));

            filter.Set(2, 1, false);
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object1A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object2B)));
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object2A, object1B)));
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object1A, object2B)));

            filter.Set(1, 1, true);
            filter.Set(1, 2, true);
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object1A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object2B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object1A, object2B)));

            filter.Set(object1A, object2B, false);
            filter.Set(object1B, object1A, false);
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object1A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object2B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object1B)));
            Assert.IsFalse(filter.Filter(new Pair <CollisionObject>(object1A, object2B)));

            filter.Set(object1A, object2B, true);
            filter.Set(object1B, object1A, true);
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object1A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object2B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object1A, object2B)));

            filter.Set(object1B, object1A, false);
            filter.Reset();
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object1A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object2B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object2A, object1B)));
            Assert.IsTrue(filter.Filter(new Pair <CollisionObject>(object1A, object2B)));
        }