Box2DX.Dynamics.Contact.InitializeRegisters C# (CSharp) Метод

InitializeRegisters() публичный статический Метод

public static InitializeRegisters ( ) : void
Результат void
        public static void InitializeRegisters()
        {
            AddType(CircleContact.Create, CircleContact.Destroy, ShapeType.CircleShape, ShapeType.CircleShape);
            AddType(PolyAndCircleContact.Create, PolyAndCircleContact.Destroy, ShapeType.PolygonShape, ShapeType.CircleShape);
            AddType(PolygonContact.Create, PolygonContact.Destroy, ShapeType.PolygonShape, ShapeType.PolygonShape);

            AddType(EdgeAndCircleContact.Create, EdgeAndCircleContact.Destroy, ShapeType.EdgeShape, ShapeType.CircleShape);
            AddType(PolyAndEdgeContact.Create, PolyAndEdgeContact.Destroy, ShapeType.PolygonShape, ShapeType.EdgeShape);
        }

Usage Example

Пример #1
0
        public static Contact Create(Shape shape1, Shape shape2)
        {
            if (!Contact.s_initialized)
            {
                Contact.InitializeRegisters();
                Contact.s_initialized = true;
            }
            ShapeType type  = shape1.GetType();
            ShapeType type2 = shape2.GetType();

            Box2DXDebug.Assert(ShapeType.UnknownShape < type && type < ShapeType.ShapeTypeCount);
            Box2DXDebug.Assert(ShapeType.UnknownShape < type2 && type2 < ShapeType.ShapeTypeCount);
            ContactCreateFcn createFcn = Contact.s_registers[(int)type][(int)type2].CreateFcn;
            Contact          result;

            if (createFcn != null)
            {
                if (Contact.s_registers[(int)type][(int)type2].Primary)
                {
                    result = createFcn(shape1, shape2);
                }
                else
                {
                    Contact contact = createFcn(shape2, shape1);
                    for (int i = 0; i < contact.GetManifoldCount(); i++)
                    {
                        Manifold manifold = contact.GetManifolds()[i];
                        manifold.Normal = -manifold.Normal;
                    }
                    result = contact;
                }
            }
            else
            {
                result = null;
            }
            return(result);
        }