예제 #1
0
 public static bool ContainsBounds(this Collider collider, Bounds bounds)
 {
     return(collider.ContainsPosition(bounds.BottomLeftBack()) &&
            collider.ContainsPosition(bounds.BottomLeftFront()) &&
            collider.ContainsPosition(bounds.BottomRightBack()) &&
            collider.ContainsPosition(bounds.BottomRightFront()) &&
            collider.ContainsPosition(bounds.TopLeftBack()) &&
            collider.ContainsPosition(bounds.TopLeftFront()) &&
            collider.ContainsPosition(bounds.TopRightBack()) &&
            collider.ContainsPosition(bounds.TopRightFront()));
 }
예제 #2
0
        public static IEnumerable <Vector3> Points(this Bounds bound)
        {
            yield return(bound.BottomLeftBack());

            yield return(bound.BottomLeftFront());

            yield return(bound.BottomRightBack());

            yield return(bound.BottomRightFront());

            yield return(bound.TopLeftBack());

            yield return(bound.TopLeftFront());

            yield return(bound.TopRightBack());

            yield return(bound.TopRightFront());
        }
예제 #3
0
        public static Vector3 FurthestPoint(this Bounds bounds, Vector3 toCompare)
        {
            Vector3 distance = (bounds.ClosestPoint(toCompare) - bounds.center);

            if (distance.x > 0)
            {
                //then left side
                if (distance.y > 0)
                {
                    // then bottom
                    if (distance.z > 0)
                    {
                        //then front
                        return(bounds.BottomLeftFront());
                    }
                    else
                    {
                        //then back
                        return(bounds.BottomLeftBack());
                    }
                }
                else
                {
                    //then top
                    if (distance.z > 0)
                    {
                        //then front
                        return(bounds.TopLeftFront());
                    }
                    else
                    {
                        //then back
                        return(bounds.TopLeftBack());
                    }
                }
            }
            else
            {
                //then right side
                if (distance.y > 0)
                {
                    // then bottom
                    if (distance.z > 0)
                    {
                        //then front
                        return(bounds.BottomRightFront());
                    }
                    else
                    {
                        //then back
                        return(bounds.BottomRightBack());
                    }
                }
                else
                {
                    //then top
                    if (distance.z > 0)
                    {
                        //then front
                        return(bounds.TopRightFront());
                    }
                    else
                    {
                        //then back
                        return(bounds.TopRightBack());
                    }
                }
            }
        }
예제 #4
0
        public static Vector3 RandomPointInBounds(this Bounds bound)
        {
            Vector3 rightSideRand = RandomExt.RandomVectorInQuad(bound.TopRightBack(), bound.TopRightFront(),
                                                                 bound.BottomRightBack(), bound.BottomRightFront());
            Vector3 leftSideRand = RandomExt.RandomVectorInQuad(bound.TopLeftBack(), bound.TopLeftFront(),
                                                                bound.BottomLeftBack(), bound.BottomLeftFront());

            return(RandomExt.RandomVectorBetween(rightSideRand, leftSideRand));
        }