Box2D.Collision.Distance.DistanceProxy.Set C# (CSharp) Method

Set() public method

Initialize the proxy using the given shape. The shape must remain in scope while the proxy is in use.
public Set ( Shape shape, int index ) : void
shape Box2D.Collision.Shapes.Shape
index int
return void
            public void Set(Shape shape, int index)
            {
                switch (shape.Type)
                {

                    case ShapeType.Circle:
                        CircleShape circle = (CircleShape)shape;
                        Vertices[0].Set(circle.P);
                        VertexCount = 1;
                        Radius = circle.Radius;

                        break;

                    case ShapeType.Polygon:
                        PolygonShape poly = (PolygonShape)shape;
                        VertexCount = poly.VertexCount;
                        Radius = poly.Radius;
                        for (int i = 0; i < VertexCount; i++)
                        {
                            Vertices[i].Set(poly.Vertices[i]);
                        }
                        break;

                    case ShapeType.Chain:
                        ChainShape chain = (ChainShape)shape;
                        Debug.Assert(0 <= index && index < chain.Count);

                        Buffer[0] = chain.Vertices[index];
                        if (index + 1 < chain.Count)
                        {
                            Buffer[1] = chain.Vertices[index + 1];
                        }
                        else
                        {
                            Buffer[1] = chain.Vertices[0];
                        }

                        Vertices[0].Set(Buffer[0]);
                        Vertices[1].Set(Buffer[1]);
                        VertexCount = 2;
                        Radius = chain.Radius;
                        break;

                    case ShapeType.Edge:
                        EdgeShape edge = (EdgeShape)shape;
                        Vertices[0].Set(edge.Vertex1);
                        Vertices[1].Set(edge.Vertex2);
                        VertexCount = 2;
                        Radius = edge.Radius;
                        break;

                    default:
                        Debug.Assert(false);
                        break;

                }
            }