w = s->winding;
if (!w)
continue;
- ClipWindingEpsilon (w, plane->normal, plane->dist,
- 0 /*PLANESIDE_EPSILON*/, &cw[0], &cw[1]);
+ ClipWindingEpsilonStrict (w, plane->normal, plane->dist,
+ 0 /*PLANESIDE_EPSILON*/, &cw[0], &cw[1]); /* strict, in parallel case we get the face back because it also is the midwinding */
for (j=0 ; j<2 ; j++)
{
if (!cw[j])
for( i = 0; i < dp->numPlanes; i++ )
{
/* chop winding by the plane */
- ClipWindingEpsilon( w, dp->planes[ i ], dp->planes[ i ][ 3 ], 0.0625f, &front, &back );
+ ClipWindingEpsilonStrict( w, dp->planes[ i ], dp->planes[ i ][ 3 ], 0.0625f, &front, &back ); /* strict, if identical plane we don't want to keep it */
FreeWinding( w );
/* lose the front fragment */
/* switch on side */
if( side == SIDE_CROSS )
{
- ClipWindingEpsilon( split->w, plane->normal, plane->dist, CLIP_EPSILON * 2,
- &frontWinding, &backWinding );
+ ClipWindingEpsilonStrict( split->w, plane->normal, plane->dist, CLIP_EPSILON * 2,
+ &frontWinding, &backWinding ); /* strict; if no winding is left, we have a "virtually identical" plane and don't want to split by it */
if( frontWinding ) {
newFace = AllocBspFace();
newFace->w = frontWinding;
continue;
/* general case */
- ClipWindingEpsilon( w, plane->normal, plane->dist, ON_EPSILON, &front, &back );
+ ClipWindingEpsilonStrict( w, plane->normal, plane->dist, ON_EPSILON, &front, &back ); /* strict; if plane is "almost identical" to face, both ways to continue can be wrong, so we better not fog it */
FreeWinding( w );
if( back == NULL )
// cut the portal into two portals, one on each side of the cut plane
//
ClipWindingEpsilon (p->winding, plane->normal, plane->dist,
- SPLIT_WINDING_EPSILON, &frontwinding, &backwinding);
+ SPLIT_WINDING_EPSILON, &frontwinding, &backwinding); /* not strict, we want to always keep one of them even if coplanar */
if (frontwinding && WindingIsTiny(frontwinding))
{
if( (subCeil - subFloor) > subdivisions )
{
/* clip the winding */
- ClipWindingEpsilon( w, planeNormal, d, epsilon, &frontWinding, &backWinding );
+ ClipWindingEpsilon( w, planeNormal, d, epsilon, &frontWinding, &backWinding ); /* not strict; we assume we always keep a winding */
/* the clip may not produce two polygons if it was epsilon close */
if( frontWinding == NULL )
}
plane = &mapplanes[ node->planenum ];
- ClipWindingEpsilon ( w, plane->normal, plane->dist,
- ON_EPSILON, &front, &back );
+ ClipWindingEpsilonStrict ( w, plane->normal, plane->dist,
+ ON_EPSILON, &front, &back ); /* strict, we handle the "winding disappeared" case */
+ if(!front && !back)
+ {
+ /* in doubt, register it in both nodes */
+ front = CopyWinding(w);
+ back = CopyWinding(w);
+ }
FreeWinding( w );
ClipSideIntoTree_r( front, side, node->children[0] );
}
/* clip the winding by this plane */
- ClipWindingEpsilonStrict( w, plane1, plane1[ 3 ], ON_EPSILON, &front, &back );
+ ClipWindingEpsilonStrict( w, plane1, plane1[ 3 ], ON_EPSILON, &front, &back ); /* strict; we handle the "winding disappeared" case */
/* filter by this plane */
refs = 0;