Пример #1
0
        [Test] public void RemoveAll()
        {
            // Remove nothing
            {
                RawList <int> list = new RawList <int>(Enumerable.Range(0, 10));
                list.RemoveAll(i => false);
                CollectionAssert.AreEqual(Enumerable.Range(0, 10), list);
            }

            // Remove everything
            {
                RawList <int> list = new RawList <int>(Enumerable.Range(0, 10));
                list.RemoveAll(i => true);
                CollectionAssert.AreEqual(new int[0], list);
            }

            // Remove all even numbers
            {
                RawList <int> list = new RawList <int>(Enumerable.Range(0, 10));
                list.RemoveAll(i => i % 2 == 0);
                CollectionAssert.AreEqual(new int[] { 1, 3, 5, 7, 9 }, list);
            }

            // Remove numbers that are in a second list with no regularity
            {
                RawList <int> list       = new RawList <int>(Enumerable.Range(0, 10));
                RawList <int> removeList = new RawList <int>(new int[] { 1, 2, 4, 5, 6, 9 });
                list.RemoveAll(i => removeList.Contains(i));
                CollectionAssert.AreEqual(new int[] { 0, 3, 7, 8 }, list);
            }
        }
Пример #2
0
        [Test] public void RemoveAll()
        {
            // Remove nothing
            {
                RawList <int> list = new RawList <int>(Enumerable.Range(0, 10));
                list.RemoveAll(i => false);
                CollectionAssert.AreEqual(Enumerable.Range(0, 10), list);
            }

            // Remove everything
            {
                RawList <int> list = new RawList <int>(Enumerable.Range(0, 10));
                list.RemoveAll(i => true);
                CollectionAssert.AreEqual(new int[0], list);
            }

            // Remove all even numbers
            {
                RawList <int> list = new RawList <int>(Enumerable.Range(0, 10));
                list.RemoveAll(i => i % 2 == 0);
                CollectionAssert.AreEqual(new int[] { 1, 3, 5, 7, 9 }, list);
            }
        }
Пример #3
0
		[Test] public void RemoveAll()
		{
			// Remove nothing
			{
				RawList<int> list = new RawList<int>(Enumerable.Range(0, 10));
				list.RemoveAll(i => false);
				CollectionAssert.AreEqual(Enumerable.Range(0, 10), list);
			}

			// Remove everything
			{
				RawList<int> list = new RawList<int>(Enumerable.Range(0, 10));
				list.RemoveAll(i => true);
				CollectionAssert.AreEqual(new int[0], list);
			}

			// Remove all even numbers
			{
				RawList<int> list = new RawList<int>(Enumerable.Range(0, 10));
				list.RemoveAll(i => i % 2 == 0);
				CollectionAssert.AreEqual(new int[] { 1, 3, 5, 7, 9 }, list);
			}
		}
