public void FromIntersectionTests()
        {
            var someAabb         = new BoundingRectangle(100, 100, 120, 120);
            var intersectingAabb = new BoundingRectangle(90, 90, 110, 110);
            var containedAabb    = new BoundingRectangle(110, 110, 115, 115);
            var disjointedAabb   = new BoundingRectangle(0, 0, 50, 50);

            Assert.That(BoundingRectangle.FromIntersection(someAabb, intersectingAabb),
                        Is.EqualTo(new BoundingRectangle(100, 100, 110, 110)));
            Assert.That(BoundingRectangle.FromIntersection(someAabb, containedAabb), Is.EqualTo(containedAabb));
            Assert.That(BoundingRectangle.FromIntersection(someAabb, disjointedAabb),
                        Is.EqualTo(BoundingRectangle.Empty));
        }
예제 #2
0
            void Collide()
            {
                BoundingRectangle bb1 = body1.Rectangle;
                BoundingRectangle bb2 = body2.Rectangle;
                BoundingRectangle targetArea;

                BoundingRectangle.FromIntersection(ref bb1, ref bb2, out targetArea);
                LinkedListNode <ContactPoint> node = contacts.First;

                if (!body2.IgnoreVertexes &&
                    body1.Shape.CanGetIntersection)
                {
                    Collide(ref node, this.body1, this.body2, false, ref targetArea);
                }
                if (!body1.IgnoreVertexes &&
                    body2.Shape.CanGetIntersection)
                {
                    Collide(ref node, this.body2, this.body1, true, ref targetArea);
                }
            }