@@ -501,55 +501,49 @@ polygon_generic(
501
501
// Needed to draw consistent polygons
502
502
xx [j ] = xx [j - 1 ];
503
503
j ++ ;
504
- } else if (current -> dx != 0 && j % 2 == 1 &&
505
- roundf ( xx [ j - 1 ]) == xx [ j - 1 ] ) {
504
+ } else if (( ymin == current -> ymin || ymin == current -> ymax ) &&
505
+ current -> dx != 0 ) {
506
506
// Connect discontiguous corners
507
507
for (k = 0 ; k < i ; k ++ ) {
508
508
Edge * other_edge = edge_table [k ];
509
- if ((current -> dx > 0 && other_edge -> dx <= 0 ) ||
510
- ( current -> dx < 0 && other_edge -> dx >= 0 ) ) {
509
+ if ((ymin != other_edge -> ymin && ymin != other_edge -> ymax ) ||
510
+ other_edge -> dx == 0 ) {
511
511
continue ;
512
512
}
513
513
// Check if the two edges join to make a corner
514
- if (xx [j - 1 ] ==
515
- (ymin - other_edge -> y0 ) * other_edge -> dx + other_edge -> x0 ) {
514
+ if (roundf (xx [j - 1 ]) ==
515
+ roundf (
516
+ (ymin - other_edge -> y0 ) * other_edge -> dx +
517
+ other_edge -> x0
518
+ )) {
516
519
// Determine points from the edges on the next row
517
520
// Or if this is the last row, check the previous row
518
- int offset = ymin == ymax ? -1 : 1 ;
521
+ int offset = ymin == current -> ymax ? -1 : 1 ;
519
522
adjacent_line_x =
520
523
(ymin + offset - current -> y0 ) * current -> dx +
521
524
current -> x0 ;
522
- adjacent_line_x_other_edge =
523
- (ymin + offset - other_edge -> y0 ) * other_edge -> dx +
524
- other_edge -> x0 ;
525
- if (ymin == current -> ymax ) {
526
- if (current -> dx > 0 ) {
527
- xx [k ] =
528
- fmax (
525
+ if (ymin + offset >= other_edge -> ymin &&
526
+ ymin + offset <= other_edge -> ymax ) {
527
+ adjacent_line_x_other_edge =
528
+ (ymin + offset - other_edge -> y0 ) * other_edge -> dx +
529
+ other_edge -> x0 ;
530
+ if (xx [j - 1 ] > adjacent_line_x + 1 &&
531
+ xx [j - 1 ] > adjacent_line_x_other_edge + 1 ) {
532
+ xx [j - 1 ] =
533
+ roundf (fmax (
529
534
adjacent_line_x , adjacent_line_x_other_edge
530
- ) +
535
+ )) +
531
536
1 ;
532
- } else {
533
- xx [k ] =
534
- fmin (
537
+ } else if (xx [j - 1 ] < adjacent_line_x - 1 &&
538
+ xx [j - 1 ] < adjacent_line_x_other_edge - 1 ) {
539
+ xx [j - 1 ] =
540
+ roundf (fmin (
535
541
adjacent_line_x , adjacent_line_x_other_edge
536
- ) -
537
- 1 ;
538
- }
539
- } else {
540
- if (current -> dx > 0 ) {
541
- xx [k ] = fmin (
542
- adjacent_line_x , adjacent_line_x_other_edge
543
- );
544
- } else {
545
- xx [k ] =
546
- fmax (
547
- adjacent_line_x , adjacent_line_x_other_edge
548
- ) +
542
+ )) -
549
543
1 ;
550
544
}
545
+ break ;
551
546
}
552
- break ;
553
547
}
554
548
}
555
549
}
0 commit comments