Пример #1
0
        protected virtual bool OnContactBegin(CContactBeginEventArgs pEventArgs)
        {
            if (m_ContactBegin != null)
            {
                m_ContactBegin(this, pEventArgs);
            }

            return(pEventArgs.AllowCollision);
        }
Пример #2
0
        private void ContactBegin(object sender, Game.Newt.v1.NewtonDynamics1.Api.CContactBeginEventArgs e)
        {
            #region Get Keys

            // Get the entry for this material pair
            string key = GetMaterialComboHash(e.Body0.MaterialGroupID, e.Body1.MaterialGroupID);
            if (!_collisionListeners.ContainsKey(key))
            {
                throw new ApplicationException("There is no listener for this material pair, but how did this callback get set up???: " + key);
            }

            // Just to complicate things, the contact process callback doesn't give me bodies, and e.Material is different, so I have store the key,
            // and trust everything is called in order
            _currentCollidingKey = key;

            #endregion

            // Reset for this current collision between these two bodies
            CollisionEventProps eventProps = _collisionListeners[key];
            eventProps.CollisionBody1        = e.Body0.UserData;
            eventProps.CollisionBody2        = e.Body1.UserData;
            eventProps.Material1             = _materials[e.Body0.MaterialGroupID];
            eventProps.Material2             = _materials[e.Body1.MaterialGroupID];
            eventProps.HasRaisedContactEvent = false;
            eventProps.HasContactCancelled   = false;

            if (eventProps.CollisionStart != null)
            {
                // Raise an event to the outside
                CollisionStartEventArgs args = new CollisionStartEventArgs();
                args.Body1 = e.Body0.UserData;
                args.Body2 = e.Body1.UserData;

                eventProps.CollisionStart(this, args);

                // Tell the caller what the user decided
                e.AllowCollision = args.AllowCollision;

                // This shouldn't matter, because the ContactProcess shouldn't be called if they cancelled, but I'm just being safe
                if (!args.AllowCollision)
                {
                    eventProps.HasContactCancelled = true;
                }
            }
        }
Пример #3
0
		protected virtual bool OnContactBegin(CContactBeginEventArgs pEventArgs)
		{
			if (m_ContactBegin != null)
			{
				m_ContactBegin(this, pEventArgs);
			}

            return pEventArgs.AllowCollision;
		}