Esempio n. 1
0
        /// <summary>
        /// Begin collision world event
        /// </summary>
        /// <param name="contact">contact instance</param>
        private void Simulate2D_BeginCollision(WaveEngine.Common.Physics2D.ICollisionInfo2D contact)
        {
            var fixtureA = contact.ColliderA;
            var fixtureB = contact.ColliderB;

            if (fixtureA.IsSensor && fixtureB.RigidBody.Type == WaveEngine.Common.Physics2D.RigidBodyType2D.Dynamic)
            {
                this.fixturePairs.Add(new Tuple <ICollider2D, ICollider2D>(fixtureA, fixtureB));
            }
            else if (fixtureB.IsSensor && fixtureA.RigidBody.Type == RigidBodyType2D.Dynamic)
            {
                this.fixturePairs.Add(new Tuple <ICollider2D, ICollider2D>(fixtureB, fixtureA));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// End collision world event
        /// </summary>
        /// <param name="contact">contact instance</param>
        private void Simulate2D_EndCollision(WaveEngine.Common.Physics2D.ICollisionInfo2D contact)
        {
            var fixtureA = contact.ColliderA;
            var fixtureB = contact.ColliderB;

            if (fixtureA.IsSensor && fixtureB.RigidBody.Type == RigidBodyType2D.Dynamic)
            {
                var tuple = this.fixturePairs.Find(pair => pair.Item1 == fixtureA && pair.Item2 == fixtureB);
                this.fixturePairs.Remove(tuple);
            }
            else if (fixtureB.IsSensor && fixtureA.RigidBody.Type == RigidBodyType2D.Dynamic)
            {
                var tuple = this.fixturePairs.Find(pair => pair.Item1 == fixtureB && pair.Item2 == fixtureA);
                this.fixturePairs.Remove(tuple);
            }
        }