34 } |
34 } |
35 |
35 |
36 /* |
36 /* |
37 * Inverts the winding of a polygon. |
37 * Inverts the winding of a polygon. |
38 */ |
38 */ |
39 void gl::invert(gl::Polygon& polygon) |
39 void gl::invert(PolygonElement& polygon) |
40 { |
40 { |
41 switch (polygon.numPolygonVertices()) |
41 visitPolygon<void>( |
42 { |
42 [](LineSegment&) {}, |
43 case 2: |
43 [](Triangle& tri) { |
44 case 3: |
44 std::swap(tri.p1, tri.p2); |
45 // 0 1 => 1 0 |
45 }, |
46 // 0 1 2 => 1 0 2 |
46 [](Quadrilateral& quad) { |
47 std::swap(polygon.vertices[0], polygon.vertices[1]); |
47 std::swap(quad.p1, quad.p3); |
48 break; |
48 }, |
49 case 4: |
49 [](ConditionalEdge&) {}, |
50 // 0 1 2 3 => 0 3 2 1 |
50 polygon); |
51 std::swap(polygon.vertices[1], polygon.vertices[3]); |
|
52 break; |
|
53 } |
|
54 } |
51 } |