示例#1
0
        public static ElementBounds CreateBounds(ElementBoundsSource boundsSource, ElementBoundsProvider boundsProvider, Transform transform, Func <Bounds> automaticAxisAlignedBox, Func <Sphere> automaticSphere)
        {
            var fixedScale    = (boundsSource & ElementBoundsSource.FixedScale) != 0;
            var fixedRotation = (boundsSource & ElementBoundsSource.FixedRotation) != 0;

            switch (boundsSource & ElementBoundsSource.Source)
            {
            case ElementBoundsSource.None:
                return(null);

            case ElementBoundsSource.LocalOrigin:
                return(new LocalOriginBounds());

            case ElementBoundsSource.Automatic:
                if (fixedRotation)
                {
                    goto case ElementBoundsSource.AutomaticAxisAlignedBox;
                }
                goto case ElementBoundsSource.AutomaticSphere;

            case ElementBoundsSource.AutomaticAxisAlignedBox:
                return(AxisAlignedBoxBounds.Create(automaticAxisAlignedBox(), transform, fixedScale));

            case ElementBoundsSource.AutomaticSphere:
                return(SphereBounds.Create(automaticSphere(), transform, fixedScale, fixedRotation));

            case ElementBoundsSource.Manual:
                return((boundsProvider != null) ? boundsProvider.CreateBounds(fixedScale, fixedRotation) : null);

            default:
                throw new NotImplementedException();
            }
        }
示例#2
0
 public override ElementBounds CreateBounds(bool fixedScale, bool fixedRotation)
 {
     return(SphereBounds.Create(new Sphere(center, radius), fixedScale, fixedRotation));
 }