コード例 #1
0
        private static void CheckResult(ContactSet contactSet, bool isClosestPointResult)
        {
            if (isClosestPointResult && contactSet.Count > 1)
            {
                throw new GeometryException("Closest point query result contains more than one contact.");
            }

            if (contactSet.HaveContact)
            {
                if (contactSet.Any(contact => contact.PenetrationDepth < 0))
                {
                    throw new GeometryException("HaveContact is true but the contactSet contains a separated contact.");
                }

                if (contactSet.ObjectA.GeometricObject.Shape is RayShape || contactSet.ObjectB.GeometricObject.Shape is RayShape)
                {
                    if (contactSet.Count > 1)
                    {
                        throw new GeometryException("Ray casts must not contain more than 1 contact.");
                    }

                    if (contactSet.Any(contact => !contact.IsRayHit))
                    {
                        throw new GeometryException("IsRayHit is not set for a ray hit.");
                    }
                }
            }

            if (isClosestPointResult == false && contactSet.HaveContact == false && contactSet.Count > 0)
            {
                throw new GeometryException("A contact query returned contact details for a separated pair.");
            }

            if (contactSet.HaveContact == false && contactSet.Any(contact => contact.PenetrationDepth >= 0))
            {
                throw new GeometryException("HaveContact is false but the contactSet contains a touching/penetrating contact.");
            }
        }
コード例 #2
0
        private static void CheckResult(ContactSet contactSet, bool isClosestPointResult)
        {
            if (isClosestPointResult && contactSet.Count > 1)
            throw new GeometryException("Closest point query result contains more than one contact.");

              if (contactSet.HaveContact)
              {
            if (contactSet.Any(contact => contact.PenetrationDepth < 0))
              throw new GeometryException("HaveContact is true but the contactSet contains a separated contact.");

            if (contactSet.ObjectA.GeometricObject.Shape is RayShape || contactSet.ObjectB.GeometricObject.Shape is RayShape)
            {
              if (contactSet.Count > 1)
            throw new GeometryException("Ray casts must not contain more than 1 contact.");

              if (contactSet.Any(contact => !contact.IsRayHit))
            throw new GeometryException("IsRayHit is not set for a ray hit.");
            }
              }

              if (isClosestPointResult == false && contactSet.HaveContact == false && contactSet.Count > 0)
            throw new GeometryException("A contact query returned contact details for a separated pair.");

              if (contactSet.HaveContact == false && contactSet.Any(contact => contact.PenetrationDepth >= 0))
            throw new GeometryException("HaveContact is false but the contactSet contains a touching/penetrating contact.");
        }