コード例 #1
0
            public void IncludeTopLevelNonSpatialQueryableDesendants(IList <object> topLevelObjects)
            {
                var count = topLevelObjects.Count;

                for (int i = 0; i < count; ++i)
                {
                    ContainerTraverser.Traverse(topLevelObjects[i], traverser);
                }
            }
コード例 #2
0
ファイル: Group.cs プロジェクト: Hengle/Engine-Nine
        /// <summary>
        /// Performs a depth first search and finds the first descendant object with the specified type.
        /// </summary>
        public T Find <T>() where T : class
        {
            T result = null;

            ContainerTraverser.Traverse <Object>(this, desendant =>
            {
                result = desendant as T;
                if (result != null)
                {
                    return(TraverseOptions.Stop);
                }
                result = null;
                return(TraverseOptions.Continue);
            });
            return(result);
        }
コード例 #3
0
 /// <summary>
 /// Called when a child object is removed directly from this drawing group.
 /// </summary>
 /// <param name="child"></param>
 protected override void OnRemoved(object child)
 {
     ++workingExpandablesDepth;
     ContainerTraverser.Traverse <object>(child, InternalRemove);
     if (--workingExpandablesDepth == 0)
     {
         var count = workingExpandables.Count;
         for (var i = 0; i < count; ++i)
         {
             var collectionChanged = workingExpandables[i];
             if (collectionChanged != null)
             {
                 collectionChanged.Added   -= OnDesecendantAdded;
                 collectionChanged.Removed -= OnDesecendantRemoved;
             }
         }
         workingExpandables.Clear();
     }
 }
コード例 #4
0
ファイル: Group.cs プロジェクト: Hengle/Engine-Nine
        /// <summary>
        /// Computes the axis aligned bounding box that exactly contains the bounds of all child node.
        /// </summary>
        /// <remarks>
        /// Any desendant that implements <see cref="ISpatialQueryable"/> will be included in the final bounding box.
        /// </remarks>
        public BoundingBox ComputeBounds()
        {
            var hasBoundable = false;
            var bounds       = new BoundingBox();

            ContainerTraverser.Traverse <ISpatialQueryable>(this, boundable =>
            {
                if (hasBoundable)
                {
                    var childBounds = boundable.BoundingBox;
                    BoundingBox.CreateMerged(ref bounds, ref childBounds, out bounds);
                }
                else
                {
                    bounds       = boundable.BoundingBox;
                    hasBoundable = true;
                }
                return(TraverseOptions.Continue);
            });
            return(bounds);
        }
コード例 #5
0
ファイル: Group.cs プロジェクト: Hengle/Engine-Nine
        /// <summary>
        /// Performs a depth first search and finds the first descendant object with the specified name.
        /// </summary>
        public T FindName <T>(string name) where T : class
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("name");
            }

            T result = null;

            ContainerTraverser.Traverse <Object>(this, desendant =>
            {
                result = desendant as T;
                if (result != null)
                {
                    if (desendant.name == name)
                    {
                        return(TraverseOptions.Stop);
                    }
                    result = null;
                }
                return(TraverseOptions.Continue);
            });
            return(result);
        }
コード例 #6
0
ファイル: Group.cs プロジェクト: Hengle/Engine-Nine
 /// <summary>
 /// Finds all the child objects of the target including the input target.
 /// </summary>
 public void Traverse <T>(Func <T, TraverseOptions> result) where T : class
 {
     ContainerTraverser.Traverse(this, result);
 }
コード例 #7
0
ファイル: Group.cs プロジェクト: Hengle/Engine-Nine
 /// <summary>
 /// Finds all the child objects of the target including the input target.
 /// </summary>
 public void Traverse <T>(ICollection <T> result) where T : class
 {
     ContainerTraverser.Traverse(this, result);
 }
コード例 #8
0
ファイル: Group.cs プロジェクト: Hengle/Engine-Nine
 /// <summary>
 /// Traverse up the scene tree and returns the first parent of type T.
 /// Returns the target object if it is already an instance of T.
 /// </summary>
 public T FindParent <T>() where T : class
 {
     return(ContainerTraverser.FindParentContainer <T>(this));
 }
コード例 #9
0
ファイル: Group.cs プロジェクト: Hengle/Engine-Nine
 /// <summary>
 /// Finds the root object in the scene hierarchy.
 /// </summary>
 public T FindRoot <T>() where T : class
 {
     return(ContainerTraverser.FindRootContainer(this) as T);
 }
コード例 #10
0
 public override void Add(ISpatialQueryable item)
 {
     currentItem = item;
     ContainerTraverser.Traverse(item, traverser);
     currentItem = null;
 }