summaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/code.google.com/p/draw2d/draw2d/raster/polygon.go
blob: 2a19e73554190f048d489d7d58b151448ca7998a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
// Copyright 2011 The draw2d Authors. All rights reserved.
// created: 27/05/2011 by Laurent Le Goff
package raster

const (
	POLYGON_CLIP_NONE = iota
	POLYGON_CLIP_LEFT
	POLYGON_CLIP_RIGHT
	POLYGON_CLIP_TOP
	POLYGON_CLIP_BOTTOM
)

type Polygon []float64

type PolygonEdge struct {
	X, Slope            float64
	FirstLine, LastLine int
	Winding             int16
}

//! A more optimized representation of a polygon edge.
type PolygonScanEdge struct {
	FirstLine, LastLine int
	Winding             int16
	X                   Fix
	Slope               Fix
	SlopeFix            Fix
	NextEdge            *PolygonScanEdge
}

//! Calculates the edges of the polygon with transformation and clipping to edges array.
/*! \param startIndex the index for the first vertex.
 *  \param vertexCount the amount of vertices to convert.
 *  \param edges the array for result edges. This should be able to contain 2*aVertexCount edges.
 *  \param tr the transformation matrix for the polygon.
 *  \param aClipRectangle the clip rectangle.
 *  \return the amount of edges in the result.
 */
func (p Polygon) getEdges(startIndex, vertexCount int, edges []PolygonEdge, tr [6]float64, clipBound [4]float64) int {
	startIndex = startIndex * 2
	endIndex := startIndex + vertexCount*2
	if endIndex > len(p) {
		endIndex = len(p)
	}

	x := p[startIndex]
	y := p[startIndex+1]
	// inline transformation
	prevX := x*tr[0] + y*tr[2] + tr[4]
	prevY := x*tr[1] + y*tr[3] + tr[5]

	//! Calculates the clip flags for a point.
	prevClipFlags := POLYGON_CLIP_NONE
	if prevX < clipBound[0] {
		prevClipFlags |= POLYGON_CLIP_LEFT
	} else if prevX >= clipBound[2] {
		prevClipFlags |= POLYGON_CLIP_RIGHT
	}

	if prevY < clipBound[1] {
		prevClipFlags |= POLYGON_CLIP_TOP
	} else if prevY >= clipBound[3] {
		prevClipFlags |= POLYGON_CLIP_BOTTOM
	}

	edgeCount := 0
	var k, clipFlags, clipSum, clipUnion int
	var xleft, yleft, xright, yright, oldY, maxX, minX float64
	var swapWinding int16
	for n := startIndex; n < endIndex; n = n + 2 {
		k = (n + 2) % len(p)
		x = p[k]*tr[0] + p[k+1]*tr[2] + tr[4]
		y = p[k]*tr[1] + p[k+1]*tr[3] + tr[5]

		//! Calculates the clip flags for a point.
		clipFlags = POLYGON_CLIP_NONE
		if prevX < clipBound[0] {
			clipFlags |= POLYGON_CLIP_LEFT
		} else if prevX >= clipBound[2] {
			clipFlags |= POLYGON_CLIP_RIGHT
		}
		if prevY < clipBound[1] {
			clipFlags |= POLYGON_CLIP_TOP
		} else if prevY >= clipBound[3] {
			clipFlags |= POLYGON_CLIP_BOTTOM
		}

		clipSum = prevClipFlags | clipFlags
		clipUnion = prevClipFlags & clipFlags

		// Skip all edges that are either completely outside at the top or at the bottom.
		if clipUnion&(POLYGON_CLIP_TOP|POLYGON_CLIP_BOTTOM) == 0 {
			if clipUnion&POLYGON_CLIP_RIGHT != 0 {
				// Both clip to right, edge is a vertical line on the right side
				if getVerticalEdge(prevY, y, clipBound[2], &edges[edgeCount], clipBound) {
					edgeCount++
				}
			} else if clipUnion&POLYGON_CLIP_LEFT != 0 {
				// Both clip to left, edge is a vertical line on the left side
				if getVerticalEdge(prevY, y, clipBound[0], &edges[edgeCount], clipBound) {
					edgeCount++
				}
			} else if clipSum&(POLYGON_CLIP_RIGHT|POLYGON_CLIP_LEFT) == 0 {
				// No clipping in the horizontal direction
				if getEdge(prevX, prevY, x, y, &edges[edgeCount], clipBound) {
					edgeCount++
				}
			} else {
				// Clips to left or right or both.

				if x < prevX {
					xleft, yleft = x, y
					xright, yright = prevX, prevY
					swapWinding = -1
				} else {
					xleft, yleft = prevX, prevY
					xright, yright = x, y
					swapWinding = 1
				}

				slope := (yright - yleft) / (xright - xleft)

				if clipSum&POLYGON_CLIP_RIGHT != 0 {
					// calculate new position for the right vertex
					oldY = yright
					maxX = clipBound[2]

					yright = yleft + (maxX-xleft)*slope
					xright = maxX

					// add vertical edge for the overflowing part
					if getVerticalEdge(yright, oldY, maxX, &edges[edgeCount], clipBound) {
						edges[edgeCount].Winding *= swapWinding
						edgeCount++
					}
				}

				if clipSum&POLYGON_CLIP_LEFT != 0 {
					// calculate new position for the left vertex
					oldY = yleft
					minX = clipBound[0]

					yleft = yleft + (minX-xleft)*slope
					xleft = minX

					// add vertical edge for the overflowing part
					if getVerticalEdge(oldY, yleft, minX, &edges[edgeCount], clipBound) {
						edges[edgeCount].Winding *= swapWinding
						edgeCount++
					}
				}

				if getEdge(xleft, yleft, xright, yright, &edges[edgeCount], clipBound) {
					edges[edgeCount].Winding *= swapWinding
					edgeCount++
				}
			}
		}

		prevClipFlags = clipFlags
		prevX = x
		prevY = y
	}

	return edgeCount
}

