示例#1
0
 public void RemoteRegisterCollision(PhysCompoundCollider coll)
 {
     if (coll.IsValid)
     {
         collisionSet.Add(coll);
     }
 }
示例#2
0
        public static void UnregisterCollider(PhysCompoundCollider coll)
        {
            if (!idLookUp.ContainsKey(coll))
            {
                return;
            }

            uint id = idLookUp[coll];

            idPool.Push(id);
            idLookUp.Remove(coll);

            colliderList.Remove(compoundColliderReg[coll]);
            compoundColliderReg.Remove(coll);
        }
示例#3
0
            public FCollisionBodyExtractor(PhysCompoundCollider compoundCollider)
            {
                if (compoundCollider is PhysRigidbody)
                {
                    PhysRigidbody rigid = compoundCollider as PhysRigidbody;

                    Bounciness  = rigid.Bounciness;
                    IsRigidbody = true;
                }
                else
                {
                    Bounciness  = float.MaxValue;
                    IsRigidbody = false;
                }

                Body = compoundCollider;
            }
示例#4
0
        protected void TriggerCollisionEnter(PhysCompoundCollider other)
        {
            if (other.IsValid)
            {
                collisionSet.Add(other);
            }

            FCollision collision = new FCollision()
            {
                Other          = other.gameObject,
                OtherCollider  = other,
                OtherRigidbody = other as PhysRigidbody
            };

            if (other.IsTrigger || IsTrigger)
            {
                PhysicsEngine.EventManager.InvokeTriggerEnter(gameObject, collision);
            }
            else
            {
                PhysicsEngine.EventManager.InvokeCollisionEnter(gameObject, collision);
            }

            if (collision.OtherRigidbody == null)
            {
                other.RemoteRegisterCollision(this);

                collision = new FCollision()
                {
                    Other          = this.gameObject,
                    OtherCollider  = this,
                    OtherRigidbody = this
                };

                if (other.IsTrigger || IsTrigger)
                {
                    PhysicsEngine.EventManager.InvokeTriggerEnter(other.gameObject, collision);
                }
                else
                {
                    PhysicsEngine.EventManager.InvokeCollisionEnter(other.gameObject, collision);
                }
            }
        }
示例#5
0
        protected void TriggerCollisionExit(PhysCompoundCollider other)
        {
            collisionSet.Remove(other);

            FCollision collision = new FCollision()
            {
                Other          = other.gameObject,
                OtherCollider  = other,
                OtherRigidbody = other as PhysRigidbody
            };

            if (other.IsTrigger || IsTrigger)
            {
                PhysicsEngine.EventManager.InvokeTriggerExit(gameObject, collision);
            }
            else
            {
                PhysicsEngine.EventManager.InvokeCollisionExit(gameObject, collision);
            }

            if (!(other is PhysRigidbody))
            {
                other.RemoteUnregisterCollision(this);

                collision = new FCollision()
                {
                    Other          = this.gameObject,
                    OtherCollider  = this,
                    OtherRigidbody = this
                };

                if (other.IsTrigger || IsTrigger)
                {
                    PhysicsEngine.EventManager.InvokeTriggerExit(other.gameObject, collision);
                }
                else
                {
                    PhysicsEngine.EventManager.InvokeCollisionExit(other.gameObject, collision);
                }
            }
        }
示例#6
0
        public static void RegisterCollider(PhysCompoundCollider coll)
        {
            if (compoundColliderReg.ContainsKey(coll))
            {
                return;
            }

            if (idPool.Count == 0)
            {
                FillIDPool();

                if (idPool.Count == 0)
                {
                    return;
                }
            }

            uint id = idPool.Pop();

            compoundColliderReg.Add(coll, colliderList.AddLast(coll));
            idLookUp.Add(coll, id);
        }
示例#7
0
 public void RemoteUnregisterCollision(PhysCompoundCollider coll)
 {
     collisionSet.Remove(coll);
 }
示例#8
0
        public void GatherCollisionInformation(PhysCompoundCollider other)
        {
            if (other is PhysRigidbody)
            {
                PhysRigidbody rigid = other as PhysRigidbody;

                for (int c1 = 0; c1 < Collider.Length; c1++)
                {
                    FAABB2D bounds = other.Collider[c1].CachedBoundsWS;

                    for (int c2 = 0; c2 < other.Collider.Length; c2++)
                    {
                        if (bounds.Intersects(other.Collider[c2].CachedBoundsWS))
                        {
                            CollisionContact manifold = null;
                            bool             isBodyA  = false;

                            if (Collider[c1].IsColliding(other.Collider[c2], out manifold, out isBodyA))
                            {
                                if (isBodyA)
                                {
                                    manifold.A = this;
                                    manifold.B = rigid;
                                }
                                else
                                {
                                    manifold.A = rigid;
                                    manifold.B = this;
                                }

                                RegisterCollision(manifold, isBodyA);
                                rigid.RegisterCollision(manifold, !isBodyA);
                            }
                        }
                    }
                }
            }
            else
            {
                for (int c1 = 0; c1 < Collider.Length; c1++)
                {
                    FAABB2D bounds = other.Collider[c1].CachedBoundsWS;

                    for (int c2 = 0; c2 < other.Collider.Length; c2++)
                    {
                        if (bounds.Intersects(other.Collider[c2].CachedBoundsWS))
                        {
                            CollisionContact manifold = null;
                            bool             isBodyA  = false;

                            if (Collider[c1].IsColliding(other.Collider[c2], out manifold, out isBodyA))
                            {
                                if (isBodyA)
                                {
                                    manifold.A = this;
                                    manifold.B = other;
                                }
                                else
                                {
                                    manifold.A = other;
                                    manifold.B = this;
                                }

                                RegisterCollision(manifold, isBodyA);
                            }
                        }
                    }
                }
            }
        }