Пример #1
0
        public override void CheckCollisionCollider(Collider other)
        {
            //if (!active || !other.active) { return; }
            //if (exclusions.Contains(other)) return;

            //Manifold m = new Manifold(this, other);
            //m.Solve();
            bool iscolliding = Collision.CheckCollision(this, other);

            if (iscolliding)
            {
                if (DoExclusionCheck(other)) return;
                if (other.HandlersEnabled)
                {
                    //todo:add to handler list
                    //if (OnCollisionStay != null)
                    //{
                    //    OnCollisionStay(parent, other.parent);
                    //}
                    //bool parentEnter = OnCollisionEnter != null;
                    //if (parentEnter || OnCollisionExit != null || OnCollisionFirstEnter != null || OnCollisionAllExit != null)
                    //{
                    //    HashSet<Collider> lastframe = previousCollision;
                    //    HashSet<Collider> thisframe = currentCollision;
                    //    thisframe.Add(other);
                    //    if (!lastframe.Contains(other) && parentEnter)
                    //    {
                    //        OnCollisionEnter(parent, other.parent);
                    //    }
                    //}

                    if (other.OnCollisionStay != null)
                    {
                        other.OnCollisionStay(other.parent, parent);
                    }
                    bool otherEnter = other.OnCollisionEnter != null;
                    if (otherEnter || other.OnCollisionExit != null || other.OnCollisionFirstEnter != null || other.OnCollisionAllExit != null)
                    {
                        //HashSet<Node> lastframe = other.collision.currentIsCol1 ? other.collision.collisions1 : other.collision.collisions2;
                        //HashSet<Node> thisframe = !other.collision.currentIsCol1 ? other.collision.collisions1 : other.collision.collisions2;
                        HashSet<Collider> lastframe = other.previousCollision;
                        HashSet<Collider> thisframe = other.currentCollision;
                        thisframe.Add(this);
                        if (!lastframe.Contains(this) && otherEnter)
                        {
                            other.OnCollisionEnter(other.parent, parent);
                        }
                    }
                }
            }
        }