//! Creates a polygon edge between two vectors.
/*! Clips the edge vertically to the clip rectangle. Returns true for edges that
 *  should be rendered, false for others.
 */
func getEdge(x0, y0, x1, y1 float64, edge *PolygonEdge, clipBound [4]float64) bool {
	var startX, startY, endX, endY float64
	var winding int16

	if y0 <= y1 {
		startX = x0
		startY = y0
		endX = x1
		endY = y1
		winding = 1
	} else {
		startX = x1
		startY = y1
		endX = x0
		endY = y0
		winding = -1
	}

	// Essentially, firstLine is floor(startY + 1) and lastLine is floor(endY).
	// These are refactored to integer casts in order to avoid function
	// calls. The difference with integer cast is that numbers are always
	// rounded towards zero. Since values smaller than zero get clipped away,
	// only coordinates between 0 and -1 require greater attention as they
	// also round to zero. The problems in this range can be avoided by
	// adding one to the values before conversion and subtracting after it.

	firstLine := int(startY + 1)
	lastLine := int(endY+1) - 1

	minClip := int(clipBound[1])
	maxClip := int(clipBound[3])

	// If start and end are on the same line, the edge doesn't cross
	// any lines and thus can be ignored.
	// If the end is smaller than the first line, edge is out.
	// If the start is larger than the last line, edge is out.
	if firstLine > lastLine || lastLine < minClip || firstLine >= maxClip {
		return false
	}

	// Adjust the start based on the target.
	if firstLine < minClip {
		firstLine = minClip
	}

	if lastLine >= maxClip {
		lastLine = maxClip - 1
	}
	edge.Slope = (endX - startX) / (endY - startY)
	edge.X = startX + (float64(firstLine)-startY)*edge.Slope
	edge.Winding = winding
	edge.FirstLine = firstLine
	edge.LastLine = lastLine

	return true
}

//! Creates a vertical polygon edge between two y values.
/*! Clips the edge vertically to the clip rectangle. Returns true for edges that
 *  should be rendered, false for others.
 */
func getVerticalEdge(startY, endY, x float64, edge *PolygonEdge, clipBound [4]float64) bool {
	var start, end float64
	var winding int16
	if startY < endY {
		start = startY
		end = endY
		winding = 1
	} else {
		start = endY
		end = startY
		winding = -1
	}

	firstLine := int(start + 1)
	lastLine := int(end+1) - 1

	minClip := int(clipBound[1])
	maxClip := int(clipBound[3])

	// If start and end are on the same line, the edge doesn't cross
	// any lines and thus can be ignored.
	// If the end is smaller than the first line, edge is out.
	// If the start is larger than the last line, edge is out.
	if firstLine > lastLine || lastLine < minClip || firstLine >= maxClip {
		return false
	}

	// Adjust the start based on the clip rect.
	if firstLine < minClip {
		firstLine = minClip
	}
	if lastLine >= maxClip {
		lastLine = maxClip - 1
	}

	edge.Slope = 0
	edge.X = x
	edge.Winding = winding
	edge.FirstLine = firstLine
	edge.LastLine = lastLine

	return true
}

type VertexData struct {
	X, Y      float64
	ClipFlags int
	Line      int
}

