当前位置: 首页>>代码示例>>C#>>正文


C# RawList类代码示例

本文整理汇总了C#中RawList的典型用法代码示例。如果您正苦于以下问题:C# RawList类的具体用法?C# RawList怎么用?C# RawList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RawList类属于命名空间,在下文中一共展示了RawList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Move

		[Test] public void Move()
		{
			int[] testArray = Enumerable.Range(0, 10).ToArray();
			RawList<int> intList = new RawList<int>();

			intList.AddRange(testArray);
			intList.Move(0, 3, 1);
			CollectionAssert.AreEqual(new int[] { 0, 0, 1, 2, 4, 5, 6, 7, 8, 9 }, intList);
			intList.Clear();

			intList.AddRange(testArray);
			intList.Move(0, 3, 3);
			CollectionAssert.AreEqual(new int[] { 0, 0, 0, 0, 1, 2, 6, 7, 8, 9 }, intList);
			intList.Clear();

			intList.AddRange(testArray);
			intList.Move(0, 3, 5);
			CollectionAssert.AreEqual(new int[] { 0, 0, 0, 3, 4, 0, 1, 2, 8, 9 }, intList);
			intList.Clear();

			intList.AddRange(testArray);
			intList.Move(7, 3, -1);
			CollectionAssert.AreEqual(new int[] { 0, 1, 2, 3, 4, 5, 7, 8, 9, 0 }, intList);
			intList.Clear();

			intList.AddRange(testArray);
			intList.Move(7, 3, -3);
			CollectionAssert.AreEqual(new int[] { 0, 1, 2, 3, 7, 8, 9, 0, 0, 0 }, intList);
			intList.Clear();

			intList.AddRange(testArray);
			intList.Move(7, 3, -5);
			CollectionAssert.AreEqual(new int[] { 0, 1, 7, 8, 9, 5, 6, 0, 0, 0 }, intList);
			intList.Clear();
		}
开发者ID:Scottyaim,项目名称:duality,代码行数:35,代码来源:RawListTest.cs

示例2: GetShapeMeshData

        public static void GetShapeMeshData(EntityCollidable collidable, List<VertexPositionNormalTexture> vertices, List<ushort> indices)
        {
            var shape = collidable.Shape as ConvexShape;
            if (shape == null)
                throw new ArgumentException("Wrong shape type for this helper.");
            var vertexPositions = new BEPUutilities.Vector3[SampleDirections.Length];

            for (int i = 0; i < SampleDirections.Length; ++i)
            {
                shape.GetLocalExtremePoint(SampleDirections[i], out vertexPositions[i]);
            }

            var hullIndices = new RawList<int>();
            ConvexHullHelper.GetConvexHull(vertexPositions, hullIndices);

            var hullTriangleVertices = new RawList<BEPUutilities.Vector3>();
            foreach (int i in hullIndices)
            {
                hullTriangleVertices.Add(vertexPositions[i]);
            }

            for (ushort i = 0; i < hullTriangleVertices.Count; i += 3)
            {
                Vector3 normal = MathConverter.Convert(BEPUutilities.Vector3.Normalize(BEPUutilities.Vector3.Cross(hullTriangleVertices[i + 2] - hullTriangleVertices[i], hullTriangleVertices[i + 1] - hullTriangleVertices[i])));
                vertices.Add(new VertexPositionNormalTexture(MathConverter.Convert(hullTriangleVertices[i]), normal, new Vector2(0, 0)));
                vertices.Add(new VertexPositionNormalTexture(MathConverter.Convert(hullTriangleVertices[i + 1]), normal, new Vector2(1, 0)));
                vertices.Add(new VertexPositionNormalTexture(MathConverter.Convert(hullTriangleVertices[i + 2]), normal, new Vector2(0, 1)));
                indices.Add(i);
                indices.Add((ushort)(i + 1));
                indices.Add((ushort)(i + 2));
            }
        }
开发者ID:Raverenx,项目名称:GameEngine,代码行数:32,代码来源:DisplayConvex.cs

示例3: GeneralConvexContactManifold

 ///<summary>
 /// Constructs a new convex-convex manifold.
 ///</summary>
 public GeneralConvexContactManifold()
 {
     contacts = new RawList<Contact>(4);
     unusedContacts = new UnsafeResourcePool<Contact>(4);
     contactIndicesToRemove = new RawList<int>(4);
     pairTester = new GeneralConvexPairTester();
 }
