FarseerPhysics.Collision.Shapes.ChainShape.setVertices C# (CSharp) Method

setVertices() public method

public setVertices ( Vertices vertices, bool createLoop = false ) : void
vertices Vertices
createLoop bool
return void
		public void setVertices( Vertices vertices, bool createLoop = false )
		{
			Debug.Assert( vertices != null && vertices.Count >= 3 );
			Debug.Assert( vertices[0] != vertices[vertices.Count - 1] ); // FPE. See http://www.box2d.org/forum/viewtopic.php?f=4&t=7973&p=35363

			for( int i = 1; i < vertices.Count; ++i )
			{
				var v1 = vertices[i - 1];
				var v2 = vertices[i];

				// If the code crashes here, it means your vertices are too close together.
				Debug.Assert( Vector2.DistanceSquared( v1, v2 ) > Settings.linearSlop * Settings.linearSlop );
			}

			this.vertices = vertices;

			if( createLoop )
			{
				this.vertices.Add( vertices[0] );
				prevVertex = this.vertices[this.vertices.Count - 2]; // FPE: We use the properties instead of the private fields here.
				nextVertex = this.vertices[1]; // FPE: We use the properties instead of the private fields here.
			}
		}