Example #1
0
        public IBoundingBox GetBoundingBox()
        {
            if (_boundingSphereComputed)
            {
                return(_boundingBox);
            }

            _boundingBox = _initialBoundingBox;

            _boundingBox.ExpandBy(null != ComputeBoundingBoxCallback
                ? ComputeBoundingBoxCallback(this)
                : ComputeBoundingBox());

            if (_boundingBox.Valid())
            {
                _boundingSphere.Set(_boundingBox.Center, _boundingBox.Radius);
            }
            else
            {
                _boundingSphere.Init();
            }

            _boundingSphereComputed = true;

            return(_boundingBox);
        }
Example #2
0
        /// <summary>
        /// Expand the bounding box to include the given bounding box.
        /// </summary>
        /// <param name="bb"></param>
        public void ExpandBy(IBoundingBox bb)
        {
            if (!bb.Valid())
            {
                return;
            }

            if (bb.XMin < _min.X)
            {
                _min.X = bb.XMin;
            }
            if (bb.XMax > _max.X)
            {
                _max.X = bb.XMax;
            }

            if (bb.YMin < _min.Y)
            {
                _min.Y = bb.YMin;
            }
            if (bb.YMax > _max.Y)
            {
                _max.Y = bb.YMax;
            }

            if (bb.ZMin < _min.Z)
            {
                _min.Z = bb.ZMin;
            }
            if (bb.ZMax > _max.Z)
            {
                _max.Z = bb.ZMax;
            }
        }