示例#1
0
        public static Contact Create(Fixture fixtureA, Fixture fixtureB)
        {
            if (s_initialized == false)
            {
                InitializeRegisters();
                s_initialized = true;
            }

            ShapeType type1 = fixtureA.ShapeType;
            ShapeType type2 = fixtureB.ShapeType;

            Box2DXDebug.Assert(ShapeType.UnknownShape < type1 && type1 < ShapeType.ShapeTypeCount);
            Box2DXDebug.Assert(ShapeType.UnknownShape < type2 && type2 < ShapeType.ShapeTypeCount);

            ContactCreateFcn createFcn = s_registers[(int)type1][(int)type2].CreateFcn;

            if (createFcn != null)
            {
                if (s_registers[(int)type1][(int)type2].Primary)
                {
                    return(createFcn(fixtureA, fixtureB));
                }
                else
                {
                    return(createFcn(fixtureB, fixtureA));
                }
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        internal static Contact Create(Fixture fixtureA, int indexA, Fixture fixtureB, int indexB)
        {
            if (s_initialized == false)
            {
                InitializeRegisters();
                s_initialized = true;
            }

            ShapeType type1 = fixtureA.GetShapeType();
            ShapeType type2 = fixtureB.GetShapeType();

            Utilities.Assert(0 <= type1 && type1 < ShapeType.Count);
            Utilities.Assert(0 <= type2 && type2 < ShapeType.Count);

            ContactCreateFcn createFcn = s_registers[(int)type1, (int)type2].createFcn;

            if (createFcn != null)
            {
                if (s_registers[(int)type1, (int)type2].primary)
                {
                    return(createFcn(fixtureA, indexA, fixtureB, indexB));
                }
                else
                {
                    return(createFcn(fixtureB, indexB, fixtureA, indexA));
                }
            }
            else
            {
                return(null);
            }
        }
示例#3
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;
            }
        }
示例#4
0
        public static Contact Create(Fixture fixtureA, Fixture fixtureB)
        {
            if (s_initialized == false)
            {
                InitializeRegisters();
                s_initialized = true;
            }

            ShapeType type1 = fixtureA.ShapeType;
            ShapeType type2 = fixtureB.ShapeType;


            ContactCreateFcn createFcn = s_registers[(int)type1][(int)type2].CreateFcn;

            if (createFcn != null)
            {
                if (s_registers[(int)type1][(int)type2].Primary)
                {
                    return(createFcn(fixtureA, fixtureB));
                }
                else
                {
                    return(createFcn(fixtureB, fixtureA));
                }
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        protected static void AddType(ContactCreateFcn createFcn, ContactDestroyFcn destroyFcn, ShapeType type1, ShapeType type2)
        {
            Utilities.Assert(0 <= (int)type1 && type1 < ShapeType.Count);
            Utilities.Assert(0 <= (int)type2 && type2 < ShapeType.Count);

            s_registers[(int)type1, (int)type2].createFcn  = createFcn;
            s_registers[(int)type1, (int)type2].destroyFcn = destroyFcn;
            s_registers[(int)type1, (int)type2].primary    = true;

            if (type1 != type2)
            {
                s_registers[(int)type2, (int)type1].createFcn  = createFcn;
                s_registers[(int)type2, (int)type1].destroyFcn = destroyFcn;
                s_registers[(int)type2, (int)type1].primary    = false;
            }
        }
示例#6
0
文件: Contact.cs 项目: vb0067/LGame
        public static void AddType(ContactCreateFcn createFcn, ContactDestroyFcn destroyFcn,
                                   ShapeType typeA, ShapeType typeB)
        {
            Box2DXDebug.Assert(ShapeType.UnknownShape < typeA && typeA < ShapeType.ShapeTypeCount);
            Box2DXDebug.Assert(ShapeType.UnknownShape < typeB && typeB < ShapeType.ShapeTypeCount);

            Registers[(int)typeA][(int)typeB].CreateFcn  = createFcn;
            Registers[(int)typeA][(int)typeB].DestroyFcn = destroyFcn;
            Registers[(int)typeA][(int)typeB].Primary    = true;

            if (typeA != typeB)
            {
                Registers[(int)typeB][(int)typeA].CreateFcn  = createFcn;
                Registers[(int)typeB][(int)typeA].DestroyFcn = destroyFcn;
                Registers[(int)typeB][(int)typeA].Primary    = false;
            }
        }
示例#7
0
文件: Contact.cs 项目: litdev1/LitDev
 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 (Contact.s_registers[(int)type1] == null)
     {
         Contact.s_registers[(int)type1] = new ContactRegister[2];
     }
     Contact.s_registers[(int)type1][(int)type2].CreateFcn = createFcn;
     Contact.s_registers[(int)type1][(int)type2].DestroyFcn = destoryFcn;
     Contact.s_registers[(int)type1][(int)type2].Primary = true;
     if (type1 != type2)
     {
         Contact.s_registers[(int)type2][(int)type1].CreateFcn = createFcn;
         Contact.s_registers[(int)type2][(int)type1].DestroyFcn = destoryFcn;
         Contact.s_registers[(int)type2][(int)type1].Primary = false;
     }
 }
示例#8
0
        public static void AddType(ContactCreateFcn createFcn, ContactDestroyFcn destoryFcn,
                                   ShapeType type1, ShapeType type2)
        {
            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)
            {
                s_registers[(int)type2][(int)type1].CreateFcn  = createFcn;
                s_registers[(int)type2][(int)type1].DestroyFcn = destoryFcn;
                s_registers[(int)type2][(int)type1].Primary    = false;
            }
        }
