public void GetVisibleObjects(Camera camera, ICollection <T> collection, ICullTester <T> frustumTester = null)
 {
     foreach (var item in _items)
     {
         if (frustumTester != null && frustumTester.Contains(camera, item.BoundingSphere))
         {
             collection.Add(item);
         }
         else if (camera.TestFrustum(item.BoundingSphere) != FrustumTest.Outside)
         {
             collection.Add(item);
         }
     }
 }
Esempio n. 2
0
            public void CullItems(Camera camera, HashSet <T> collection, ICullTester <T> frustumTester)
            {
                if (_nbElements == 0)
                {
                    return;
                }

                var check = frustumTester != null?
                            frustumTester.GetCullState(camera, _boundSphere) :
                                camera.TestFrustum(_boundSphere);

                switch (check)
                {
                case FrustumTest.Inside:
                    GetItems(camera, collection, false, frustumTester);
                    break;

                case FrustumTest.Partial:
                    if (_items != null)
                    {
                        foreach (var item in _items)
                        {
                            if (!collection.Contains(item) && camera.Contains(item.BoundingSphere))
                            {
                                collection.Add(item);
                            }
                        }
                    }

                    if (_northWest != null && _northWest._nbElements > 0)
                    {
                        _northWest.CullItems(camera, collection, frustumTester);
                    }
                    if (_northEast != null && _northEast._nbElements > 0)
                    {
                        _northEast.CullItems(camera, collection, frustumTester);
                    }
                    if (_southWest != null && _southWest._nbElements > 0)
                    {
                        _southWest.CullItems(camera, collection, frustumTester);
                    }
                    if (_southEast != null && _southEast._nbElements > 0)
                    {
                        _southEast.CullItems(camera, collection, frustumTester);
                    }

                    break;
                }
            }
Esempio n. 3
0
        public void GetVisibleObjects(Camera camera, ICollection <T> collection, ICullTester <T> frustumTester = null)
        {
            if (_root == null)
            {
                return;
            }

            _items.Clear();
            _root.CullItems(camera, _items, frustumTester);

            foreach (var item in _items)
            {
                collection.Add(item);
            }
        }
Esempio n. 4
0
        public static bool Contains <T>(this ICullTester <T> tester, Camera camera, Sphere sphere)
        {
            var cont = tester.GetCullState(camera, sphere);

            return(cont == FrustumTest.Inside || cont == FrustumTest.Partial);
        }
Esempio n. 5
0
            private void GetItems(Camera camera, HashSet <T> collection, bool partial, ICullTester <T> frustumTester)
            {
                if (_nbElements == 0)
                {
                    return;
                }

                if (_items != null)
                {
                    foreach (var item in _items)
                    {
                        if (!collection.Contains(item))
                        {
                            if (!partial || ((frustumTester != null && frustumTester.Contains(camera, item.BoundingSphere)) || (frustumTester == null && camera.Contains(item.BoundingSphere))))
                            {
                                collection.Add(item);
                            }
                        }
                    }
                }

                if (_northWest != null)
                {
                    _northWest.GetItems(camera, collection, partial, frustumTester);
                }
                if (_northEast != null)
                {
                    _northEast.GetItems(camera, collection, partial, frustumTester);
                }
                if (_southWest != null)
                {
                    _southWest.GetItems(camera, collection, partial, frustumTester);
                }
                if (_southEast != null)
                {
                    _southEast.GetItems(camera, collection, partial, frustumTester);
                }
            }