//! Calculates the edges of the polygon with transformation and clipping to edges array.
/*! Note that this may return upto three times the amount of edges that the polygon has vertices,
 *  in the unlucky case where both left and right side get clipped for all edges.
 *  \param edges the array for result edges. This should be able to contain 2*aVertexCount edges.
 *  \param aTransformation the transformation matrix for the polygon.
 *  \param aClipRectangle the clip rectangle.
 *  \return the amount of edges in the result.
 */
func (p Polygon) getScanEdges(edges []PolygonScanEdge, tr [6]float64, clipBound [4]float64) int {
	var n int
	vertexData := make([]VertexData, len(p)/2+1)
	for n = 0; n < len(vertexData)-1; n = n + 1 {
		k := n * 2
		vertexData[n].X = p[k]*tr[0] + p[k+1]*tr[2] + tr[4]
		vertexData[n].Y = p[k]*tr[1] + p[k+1]*tr[3] + tr[5]
		// Calculate clip flags for all vertices.
		vertexData[n].ClipFlags = POLYGON_CLIP_NONE
		if vertexData[n].X < clipBound[0] {
			vertexData[n].ClipFlags |= POLYGON_CLIP_LEFT
		} else if vertexData[n].X >= clipBound[2] {
			vertexData[n].ClipFlags |= POLYGON_CLIP_RIGHT
		}
		if vertexData[n].Y < clipBound[1] {
			vertexData[n].ClipFlags |= POLYGON_CLIP_TOP
		} else if vertexData[n].Y >= clipBound[3] {
			vertexData[n].ClipFlags |= POLYGON_CLIP_BOTTOM
		}

		// Calculate line of the vertex. If the vertex is clipped by top or bottom, the line
		// is determined by the clip rectangle.
		if vertexData[n].ClipFlags&POLYGON_CLIP_TOP != 0 {
			vertexData[n].Line = int(clipBound[1])
		} else if vertexData[n].ClipFlags&POLYGON_CLIP_BOTTOM != 0 {
			vertexData[n].Line = int(clipBound[3] - 1)
		} else {
			vertexData[n].Line = int(vertexData[n].Y+1) - 1
		}
	}

	// Copy the data from 0 to the last entry to make the data to loop.
	vertexData[len(vertexData)-1] = vertexData[0]

	// Transform the first vertex; store.
	// Process mVertexCount - 1 times, next is n+1
	// copy the first vertex to
	// Process 1 time, next is n

	edgeCount := 0
	for n = 0; n < len(vertexData)-1; n++ {
		clipSum := vertexData[n].ClipFlags | vertexData[n+1].ClipFlags
		clipUnion := vertexData[n].ClipFlags & vertexData[n+1].ClipFlags

		if clipUnion&(POLYGON_CLIP_TOP|POLYGON_CLIP_BOTTOM) == 0 &&
			vertexData[n].Line != vertexData[n+1].Line {
			var startIndex, endIndex int
			var winding int16
			if vertexData[n].Y < vertexData[n+1].Y {
				startIndex = n
				endIndex = n + 1
				winding = 1
			} else {
				startIndex = n + 1
				endIndex = n
				winding = -1
			}

			firstLine := vertexData[startIndex].Line + 1
			lastLine := vertexData[endIndex].Line

			if clipUnion&POLYGON_CLIP_RIGHT != 0 {
				// Both clip to right, edge is a vertical line on the right side
				edges[edgeCount].FirstLine = firstLine
				edges[edgeCount].LastLine = lastLine
				edges[edgeCount].Winding = winding
				edges[edgeCount].X = Fix(clipBound[2] * FIXED_FLOAT_COEF)
				edges[edgeCount].Slope = 0
				edges[edgeCount].SlopeFix = 0

				edgeCount++
			} else if clipUnion&POLYGON_CLIP_LEFT != 0 {
				// Both clip to left, edge is a vertical line on the left side
				edges[edgeCount].FirstLine = firstLine
				edges[edgeCount].LastLine = lastLine
				edges[edgeCount].Winding = winding
				edges[edgeCount].X = Fix(clipBound[0] * FIXED_FLOAT_COEF)
				edges[edgeCount].Slope = 0
				edges[edgeCount].SlopeFix = 0

				edgeCount++
			} else if clipSum&(POLYGON_CLIP_RIGHT|POLYGON_CLIP_LEFT) == 0 {
				// No clipping in the horizontal direction
				slope := (vertexData[endIndex].X -
					vertexData[startIndex].X) /
					(vertexData[endIndex].Y -
						vertexData[startIndex].Y)

					// If there is vertical clip (for the top) it will be processed here. The calculation
					// should be done for all non-clipping edges as well to determine the accurate position
					// where the edge crosses the first scanline.
				startx := vertexData[startIndex].X +
					(float64(firstLine)-vertexData[startIndex].Y)*slope

				edges[edgeCount].FirstLine = firstLine
				edges[edgeCount].LastLine = lastLine
				edges[edgeCount].Winding = winding
				edges[edgeCount].X = Fix(startx * FIXED_FLOAT_COEF)
				edges[edgeCount].Slope = Fix(slope * FIXED_FLOAT_COEF)

				if lastLine-firstLine >= SLOPE_FIX_STEP {
					edges[edgeCount].SlopeFix = Fix(slope*SLOPE_FIX_STEP*FIXED_FLOAT_COEF) -
						edges[edgeCount].Slope<<SLOPE_FIX_SHIFT
				} else {
					edges[edgeCount].SlopeFix = 0
				}

				edgeCount++
			} else {
				// Clips to left or right or both.
				slope := (vertexData[endIndex].X -
					vertexData[startIndex].X) /
					(vertexData[endIndex].Y -
						vertexData[startIndex].Y)

				// The edge may clip to both left and right.
				// The clip results in one or two new vertices, and one to three segments.
				// The rounding for scanlines may produce a result where any of the segments is
				// ignored.

				// The start is always above the end. Calculate the clip positions to clipVertices.
				// It is possible that only one of the vertices exist. This will be detected from the
				// clip flags of the vertex later, so they are initialized here.
				var clipVertices [2]VertexData

				if vertexData[startIndex].X <
					vertexData[endIndex].X {
					clipVertices[0].X = clipBound[0]
					clipVertices[1].X = clipBound[2]
					clipVertices[0].ClipFlags = POLYGON_CLIP_LEFT
					clipVertices[1].ClipFlags = POLYGON_CLIP_RIGHT
				} else {
					clipVertices[0].X = clipBound[2]
					clipVertices[1].X = clipBound[0]
					clipVertices[0].ClipFlags = POLYGON_CLIP_RIGHT
					clipVertices[1].ClipFlags = POLYGON_CLIP_LEFT
				}

				var p int
				for p = 0; p < 2; p++ {
					// Check if either of the vertices crosses the edge marked for the clip vertex
					if clipSum&clipVertices[p].ClipFlags != 0 {
						// The the vertex is required, calculate it.
						clipVertices[p].Y = vertexData[startIndex].Y +
							(clipVertices[p].X-
								vertexData[startIndex].X)/slope

						// If there is clipping in the vertical direction, the new vertex may be clipped.
						if clipSum&(POLYGON_CLIP_TOP|POLYGON_CLIP_BOTTOM) != 0 {
							if clipVertices[p].Y < clipBound[1] {
								clipVertices[p].ClipFlags = POLYGON_CLIP_TOP
								clipVertices[p].Line = int(clipBound[1])
							} else if clipVertices[p].Y > clipBound[3] {
								clipVertices[p].ClipFlags = POLYGON_CLIP_BOTTOM
								clipVertices[p].Line = int(clipBound[3] - 1)
							} else {
								clipVertices[p].ClipFlags = 0
								clipVertices[p].Line = int(clipVertices[p].Y+1) - 1
							}
						} else {
							clipVertices[p].ClipFlags = 0
							clipVertices[p].Line = int(clipVertices[p].Y+1) - 1
						}
					}
				}

				// Now there are three or four vertices, in the top-to-bottom order of start, clip0, clip1,
				// end. What kind of edges are required for connecting these can be determined from the
				// clip flags.
				// -if clip vertex has horizontal clip flags, it doesn't exist. No edge is generated.
				// -if start vertex or end vertex has horizontal clip flag, the edge to/from the clip vertex is vertical
				// -if the line of two vertices is the same, the edge is not generated, since the edge doesn't
				//  cross any scanlines.

				// The alternative patterns are:
				// start - clip0 - clip1 - end
				// start - clip0 - end
				// start - clip1 - end

				var topClipIndex, bottomClipIndex int
				if (clipVertices[0].ClipFlags|clipVertices[1].ClipFlags)&
					(POLYGON_CLIP_LEFT|POLYGON_CLIP_RIGHT) == 0 {
					// Both sides are clipped, the order is start-clip0-clip1-end
					topClipIndex = 0
					bottomClipIndex = 1

					// Add the edge from clip0 to clip1
					// Check that the line is different for the vertices.
					if clipVertices[0].Line != clipVertices[1].Line {
						firstClipLine := clipVertices[0].Line + 1

						startx := vertexData[startIndex].X +
							(float64(firstClipLine)-vertexData[startIndex].Y)*slope

						edges[edgeCount].X = Fix(startx * FIXED_FLOAT_COEF)
						edges[edgeCount].Slope = Fix(slope * FIXED_FLOAT_COEF)
						edges[edgeCount].FirstLine = firstClipLine
						edges[edgeCount].LastLine = clipVertices[1].Line
						edges[edgeCount].Winding = winding

						if edges[edgeCount].LastLine-edges[edgeCount].FirstLine >= SLOPE_FIX_STEP {
							edges[edgeCount].SlopeFix = Fix(slope*SLOPE_FIX_STEP*FIXED_FLOAT_COEF) -
								edges[edgeCount].Slope<<SLOPE_FIX_SHIFT
						} else {
							edges[edgeCount].SlopeFix = 0
						}

						edgeCount++
					}
				} else {
					// Clip at either side, check which side. The clip flag is on for the vertex
					// that doesn't exist, i.e. has not been clipped to be inside the rect.
					if clipVertices[0].ClipFlags&(POLYGON_CLIP_LEFT|POLYGON_CLIP_RIGHT) != 0 {
						topClipIndex = 1
						bottomClipIndex = 1
					} else {
						topClipIndex = 0
						bottomClipIndex = 0
					}
				}

				// Generate the edges from start - clip top and clip bottom - end
				// Clip top and clip bottom may be the same vertex if there is only one 
				// clipped vertex.

				// Check that the line is different for the vertices.
				if vertexData[startIndex].Line != clipVertices[topClipIndex].Line {
					edges[edgeCount].FirstLine = firstLine
					edges[edgeCount].LastLine = clipVertices[topClipIndex].Line
					edges[edgeCount].Winding = winding

					// If startIndex is clipped, the edge is a vertical one.
					if vertexData[startIndex].ClipFlags&(POLYGON_CLIP_LEFT|POLYGON_CLIP_RIGHT) != 0 {
						edges[edgeCount].X = Fix(clipVertices[topClipIndex].X * FIXED_FLOAT_COEF)
						edges[edgeCount].Slope = 0
						edges[edgeCount].SlopeFix = 0
					} else {
						startx := vertexData[startIndex].X +
							(float64(firstLine)-vertexData[startIndex].Y)*slope

						edges[edgeCount].X = Fix(startx * FIXED_FLOAT_COEF)
						edges[edgeCount].Slope = Fix(slope * FIXED_FLOAT_COEF)

						if edges[edgeCount].LastLine-edges[edgeCount].FirstLine >= SLOPE_FIX_STEP {
							edges[edgeCount].SlopeFix = Fix(slope*SLOPE_FIX_STEP*FIXED_FLOAT_COEF) -
								edges[edgeCount].Slope<<SLOPE_FIX_SHIFT
						} else {
							edges[edgeCount].SlopeFix = 0
						}
					}

					edgeCount++
				}

				// Check that the line is different for the vertices.
				if clipVertices[bottomClipIndex].Line != vertexData[endIndex].Line {
					firstClipLine := clipVertices[bottomClipIndex].Line + 1

					edges[edgeCount].FirstLine = firstClipLine
					edges[edgeCount].LastLine = lastLine
					edges[edgeCount].Winding = winding

					// If endIndex is clipped, the edge is a vertical one.
					if vertexData[endIndex].ClipFlags&(POLYGON_CLIP_LEFT|POLYGON_CLIP_RIGHT) != 0 {
						edges[edgeCount].X = Fix(clipVertices[bottomClipIndex].X * FIXED_FLOAT_COEF)
						edges[edgeCount].Slope = 0
						edges[edgeCount].SlopeFix = 0
					} else {
						startx := vertexData[startIndex].X +
							(float64(firstClipLine)-vertexData[startIndex].Y)*slope

						edges[edgeCount].X = Fix(startx * FIXED_FLOAT_COEF)
						edges[edgeCount].Slope = Fix(slope * FIXED_FLOAT_COEF)

						if edges[edgeCount].LastLine-edges[edgeCount].FirstLine >= SLOPE_FIX_STEP {
							edges[edgeCount].SlopeFix = Fix(slope*SLOPE_FIX_STEP*FIXED_FLOAT_COEF) -
								edges[edgeCount].Slope<<SLOPE_FIX_SHIFT
						} else {
							edges[edgeCount].SlopeFix = 0
						}
					}

					edgeCount++
				}

			}
		}
	}

	return edgeCount
}