Пример #4
0
        private void CollectDrawcalls()
        {
            // If no visibility groups are met, don't bother looking for renderers.
            // This is important to allow efficient drawcall injection with additional
            // "dummy" renderpasses. CamViewStates render their overlays by temporarily
            // adding 3 - 4 of these passes. Iterating over all objects again would be
            // devastating for performance and at the same time pointless.
            if ((this.drawDevice.VisibilityMask & VisibilityFlag.AllGroups) == VisibilityFlag.None)
            {
                return;
            }

            // Query renderers
            IRendererVisibilityStrategy visibilityStrategy = Scene.Current.VisibilityStrategy;
            RawList <ICmpRenderer>      visibleRenderers;

            {
                if (visibilityStrategy == null)
                {
                    return;
                }
                Profile.TimeQueryVisibleRenderers.BeginMeasure();

                visibleRenderers = new RawList <ICmpRenderer>();
                visibilityStrategy.QueryVisibleRenderers(this.drawDevice, visibleRenderers);
                if (this.editorRenderFilter.Count > 0)
                {
                    visibleRenderers.RemoveAll(r =>
                    {
                        for (int i = 0; i < this.editorRenderFilter.Count; i++)
                        {
                            if (!this.editorRenderFilter[i](r))
                            {
                                return(true);
                            }
                        }
                        return(false);
                    });
                }

                Profile.TimeQueryVisibleRenderers.EndMeasure();
            }

            // Collect drawcalls
            if (this.drawDevice.IsPicking)
            {
                this.pickingMap.AddRange(visibleRenderers);
                foreach (ICmpRenderer r in visibleRenderers)
                {
                    r.Draw(this.drawDevice);
                    this.drawDevice.PickingIndex++;
                }
            }
            else
            {
                bool profilePerType = visibilityStrategy.IsRendererQuerySorted;
                Profile.TimeCollectDrawcalls.BeginMeasure();

                Type           lastRendererType = null;
                Type           rendererType     = null;
                TimeCounter    activeProfiler   = null;
                ICmpRenderer[] data             = visibleRenderers.Data;
                for (int i = 0; i < data.Length; i++)
                {
                    if (i >= visibleRenderers.Count)
                    {
                        break;
                    }

                    // Manage profilers per Component type
                    if (profilePerType)
                    {
                        rendererType = data[i].GetType();
                        if (rendererType != lastRendererType)
                        {
                            if (activeProfiler != null)
                            {
                                activeProfiler.EndMeasure();
                            }
                            activeProfiler = Profile.RequestCounter <TimeCounter>(Profile.TimeCollectDrawcalls.FullName + @"\" + rendererType.Name);
                            activeProfiler.BeginMeasure();
                            lastRendererType = rendererType;
                        }
                    }

                    // Collect Drawcalls from this Component
                    data[i].Draw(this.drawDevice);
                }

                if (activeProfiler != null)
                {
                    activeProfiler.EndMeasure();
                }

                Profile.TimeCollectDrawcalls.EndMeasure();
            }
        }
Пример #5
0
        private void CollectDrawcalls()
        {
            // If no visibility groups are met, don't bother looking for renderers.
            // This is important to allow efficient drawcall injection with additional
            // "dummy" renderpasses. CamViewStates render their overlays by temporarily
            // adding 3 - 4 of these passes. Iterating over all objects again would be
            // devastating for performance and at the same time pointless.
            if ((this.drawDevice.VisibilityMask & VisibilityFlag.AllGroups) == VisibilityFlag.None) return;

            // Query renderers
            IRendererVisibilityStrategy visibilityStrategy = Scene.Current.VisibilityStrategy;
            RawList<ICmpRenderer> visibleRenderers;
            {
                if (visibilityStrategy == null) return;
                Profile.TimeQueryVisibleRenderers.BeginMeasure();

                visibleRenderers = new RawList<ICmpRenderer>();
                visibilityStrategy.QueryVisibleRenderers(this.drawDevice, visibleRenderers);
                if (this.editorRenderFilter.Count > 0)
                {
                    visibleRenderers.RemoveAll(r =>
                    {
                        for (int i = 0; i < this.editorRenderFilter.Count; i++)
                        {
                            if (!this.editorRenderFilter[i](r)) return true;
                        }
                        return false;
                    });
                }

                Profile.TimeQueryVisibleRenderers.EndMeasure();
            }

            // Collect drawcalls
            if (this.drawDevice.IsPicking)
            {
                this.pickingMap.AddRange(visibleRenderers);
                foreach (ICmpRenderer r in visibleRenderers)
                {
                    r.Draw(this.drawDevice);
                    this.drawDevice.PickingIndex++;
                }
            }
            else
            {
                bool profilePerType = visibilityStrategy.IsRendererQuerySorted;
                Profile.TimeCollectDrawcalls.BeginMeasure();

                Type lastRendererType = null;
                Type rendererType = null;
                TimeCounter activeProfiler = null;
                ICmpRenderer[] data = visibleRenderers.Data;
                for (int i = 0; i < data.Length; i++)
                {
                    if (i >= visibleRenderers.Count) break;

                    // Manage profilers per Component type
                    if (profilePerType)
                    {
                        rendererType = data[i].GetType();
                        if (rendererType != lastRendererType)
                        {
                            if (activeProfiler != null)
                                activeProfiler.EndMeasure();
                            activeProfiler = Profile.RequestCounter<TimeCounter>(Profile.TimeCollectDrawcalls.FullName + @"\" + rendererType.Name);
                            activeProfiler.BeginMeasure();
                            lastRendererType = rendererType;
                        }
                    }

                    // Collect Drawcalls from this Component
                    data[i].Draw(this.drawDevice);
                }

                if (activeProfiler != null)
                    activeProfiler.EndMeasure();

                Profile.TimeCollectDrawcalls.EndMeasure();
            }
        }
Пример #6
0
		private void CollectDrawcalls()
		{
			// If no visibility groups are met, don't bother looking for renderers
			if ((this.drawDevice.VisibilityMask & VisibilityFlag.AllGroups) == VisibilityFlag.None) return;

			// Query renderers
			IRendererVisibilityStrategy visibilityStrategy = Scene.Current.VisibilityStrategy;
			RawList<ICmpRenderer> visibleRenderers;
			{
				if (visibilityStrategy == null) return;
				Profile.TimeQueryVisibleRenderers.BeginMeasure();

				visibleRenderers = new RawList<ICmpRenderer>();
				visibilityStrategy.QueryVisibleRenderers(this.drawDevice, visibleRenderers);
				if (this.editorRenderFilter.Count > 0)
				{
					visibleRenderers.RemoveAll(r =>
					{
						for (int i = 0; i < this.editorRenderFilter.Count; i++)
						{
							if (!this.editorRenderFilter[i](r)) return true;
						}
						return false;
					});
				}

				Profile.TimeQueryVisibleRenderers.EndMeasure();
			}

			// Collect drawcalls
			if (this.drawDevice.IsPicking)
			{
				this.pickingMap.AddRange(visibleRenderers);
				foreach (ICmpRenderer r in visibleRenderers)
				{
					r.Draw(this.drawDevice);
					this.drawDevice.PickingIndex++;
				}
			}
			else
			{
				bool profilePerType = visibilityStrategy.IsRendererQuerySorted;
				Profile.TimeCollectDrawcalls.BeginMeasure();

				Type lastRendererType = null;
				Type rendererType = null;
				TimeCounter activeProfiler = null;
				ICmpRenderer[] data = visibleRenderers.Data;
				for (int i = 0; i < data.Length; i++)
				{
					if (i >= visibleRenderers.Count) break;

					// Manage profilers per Component type
					if (profilePerType)
					{
						rendererType = data[i].GetType();
						if (rendererType != lastRendererType)
						{
							if (activeProfiler != null)
								activeProfiler.EndMeasure();
							activeProfiler = Profile.RequestCounter<TimeCounter>(Profile.TimeCollectDrawcalls.FullName + @"\" + rendererType.Name);
							activeProfiler.BeginMeasure();
							lastRendererType = rendererType;
						}
					}

					// Collect Drawcalls from this Component
					data[i].Draw(this.drawDevice);
				}
				
				if (activeProfiler != null)
					activeProfiler.EndMeasure();

				Profile.TimeCollectDrawcalls.EndMeasure();
			}
		}
Пример #7
0
        private void CollectDrawcalls()
        {
            // If no visibility groups are met, don't bother looking for renderers
            if ((this.drawDevice.VisibilityMask & VisibilityFlag.AllGroups) == VisibilityFlag.None)
            {
                return;
            }

            // Query renderers
            IRendererVisibilityStrategy visibilityStrategy = Scene.Current.VisibilityStrategy;
            RawList <ICmpRenderer>      visibleRenderers;

            {
                if (visibilityStrategy == null)
                {
                    return;
                }
                Profile.TimeQueryVisibleRenderers.BeginMeasure();

                visibleRenderers = new RawList <ICmpRenderer>();
                visibilityStrategy.QueryVisibleRenderers(this.drawDevice, visibleRenderers);
                if (this.editorRenderFilter.Count > 0)
                {
                    visibleRenderers.RemoveAll(r =>
                    {
                        for (int i = 0; i < this.editorRenderFilter.Count; i++)
                        {
                            if (!this.editorRenderFilter[i](r))
                            {
                                return(true);
                            }
                        }
                        return(false);
                    });
                }

                Profile.TimeQueryVisibleRenderers.EndMeasure();
            }

            // Collect drawcalls
            if (this.drawDevice.IsPicking)
            {
                this.pickingMap.AddRange(visibleRenderers);
                foreach (ICmpRenderer r in visibleRenderers)
                {
                    r.Draw(this.drawDevice);
                    this.drawDevice.PickingIndex++;
                }
            }
            else
            {
                bool profilePerType = visibilityStrategy.IsRendererQuerySorted;
                Profile.TimeCollectDrawcalls.BeginMeasure();

                Type           lastRendererType = null;
                Type           rendererType     = null;
                TimeCounter    activeProfiler   = null;
                ICmpRenderer[] data             = visibleRenderers.Data;
                for (int i = 0; i < data.Length; i++)
                {
                    if (i >= visibleRenderers.Count)
                    {
                        break;
                    }

                    // Manage profilers per Component type
                    if (profilePerType)
                    {
                        rendererType = data[i].GetType();
                        if (rendererType != lastRendererType)
                        {
                            if (activeProfiler != null)
                            {
                                activeProfiler.EndMeasure();
                            }
                            activeProfiler = Profile.RequestCounter <TimeCounter>(Profile.TimeCollectDrawcalls.FullName + @"\" + rendererType.Name);
                            activeProfiler.BeginMeasure();
                            lastRendererType = rendererType;
                        }
                    }

                    // Collect Drawcalls from this Component
                    data[i].Draw(this.drawDevice);
                }

                if (activeProfiler != null)
                {
                    activeProfiler.EndMeasure();
                }

                Profile.TimeCollectDrawcalls.EndMeasure();
            }
        }