Esempio n. 1
0
        public static void CollidePolygonAndCircle(out Manifold manifold, PolygonShape polygon, Transform xf1, CircleShape circle, Transform xf2)
        {
            var polyLock = polygon.Lock();
            var circleLock = circle.Lock();

            NativeMethods.cb2_collidepolygonandcircle(out manifold, polyLock, xf1, circleLock, xf2);

            polygon.Unlock();
            circle.Unlock();
        }
Esempio n. 2
0
        public static void CollidePolygons(out Manifold manifold, PolygonShape poly1, Transform xf1, PolygonShape poly2, Transform xf2)
        {
            var poly1Lock = poly1.Lock();
            var poly2Lock = poly2.Lock();

            NativeMethods.cb2_collidepolygons(out manifold, poly1Lock, xf1, poly2Lock, xf2);

            poly1.Unlock();
            poly2.Unlock();
        }
Esempio n. 3
0
        public static void CollideCircles(out Manifold manifold, CircleShape circle1, Transform xf1, CircleShape circle2, Transform xf2)
        {
            var circle1Lock = circle1.Lock();
            var circle2Lock = circle2.Lock();

            NativeMethods.cb2_collidecircles(out manifold, circle1Lock, xf1, circle2Lock, xf2);

            circle1.Unlock();
            circle2.Unlock();
        }
Esempio n. 4
0
        public override void PreSolve(Contact contact, Manifold oldManifold)
        {
            base.PreSolve(contact, oldManifold);

            Fixture fixtureA = contact.FixtureA;
            Fixture fixtureB = contact.FixtureB;

            if (fixtureA != m_platform && fixtureA != m_character)
                return;

            if (fixtureB != m_character && fixtureB != m_character)
                return;

            Vec2 position = m_character.Body.Position;

            if (position.Y < m_top + m_radius - 3.0f * Box2DSettings.b2_linearSlop)
                contact.Enabled = false;
        }
Esempio n. 5
0
 public static extern void b2contact_evaluate(IntPtr contact, out Manifold outManifold, Transform xfA, Transform xfB);
Esempio n. 6
0
        public void Evaluate(out Manifold manifold, Transform xfA, Transform xfB)
        {
            manifold = new Manifold();

            NativeMethods.b2contact_evaluate(_contactPtr, out manifold, xfA, xfB);
        }
Esempio n. 7
0
 void PreSolveInternal(IntPtr contact, Manifold oldManifold)
 {
     PreSolve(Contact.FromPtr(contact), oldManifold);
 }
Esempio n. 8
0
 public static extern void cb2_collidecircles(out Manifold manifold, IntPtr circle1, Transform xf1, IntPtr circle2, Transform xf2);
Esempio n. 9
0
 public abstract void PreSolve(Contact contact, Manifold oldManifold);
Esempio n. 10
0
 void PreSolveInternal(IntPtr contact, Manifold oldManifold)
 {
     PreSolve(Contact.FromPtr(contact), oldManifold);
 }
Esempio n. 11
0
 public static extern void cb2_collidepolygons(out Manifold manifold, IntPtr polygon1, Transform xf1, IntPtr polygon2, Transform xf2);
Esempio n. 12
0
 public static extern void cb2_collidepolygonandcircle(out Manifold manifold, IntPtr polygon, Transform xf1, IntPtr circle, Transform xf2);
Esempio n. 13
0
 public static extern void cb2_collidecircles(out Manifold manifold, IntPtr circle1, Transform xf1, IntPtr circle2, Transform xf2);
Esempio n. 14
0
 public static extern void b2contact_getmanifold(IntPtr contact, out Manifold manifold);
Esempio n. 15
0
 public static extern void cb2_collidepolygonandcircle(out Manifold manifold, IntPtr polygon, Transform xf1, IntPtr circle, Transform xf2);
Esempio n. 16
0
        public static void GetPointStates(ref PointState[] state1, ref PointState[] state2,
            ref Manifold manifold1, ref Manifold manifold2)
        {
            for (int i = 0; i < Box2DSettings.b2_maxManifoldPoints; ++i)
            {
                state1[i] = PointState.Null;
                state2[i] = PointState.Null;
            }

            // Detect persists and removes.
            for (int i = 0; i < manifold1.PointCount; ++i)
            {
                ContactID id = manifold1[i].ID;

                state1[i] = PointState.Remove;

                for (int j = 0; j < manifold2.PointCount; ++j)
                {
                    if (manifold2[j].ID.Key == id.Key)
                    {
                        state1[i] = PointState.Persist;
                        break;
                    }
                }
            }

            // Detect persists and adds.
            for (int i = 0; i < manifold2.PointCount; ++i)
            {
                ContactID id = manifold2[i].ID;

                state2[i] = PointState.Add;

                for (int j = 0; j < manifold1.PointCount; ++j)
                {
                    if (manifold1[j].ID.Key == id.Key)
                    {
                        state2[i] = PointState.Persist;
                        break;
                    }
                }
            }
        }
Esempio n. 17
0
 public static extern void cb2_collidepolygons(out Manifold manifold, IntPtr polygon1, Transform xf1, IntPtr polygon2, Transform xf2);
Esempio n. 18
0
        public override void PreSolve(Contact contact, Manifold oldManifold)
        {
            Manifold manifold = contact.Manifold;

            if (manifold.PointCount == 0)
                return;

            Fixture fixtureA = contact.FixtureA;
            Fixture fixtureB = contact.FixtureB;

            PointState[] state1 = new PointState[Box2DSettings.b2_maxManifoldPoints],
                state2 = new PointState[Box2DSettings.b2_maxManifoldPoints];
            Manifold.GetPointStates(ref state1, ref state2, ref oldManifold, ref manifold);

            WorldManifold worldManifold = contact.WorldManifold;

            for (int i = 0; i < manifold.PointCount && m_pointCount < ContactPoint.k_maxContactPoints; ++i)
            {
                m_points[m_pointCount].fixtureA = fixtureA;
                m_points[m_pointCount].fixtureB = fixtureB;
                m_points[m_pointCount].position = worldManifold.Points[i];
                m_points[m_pointCount].normal = worldManifold.Normal;
                m_points[m_pointCount].state = state2[i];
                ++m_pointCount;
            }
        }
Esempio n. 19
0
 public abstract void PreSolve(Contact contact, Manifold oldManifold);