示例#1
0
        public static void AddType(ContactCreateFcn createFcn, ContactDestroyFcn destoryFcn,
                                   ShapeType type1, ShapeType type2)
        {
            Box2DXDebug.Assert(ShapeType.UnknownShape < type1 && type1 < ShapeType.ShapeTypeCount);
            Box2DXDebug.Assert(ShapeType.UnknownShape < type2 && type2 < ShapeType.ShapeTypeCount);

            if (s_registers[(int)type1] == null)
            {
                s_registers[(int)type1] = new ContactRegister[(int)ShapeType.ShapeTypeCount];
            }

            s_registers[(int)type1][(int)type2].CreateFcn  = createFcn;
            s_registers[(int)type1][(int)type2].DestroyFcn = destoryFcn;
            s_registers[(int)type1][(int)type2].Primary    = true;

            if (type1 != type2)
            {
                //if (_registers[(int)type2] == null)
                //	_registers[(int)type2] = new ContactRegister[(int)ShapeType.ShapeTypeCount];

                s_registers[(int)type2][(int)type1].CreateFcn  = createFcn;
                s_registers[(int)type2][(int)type1].DestroyFcn = destoryFcn;
                s_registers[(int)type2][(int)type1].Primary    = false;
            }
        }
示例#2
0
文件: Contact.cs 项目: vb0067/LGame
        public static void InitializeRegisters()
        {
            for (int i = 0; i < (int)ShapeType.ShapeTypeCount; i++)
            {
                Registers[i] = new ContactRegister[(int)ShapeType.ShapeTypeCount];
            }

            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);
        }
示例#3
0
        public static void InitializeRegisters()
        {
            for (int i = 0; i < (int)ShapeType.ShapeTypeCount; i++)
            {
                Registers[i] = new ContactRegister[(int)ShapeType.ShapeTypeCount];
            }

            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);
        }
		public static void AddType(ContactCreateFcn createFcn, ContactDestroyFcn destoryFcn,
					  ShapeType type1, ShapeType type2)
		{
			Box2DXDebug.Assert(ShapeType.UnknownShape < type1 && type1 < ShapeType.ShapeTypeCount);
			Box2DXDebug.Assert(ShapeType.UnknownShape < type2 && type2 < ShapeType.ShapeTypeCount);

			if (s_registers[(int)type1] == null)
				s_registers[(int)type1] = new ContactRegister[(int)ShapeType.ShapeTypeCount];

			s_registers[(int)type1][(int)type2].CreateFcn = createFcn;
			s_registers[(int)type1][(int)type2].DestroyFcn = destoryFcn;
			s_registers[(int)type1][(int)type2].Primary = true;

			if (type1 != type2)
			{
				//if (_registers[(int)type2] == null)
				//	_registers[(int)type2] = new ContactRegister[(int)ShapeType.ShapeTypeCount];

				s_registers[(int)type2][(int)type1].CreateFcn = createFcn;
				s_registers[(int)type2][(int)type1].DestroyFcn = destoryFcn;
				s_registers[(int)type2][(int)type1].Primary = false;
			}
		}