开发者ID:Indiefreaks,项目名称:igf,代码行数:10,代码来源:GeneralConvexContactManifold.cs

示例4: GiveBack

 /// <summary>
 /// Returns a resource to the pool.
 /// </summary>
 /// <param name="list">List to return.</param>
 public static void GiveBack(RawList<RayCastResult> list)
 {
     if (SubPoolRayCastResultList == null)
         SubPoolRayCastResultList = new UnsafeResourcePool<RawList<RayCastResult>>();
     list.Clear();
     SubPoolRayCastResultList.GiveBack(list);
 }
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:11,代码来源:PhysicsThreadResources.cs

示例5: Basics

		[Test] public void Basics()
		{
			RawList<int> intList = new RawList<int>();
			intList.Add(10);
			intList.AddRange(new int[] { 17, 42, 94 });

			Assert.AreEqual(4, intList.Count);
			Assert.IsTrue(intList.Contains(42));
			Assert.AreEqual(2, intList.IndexOf(42));
			CollectionAssert.AreEqual(new int[] { 10, 17, 42, 94 }, intList);
			CollectionAssert.AreEqual(new int[] { 10, 17, 42, 94 }, intList.Data.Take(4));

			intList.ShrinkToFit();
			Assert.AreEqual(intList.Count, intList.Capacity);

			intList.Remove(42);
			Assert.AreEqual(3, intList.Count);
			Assert.IsTrue(!intList.Contains(42));
			Assert.AreEqual(-1, intList.IndexOf(42));
			CollectionAssert.AreEqual(new int[] { 10, 17, 94 }, intList);
			CollectionAssert.AreEqual(new int[] { 10, 17, 94 }, intList.Data.Take(3));

			intList.Insert(1, 100);
			CollectionAssert.AreEqual(new int[] { 10, 100, 17, 94 }, intList);
			CollectionAssert.AreEqual(new int[] { 10, 100, 17, 94 }, intList.Data.Take(4));

			intList.InsertRange(2, new int[] { 150, 200, 250, 300 });
			CollectionAssert.AreEqual(new int[] { 10, 100, 150, 200, 250, 300, 17, 94 }, intList);
			CollectionAssert.AreEqual(new int[] { 10, 100, 150, 200, 250, 300, 17, 94 }, intList.Data.Take(8));

			intList.Clear();
			Assert.AreEqual(0, intList.Count);
			Assert.IsTrue(!intList.Contains(94));
		}
开发者ID:KSLcom,项目名称:duality,代码行数:34,代码来源:RawListTest.cs

