Пример #1
0
        public static void UnregisterRigidbody(PhysRigidbody rigid)
        {
            if (!idLookUp.ContainsKey(rigid))
            {
                return;
            }

            uint id = idLookUp[rigid];

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

            rigidbodiesList.Remove(rigidbodyReg[rigid]);
            rigidbodyReg.Remove(rigid);
        }
Пример #2
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;
            }
Пример #3
0
        public static void RegisterRigidbody(PhysRigidbody rigid)
        {
            if (rigidbodyReg.ContainsKey(rigid))
            {
                return;
            }

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

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

            uint id = idPool.Pop();

            rigidbodyReg.Add(rigid, rigidbodiesList.AddLast(rigid));
            idLookUp.Add(rigid, id);
        }
Пример #4
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);
                            }
                        }
                    }
                }
            }
        }