示例#9
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);
        }
示例#10
0
        public static Contact Create(Shape shape1, Shape shape2)
        {
            if (s_initialized == false)
            {
                InitializeRegisters();
                s_initialized = true;
            }

            ShapeType type1 = shape1.GetType();
            ShapeType type2 = shape2.GetType();

            Box2DXDebug.Assert(ShapeType.UnknownShape < type1 && type1 < ShapeType.ShapeTypeCount);
            Box2DXDebug.Assert(ShapeType.UnknownShape < type2 && type2 < ShapeType.ShapeTypeCount);

            ContactCreateFcn createFcn = s_registers[(int)type1][(int)type2].CreateFcn;

            if (createFcn != null)
            {
                if (s_registers[(int)type1][(int)type2].Primary)
                {
                    return(createFcn(shape1, shape2));
                }
                else
                {
                    Contact c = createFcn(shape2, shape1);
                    for (int i = 0; i < c.GetManifoldCount(); ++i)
                    {
                        Manifold m = c.GetManifolds()[i];
                        m.Normal = -m.Normal;
                    }
                    return(c);
                }
            }
            else
            {
                return(null);
            }
        }
示例#11
0
        public static void AddType(ContactCreateFcn createFcn, ContactDestroyFcn destroyFcn,
                            ShapeType typeA, ShapeType typeB)
        {
            Box2DXDebug.Assert(ShapeType.UnknownShape < typeA && typeA < ShapeType.ShapeTypeCount);
            Box2DXDebug.Assert(ShapeType.UnknownShape < typeB && typeB < ShapeType.ShapeTypeCount);

            Registers[(int)typeA][(int)typeB].CreateFcn = createFcn;
            Registers[(int)typeA][(int)typeB].DestroyFcn = destroyFcn;
            Registers[(int)typeA][(int)typeB].Primary = true;

            if (typeA != typeB)
            {
                Registers[(int)typeB][(int)typeA].CreateFcn = createFcn;
                Registers[(int)typeB][(int)typeA].DestroyFcn = destroyFcn;
                Registers[(int)typeB][(int)typeA].Primary = false;
            }
        }
示例#12
0
		protected static void AddType(ContactCreateFcn createFcn, ContactDestroyFcn destroyFcn, ShapeType type1, ShapeType type2){
			Utilities.Assert(0 <= (int)type1 && type1 < ShapeType.Count);
			Utilities.Assert(0 <= (int)type2 && type2 < ShapeType.Count);

			s_registers[(int)type1, (int)type2].createFcn = createFcn;
			s_registers[(int)type1, (int)type2].destroyFcn = destroyFcn;
			s_registers[(int)type1, (int)type2].primary = true;

			if (type1 != type2)
			{
				s_registers[(int)type2, (int)type1].createFcn = createFcn;
				s_registers[(int)type2, (int)type1].destroyFcn = destroyFcn;
				s_registers[(int)type2, (int)type1].primary = false;
			}
		}