src/Matter/World.js
function (tiles) {
		const maxDist = 5;
		const directNeighbours = ['up', 'down', 'left', 'right'];
		
		let t, tile, n, neighbour, i, j, tv, nv, tn, nn;
		
		for (t = 0; t < tiles.length; t++) {
			tile = tiles[t];
			
			// Skip over irrelevant tiles
			if (isIrrelevant(tile)) {
				continue;
			}
			
			// Grab the tile's body and vertices to compare with its neighbours
			let tileBody = tile.physics.matterBody.body;
			let tileVertices = tileBody.vertices;
			
			// Iterate over each direct neighbour
			for (n in directNeighbours) {
				neighbour = tile.physics.slopes.neighbours[directNeighbours[n]];
				
				// Skip over irrelevant neighbouring tiles
				if (isIrrelevant(neighbour)) {
					continue;
				}
				
				// Grab the neighbour's body and vertices
				let neighbourBody = neighbour.physics.matterBody.body;
				let neighbourVertices = neighbourBody.vertices;
				
				// Skip over tile-neighbour pairs that don't overlap
				if (!Bounds.overlaps(tileBody.bounds, neighbourBody.bounds)) {
					continue;
				}
				
				tv = tileVertices;
				nv = neighbourVertices;
				tn = tileBody.axes;
				nn = neighbourBody.axes;
				
				// Iterate over the vertices of both the tile and its neighbour
				for (i = 0; i < tv.length; i++) {
					for (j = 0; j < nv.length; j++) {
						// Find distances between the vertices
						let da = Vector.magnitudeSquared(Vector.sub(tv[(i + 1) % tv.length], nv[j])),
							db = Vector.magnitudeSquared(Vector.sub(tv[i], nv[(j + 1) % nv.length]));
						
						// If both vertices are very close, consider the edge coincident (internal)
						if (da < maxDist && db < maxDist) {
							tv[i].isInternal = true;
							nv[j].isInternal = true;
							tn[i].ignore = true;
							nn[j].ignore = true;
						}
					}
				}
			}
		}
	}
function (tiles) {
		const maxDist = 5;
		const directNeighbours = ['up', 'down', 'left', 'right'];
		
		let t, tile, n, neighbour, i, j, tv, nv, tn, nn;
		
		for (t = 0; t < tiles.length; t++) {
			tile = tiles[t];
			
			// Skip over irrelevant tiles
			if (isIrrelevant(tile)) {
				continue;
			}
			
			// Grab the tile's body and vertices to compare with its neighbours
			let tileBody = tile.physics.matterBody.body;
			let tileVertices = tileBody.vertices;
			
			// Iterate over each direct neighbour
			for (n in directNeighbours) {
				neighbour = tile.physics.slopes.neighbours[directNeighbours[n]];
				
				// Skip over irrelevant neighbouring tiles
				if (isIrrelevant(neighbour)) {
					continue;
				}
				
				// Grab the neighbour's body and vertices
				let neighbourBody = neighbour.physics.matterBody.body;
				let neighbourVertices = neighbourBody.vertices;
				
				// Skip over tile-neighbour pairs that don't overlap
				if (!Bounds.overlaps(tileBody.bounds, neighbourBody.bounds)) {
					continue;
				}
				
				tv = tileVertices;
				nv = neighbourVertices;
				tn = tileBody.axes;
				nn = neighbourBody.axes;
				
				// Iterate over the vertices of both the tile and its neighbour
				for (i = 0; i < tv.length; i++) {
					for (j = 0; j < nv.length; j++) {
						// Find distances between the vertices
						let da = Vector.magnitudeSquared(Vector.sub(tv[(i + 1) % tv.length], nv[j])),
							db = Vector.magnitudeSquared(Vector.sub(tv[i], nv[(j + 1) % nv.length]));
						
						// If both vertices are very close, consider the edge coincident (internal)
						if (da < maxDist && db < maxDist) {
							tv[i].isInternal = true;
							nv[j].isInternal = true;
							tn[i].ignore = true;
							nn[j].ignore = true;
						}
					}
				}
			}
		}
	}
function ( tiles ) { const maxDist = 5 ; const directNeighbours = [ 'up' , 'down' , 'left' , 'right' ] ; let t , tile , n , neighbour , i , j , tv , nv , tn , nn ; for ( t = 0 ; t < tiles . length ; t ++ ) { tile = tiles [ t ] ; // Skip over irrelevant tiles if ( isIrrelevant ( tile ) ) { continue ; } // Grab the tile's body and vertices to compare with its neighbours let tileBody = tile . physics . matterBody . body ; let tileVertices = tileBody . vertices ; // Iterate over each direct neighbour for ( n in directNeighbours ) { neighbour = tile . physics . slopes . neighbours [ directNeighbours [ n ] ] ; // Skip over irrelevant neighbouring tiles if ( isIrrelevant ( neighbour ) ) { continue ; } // Grab the neighbour's body and vertices let neighbourBody = neighbour . physics . matterBody . body ; let neighbourVertices = neighbourBody . vertices ; // Skip over tile-neighbour pairs that don't overlap if ( ! Bounds . overlaps ( tileBody . bounds , neighbourBody . bounds ) ) { continue ; } tv = tileVertices ; nv = neighbourVertices ; tn = tileBody . axes ; nn = neighbourBody . axes ; // Iterate over the vertices of both the tile and its neighbour for ( i = 0 ; i < tv . length ; i ++ ) { for ( j = 0 ; j < nv . length ; j ++ ) { // Find distances between the vertices let da = Vector . magnitudeSquared ( Vector . sub ( tv [ ( i + 1 ) % tv . length ] , nv [ j ] ) ) , db = Vector . magnitudeSquared ( Vector . sub ( tv [ i ] , nv [ ( j + 1 ) % nv . length ] ) ) ; // If both vertices are very close, consider the edge coincident (internal) if ( da < maxDist && db < maxDist ) { tv [ i ] . isInternal = true ; nv [ j ] . isInternal = true ; tn [ i ] . ignore = true ; nn [ j ] . ignore = true ; } } } } } }
Flag the internal edges of each tile.

Compares the edges of the given tiles with their direct neighbours and
flags those that match.

Because the polygons are represented by a set of vertices, instead of
actual edges, the first vector (assuming they are specified clockwise)
of each edge is flagged instead.

The same applies for edge normals, and these are also flagged to be
ignored in line with their respective vertices.

@param {Phaser.Tilemaps.Tile[]} tiles - The tiles to flag edges for.
Flag the internal edges of each tile .