示例6: QueryVisibleRenderers

		public void QueryVisibleRenderers(IDrawDevice device, RawList<ICmpRenderer> targetList)
		{
			// Empty the cached list of visible renderers
			targetList.Count = 0;
			targetList.Reserve(this.totalRendererCount);

			// Copy references to all renderers that are visible to the target device
			int visibleCount = 0;
			ICmpRenderer[] targetData = targetList.Data;
			foreach (var pair in this.renderersByType)
			{
				ICmpRenderer[] data = pair.Value.Data;
				for (int i = 0; i < data.Length; i++)
				{
					if (i >= pair.Value.Count) break;

					if ((data[i] as Component).Active && data[i].IsVisible(device))
					{
						targetData[visibleCount] = data[i];
						visibleCount++;
					}
				}
			}
			targetList.Count = visibleCount;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:25,代码来源:DefaultRendererVisibilityStrategy.cs

示例7: ConvexHullTestDemo

        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public ConvexHullTestDemo(DemosGame game)
            : base(game)
        {
            var random = new Random(5);

            for (int i = 0; i < 500000; ++i)
            {
                List<Vector3> points = new List<Vector3>();
                for (int k = 0; k < random.Next(8, 60); k++)
                {
                    points.Add(new Vector3(-100 + 30 * (float)random.NextDouble(), 100 + 500 * (float)random.NextDouble(), 100 + 30 * (float)random.NextDouble()));
                }
                var convexHull = new ConvexHull(new Vector3(0, 7, 0), points, 10);
                Console.WriteLine(convexHull.CollisionInformation.Shape.Vertices.Count);
            }

            var vertices = new[]
            {
                new Vector3(0, -1.750886E-9f, -1.5f),
                new Vector3(1, 1, 0.5f),
                new Vector3(1, -1, 0.5f),
                new Vector3(-1, 1, 0.5f),
                new Vector3(-1, -1, 0.5f),
            };

            var hullVertices = new RawList<Vector3>();
            ConvexHullHelper.GetConvexHull(vertices, hullVertices);

            ConvexHull hull = new ConvexHull(vertices, 5);
            Space.Add(hull);

            Box ground = new Box(new Vector3(0, -.5f, 0), 50, 1, 50);
            Space.Add(ground);
            game.Camera.Position = new Vector3(0, 6, 15);
        }
开发者ID:EugenyN,项目名称:BEPUphysicsMG,代码行数:39,代码来源:ConvexHullTestDemo.cs

示例8: CollectInvolvedEntities

        /// <summary>
        /// Adds entities associated with the solver item to the involved entities list.
        /// Ensure that sortInvolvedEntities() is called at the end of the function.
        /// This allows the non-batched multithreading system to lock properly.
        /// </summary>
        protected internal override void CollectInvolvedEntities(RawList<Entity> outputInvolvedEntities)
        {
            if (connectionA != null && connectionA != WorldEntity)
                outputInvolvedEntities.Add(connectionA);

            if (connectionB != null && connectionB != WorldEntity)
                outputInvolvedEntities.Add(connectionB);
        }
开发者ID:Indiefreaks,项目名称:igf,代码行数:13,代码来源:TwoEntityConstraint.cs

示例9: AddVertexArray

		/// <summary>
		/// Adds the specified vertex array to the Canvas' buffering mechanism. As long as buffers are available, the
		/// Canvas will prefer re-using one of them over creating a new vertex array. Every vertex array will only be used once.
		/// </summary>
		/// <param name="array"></param>
		public void AddVertexArray(RawList<VertexC1P3T2> array)
		{
			if (array == null) throw new ArgumentNullException("buffer");
			if (this.dummy) return;
			if (this.vertexArraysFree.Contains(array)) return;
			if (this.vertexArraysUsed.Contains(array)) return;
			this.vertexArraysFree.Add(array);
		}
开发者ID:undue,项目名称:duality,代码行数:13,代码来源:CanvasBuffer.cs

示例10: BroadPhaseRemovalTestDemo

        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public BroadPhaseRemovalTestDemo(DemosGame game)
            : base(game)
        {
            Entity toAdd;
            //BoundingBox box = new BoundingBox(new Vector3(-5, 1, 1), new Vector3(5, 7, 7));
            BoundingBox box = new BoundingBox(new Vector3(-500, -500, -500), new Vector3(500, 500, 500));

            DynamicHierarchy dh = new DynamicHierarchy();

            Random rand = new Random(0);

            RawList<Entity> entities = new RawList<Entity>();
            for (int k = 0; k < 1000; k++)
            {
                Vector3 position = new Vector3((float)(rand.NextDouble() * (box.Max.X - box.Min.X) + box.Min.X),
                                               (float)(rand.NextDouble() * (box.Max.Y - box.Min.Y) + box.Min.Y),
                                               (float)(rand.NextDouble() * (box.Max.Z - box.Min.Z) + box.Min.Z));
                toAdd = new Box(MathConverter.Convert(position), 1, 1, 1, 1);

                entities.Add(toAdd);

            }

            testResults = new double[2];
            int runCount = 10;
            for (int k = 0; k < runCount; k++)
            {

                for (int i = 0; i < entities.Count; i++)
                {
                    dh.Add(entities[i].CollisionInformation);
                }

                long start = Stopwatch.GetTimestamp();
                for (int i = 0; i < entities.Count; i++)
                {
                    //dh.RemoveFast(entities[i].CollisionInformation);
                }
                long end = Stopwatch.GetTimestamp();
                testResults[0] += (end - start) / (double)Stopwatch.Frequency;

                for (int i = 0; i < entities.Count; i++)
                {
                    dh.Add(entities[i].CollisionInformation);
                }

                start = Stopwatch.GetTimestamp();
                for (int i = 0; i < entities.Count; i++)
                {
                    //dh.RemoveBrute(entities[i].CollisionInformation);
                }
                end = Stopwatch.GetTimestamp();
                testResults[1] += (end - start) / (double)Stopwatch.Frequency;

            }
            testResults[0] /= runCount;
            testResults[1] /= runCount;
        }
开发者ID:Raverenx,项目名称:GameEngine,代码行数:62,代码来源:BroadPhaseRemovalTestDemo.cs

示例11: AveragePoints

 ///<summary>
 /// Averages together all the points in the point list.
 ///</summary>
 ///<param name="pointContributions">Point list to average.</param>
 ///<returns>Averaged point.</returns>
 public static Vector3 AveragePoints(RawList<Vector3> pointContributions)
 {
     var center = new Vector3();
     for (int i = 0; i < pointContributions.Count; i++)
     {
         center += pointContributions[i]; //Every point has equal weight.
     }
     return center / pointContributions.Count;
 }
开发者ID:Indiefreaks,项目名称:igf,代码行数:14,代码来源:InertiaHelper.cs

示例12: CollectInvolvedEntities

 protected internal override void CollectInvolvedEntities(RawList<Entity> outputInvolvedEntities)
 {
     //The default implementation for solver groups looks at every single subconstraint.
     //That's not necessary for these special constraints.
     if (entityA != null)
         outputInvolvedEntities.Add(entityA);
     if (entityB != null)
         outputInvolvedEntities.Add(entityB);
 }
开发者ID:rc183,项目名称:igf,代码行数:9,代码来源:ContactManifoldConstraint.cs

示例13: EditTilesetTileInputAction

        public EditTilesetTileInputAction(Tileset tileset, RawList<TileInput> tileInput, RawList<bool> tileInputMask)
        {
            if (tileset == null) throw new ArgumentNullException("tileset");
            if (tileInput == null) throw new ArgumentNullException("tileInput");
            if (tileInputMask == null) throw new ArgumentNullException("tileInputMask");
            if (tileInputMask.Count != tileInput.Count) throw new ArgumentException("Input Mask needs to be the same size as input.", "tileInputMask");

            this.tileset = tileset;
            this.tileInput = tileInput;
            this.tileInputMask = tileInputMask;
        }
开发者ID:SirePi,项目名称:duality,代码行数:11,代码来源:EditTilesetTileInputAction.cs

示例14: ConvexHullShape

        ///<summary>
        /// Constructs a new convex hull shape.
        /// The point set will be recentered on the local origin.
        ///</summary>
        ///<param name="vertices">Point set to use to construct the convex hull.</param>
        /// <param name="center">Computed center of the convex hull shape prior to recentering.</param>
        /// <param name="outputHullTriangleIndices">Triangle indices computed on the surface of the point set.</param>
        /// <param name="outputUniqueSurfaceVertices">Unique vertices on the surface of the convex hull.</param>
        ///<exception cref="ArgumentException">Thrown when the point set is empty.</exception>
        public ConvexHullShape(IList<Vector3> vertices, out Vector3 center, IList<int> outputHullTriangleIndices, IList<Vector3> outputUniqueSurfaceVertices)
        {
            if (vertices.Count == 0)
                throw new ArgumentException("Vertices list used to create a ConvexHullShape cannot be empty.");


            //Ensure that the convex hull is centered on its local origin.
            center = ComputeCenter(vertices, outputHullTriangleIndices, outputUniqueSurfaceVertices);
            this.vertices = new RawList<Vector3>(outputUniqueSurfaceVertices);

            OnShapeChanged();
        }
开发者ID:VICOGameStudio-Ujen,项目名称:igf,代码行数:21,代码来源:ConvexHullShape.cs

示例15: RemoveRenderer

		public void RemoveRenderer(ICmpRenderer renderer)
		{
			Type type = renderer.GetType();
			RawList<ICmpRenderer> list;
			if (!this.renderersByType.TryGetValue(type, out list))
			{
				list = new RawList<ICmpRenderer>();
				this.renderersByType.Add(type, list);
			}
			list.Remove(renderer);
			this.totalRendererCount--;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:12,代码来源:DefaultRendererVisibilityStrategy.cs


注:本文中的RawList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。