LargestComponent() private static method

private static LargestComponent ( Vector3 point ) : int
point UnityEngine.Vector3
return int
Example #1
0
 private void AddBreastColliders()
 {
     if (this.middleSpine != null && this.pelvis != null)
     {
         Bounds      bounds      = this.Clip(this.GetBreastBounds(this.pelvis), this.pelvis, this.middleSpine, false);
         BoxCollider boxCollider = this.pelvis.gameObject.AddComponent <BoxCollider>();
         boxCollider.center = bounds.center;
         boxCollider.size   = bounds.size;
         bounds             = this.Clip(this.GetBreastBounds(this.middleSpine), this.middleSpine, this.middleSpine, true);
         boxCollider        = this.middleSpine.gameObject.AddComponent <BoxCollider>();
         boxCollider.center = bounds.center;
         boxCollider.size   = bounds.size;
     }
     else
     {
         Bounds bounds2 = default(Bounds);
         bounds2.Encapsulate(this.pelvis.InverseTransformPoint(this.leftHips.position));
         bounds2.Encapsulate(this.pelvis.InverseTransformPoint(this.rightHips.position));
         bounds2.Encapsulate(this.pelvis.InverseTransformPoint(this.leftArm.position));
         bounds2.Encapsulate(this.pelvis.InverseTransformPoint(this.rightArm.position));
         Vector3 size = bounds2.size;
         size[RagdollBuilder.SmallestComponent(bounds2.size)] = size[RagdollBuilder.LargestComponent(bounds2.size)] / 2f;
         BoxCollider boxCollider2 = this.pelvis.gameObject.AddComponent <BoxCollider>();
         boxCollider2.center = bounds2.center;
         boxCollider2.size   = size;
     }
 }
        private static int SecondLargestComponent(Vector3 point)
        {
            int num  = RagdollBuilder.SmallestComponent(point);
            int num2 = RagdollBuilder.LargestComponent(point);

            if (num < num2)
            {
                int num3 = num2;
                num2 = num;
                num  = num3;
            }
            int result;

            if (num == 0 && num2 == 1)
            {
                result = 2;
            }
            else if (num == 0 && num2 == 2)
            {
                result = 1;
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Example #3
0
        private Bounds GetBreastBounds(Transform relativeTo)
        {
            Bounds result = default(Bounds);

            result.Encapsulate(relativeTo.InverseTransformPoint(this.leftHips.position));
            result.Encapsulate(relativeTo.InverseTransformPoint(this.rightHips.position));
            result.Encapsulate(relativeTo.InverseTransformPoint(this.leftArm.position));
            result.Encapsulate(relativeTo.InverseTransformPoint(this.rightArm.position));
            Vector3 size = result.size;

            size[RagdollBuilder.SmallestComponent(result.size)] = size[RagdollBuilder.LargestComponent(result.size)] / 2f;
            result.size = size;
            return(result);
        }
        private Bounds GetBreastBounds(Transform relativeTo)
        {
            Bounds bounds = new Bounds();

            bounds.Encapsulate(relativeTo.InverseTransformPoint(this.leftHips.position));
            bounds.Encapsulate(relativeTo.InverseTransformPoint(this.rightHips.position));
            bounds.Encapsulate(relativeTo.InverseTransformPoint(this.leftArm.position));
            bounds.Encapsulate(relativeTo.InverseTransformPoint(this.rightArm.position));
            Vector3 size = bounds.size;

            size[RagdollBuilder.SmallestComponent(bounds.size)] = size[RagdollBuilder.LargestComponent(bounds.size)] / 2f;
            bounds.size = size;
            return(bounds);
        }
        private static int SecondLargestComponent(Vector3 point)
        {
            int num1 = RagdollBuilder.SmallestComponent(point);
            int num2 = RagdollBuilder.LargestComponent(point);

            if (num1 < num2)
            {
                int num3 = num2;
                num2 = num1;
                num1 = num3;
            }
            if (num1 == 0 && num2 == 1)
            {
                return(2);
            }
            return(num1 == 0 && num2 == 2 ? 1 : 0);
        }
Example #6
0
        private Bounds Clip(Bounds bounds, Transform relativeTo, Transform clipTransform, bool below)
        {
            int index = RagdollBuilder.LargestComponent(bounds.size);

            if (Vector3.Dot(this.worldUp, relativeTo.TransformPoint(bounds.max)) > Vector3.Dot(this.worldUp, relativeTo.TransformPoint(bounds.min)) == below)
            {
                Vector3 min = bounds.min;
                min[index] = relativeTo.InverseTransformPoint(clipTransform.position)[index];
                bounds.min = min;
            }
            else
            {
                Vector3 max = bounds.max;
                max[index] = relativeTo.InverseTransformPoint(clipTransform.position)[index];
                bounds.max = max;
            }
            return(bounds);
        }