Ejemplo n.º 1
0
        private void Evaluate(ref Manifold manifold, ref Transform transformA, ref Transform transformB)
        {
            switch (this._type)
            {
            case Contact.ContactType.Polygon:
                Collision.CollidePolygons(ref manifold, (PolygonShape)this.FixtureA.Shape, ref transformA, (PolygonShape)this.FixtureB.Shape, ref transformB);
                break;

            case Contact.ContactType.PolygonAndCircle:
                Collision.CollidePolygonAndCircle(ref manifold, (PolygonShape)this.FixtureA.Shape, ref transformA, (CircleShape)this.FixtureB.Shape, ref transformB);
                break;

            case Contact.ContactType.Circle:
                Collision.CollideCircles(ref manifold, (CircleShape)this.FixtureA.Shape, ref transformA, (CircleShape)this.FixtureB.Shape, ref transformB);
                break;

            case Contact.ContactType.EdgeAndPolygon:
                Collision.CollideEdgeAndPolygon(ref manifold, (EdgeShape)this.FixtureA.Shape, ref transformA, (PolygonShape)this.FixtureB.Shape, ref transformB);
                break;

            case Contact.ContactType.EdgeAndCircle:
                Collision.CollideEdgeAndCircle(ref manifold, (EdgeShape)this.FixtureA.Shape, ref transformA, (CircleShape)this.FixtureB.Shape, ref transformB);
                break;

            case Contact.ContactType.ChainAndPolygon:
            {
                ChainShape chainShape = (ChainShape)this.FixtureA.Shape;
                chainShape.GetChildEdge(Contact._edge, this.ChildIndexA);
                Collision.CollideEdgeAndPolygon(ref manifold, Contact._edge, ref transformA, (PolygonShape)this.FixtureB.Shape, ref transformB);
                break;
            }

            case Contact.ContactType.ChainAndCircle:
            {
                ChainShape chainShape2 = (ChainShape)this.FixtureA.Shape;
                chainShape2.GetChildEdge(Contact._edge, this.ChildIndexA);
                Collision.CollideEdgeAndCircle(ref manifold, Contact._edge, ref transformA, (CircleShape)this.FixtureB.Shape, ref transformB);
                break;
            }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Evaluate this contact with your own manifold and transforms.
        /// </summary>
        /// <param name="manifold">The manifold.</param>
        /// <param name="transformA">The first transform.</param>
        /// <param name="transformB">The second transform.</param>
        private void Evaluate(ref Manifold manifold, ref Transform transformA, ref Transform transformB)
        {
            switch (_type)
            {
            case ContactType.Polygon:
                Collision.CollidePolygons(ref manifold, (PolygonShape)FixtureA.Shape, ref transformA, (PolygonShape)FixtureB.Shape, ref transformB);
                break;

            case ContactType.PolygonAndCircle:
                Collision.CollidePolygonAndCircle(ref manifold, (PolygonShape)FixtureA.Shape, ref transformA, (CircleShape)FixtureB.Shape, ref transformB);
                break;

            case ContactType.EdgeAndCircle:
                Collision.CollideEdgeAndCircle(ref manifold, (EdgeShape)FixtureA.Shape, ref transformA, (CircleShape)FixtureB.Shape, ref transformB);
                break;

            case ContactType.EdgeAndPolygon:
                Collision.CollideEdgeAndPolygon(ref manifold, (EdgeShape)FixtureA.Shape, ref transformA, (PolygonShape)FixtureB.Shape, ref transformB);
                break;

            case ContactType.ChainAndCircle:
                ChainShape chain = (ChainShape)FixtureA.Shape;
                chain.GetChildEdge(_edge, ChildIndexA);
                Collision.CollideEdgeAndCircle(ref manifold, _edge, ref transformA, (CircleShape)FixtureB.Shape, ref transformB);
                break;

            case ContactType.ChainAndPolygon:
                ChainShape loop2 = (ChainShape)FixtureA.Shape;
                loop2.GetChildEdge(_edge, ChildIndexA);
                Collision.CollideEdgeAndPolygon(ref manifold, _edge, ref transformA, (PolygonShape)FixtureB.Shape, ref transformB);
                break;

            case ContactType.Circle:
                Collision.CollideCircles(ref manifold, (CircleShape)FixtureA.Shape, ref transformA, (CircleShape)FixtureB.Shape, ref transformB);
                break;
            }
        }