-void Winding_Clip(const FixedWinding& winding, const Plane3& plane, const Plane3& clipPlane, std::size_t adjacent, FixedWinding& clipped)
-{
- PlaneClassification classification = Winding_ClassifyDistance(plane3_distance_to_point(clipPlane, winding.back().vertex), ON_EPSILON);
- PlaneClassification nextClassification;
- // for each edge
- for(std::size_t next = 0, i = winding.size()-1; next != winding.size(); i = next, ++next, classification = nextClassification)
- {
- nextClassification = Winding_ClassifyDistance(plane3_distance_to_point(clipPlane, winding[next].vertex), ON_EPSILON);
- const FixedWindingVertex& vertex = winding[i];
-
- // if first vertex of edge is ON
- if(classification == ePlaneOn)
- {
- // append first vertex to output winding
- if(nextClassification == ePlaneBack)
- {
- // this edge lies on the clip plane
- clipped.push_back(FixedWindingVertex(vertex.vertex, plane3_intersect_plane3(plane, clipPlane), adjacent));
- }
- else
- {
- clipped.push_back(vertex);
- }
- continue;
- }
-
- // if first vertex of edge is FRONT
- if(classification == ePlaneFront)
- {
- // add first vertex to output winding
- clipped.push_back(vertex);
- }
- // if second vertex of edge is ON
- if(nextClassification == ePlaneOn)
- {
- continue;
- }
- // else if second vertex of edge is same as first
- else if(nextClassification == classification)
- {
- continue;
- }
- // else if first vertex of edge is FRONT and there are only two edges
- else if(classification == ePlaneFront && winding.size() == 2)
- {
- continue;
- }
- // else first vertex is FRONT and second is BACK or vice versa
- else
- {
- // append intersection point of line and plane to output winding
- DoubleVector3 mid(line_intersect_plane(vertex.edge, clipPlane));
-
- if(classification == ePlaneFront)
- {
- // this edge lies on the clip plane
- clipped.push_back(FixedWindingVertex(mid, plane3_intersect_plane3(plane, clipPlane), adjacent));
- }
- else
- {
- clipped.push_back(FixedWindingVertex(mid, vertex.edge, vertex.adjacent));
- }
- }
- }
+void Winding_Clip( const FixedWinding& winding, const Plane3& plane, const Plane3& clipPlane, std::size_t adjacent, FixedWinding& clipped ){
+ PlaneClassification classification = Winding_ClassifyDistance( plane3_distance_to_point( clipPlane, winding.back().vertex ), ON_EPSILON );
+ PlaneClassification nextClassification;
+ // for each edge
+ for ( std::size_t next = 0, i = winding.size() - 1; next != winding.size(); i = next, ++next, classification = nextClassification )
+ {
+ nextClassification = Winding_ClassifyDistance( plane3_distance_to_point( clipPlane, winding[next].vertex ), ON_EPSILON );
+ const FixedWindingVertex& vertex = winding[i];
+
+ // if first vertex of edge is ON
+ if ( classification == ePlaneOn ) {
+ // append first vertex to output winding
+ if ( nextClassification == ePlaneBack ) {
+ // this edge lies on the clip plane
+ clipped.push_back( FixedWindingVertex( vertex.vertex, plane3_intersect_plane3( plane, clipPlane ), adjacent ) );
+ }
+ else
+ {
+ clipped.push_back( vertex );
+ }
+ continue;
+ }
+
+ // if first vertex of edge is FRONT
+ if ( classification == ePlaneFront ) {
+ // add first vertex to output winding
+ clipped.push_back( vertex );
+ }
+ // if second vertex of edge is ON
+ if ( nextClassification == ePlaneOn ) {
+ continue;
+ }
+ // else if second vertex of edge is same as first
+ else if ( nextClassification == classification ) {
+ continue;
+ }
+ // else if first vertex of edge is FRONT and there are only two edges
+ else if ( classification == ePlaneFront && winding.size() == 2 ) {
+ continue;
+ }
+ // else first vertex is FRONT and second is BACK or vice versa
+ else
+ {
+ // append intersection point of line and plane to output winding
+ DoubleVector3 mid( line_intersect_plane( vertex.edge, clipPlane ) );
+
+ if ( classification == ePlaneFront ) {
+ // this edge lies on the clip plane
+ clipped.push_back( FixedWindingVertex( mid, plane3_intersect_plane3( plane, clipPlane ), adjacent ) );
+ }
+ else
+ {
+ clipped.push_back( FixedWindingVertex( mid, vertex.edge, vertex.adjacent ) );
+ }
+ }
+ }