From: Rudolf Polzer Date: Wed, 23 Nov 2011 08:44:05 +0000 (+0100) Subject: audit all uses of ClipWindingEpsilon and choose the strict variant or not, and explai... X-Git-Tag: xonotic-v0.6.0~52 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6b01d68ba6e22e65795a25225a5b5ae30a38bd95;p=xonotic%2Fnetradiant.git audit all uses of ClipWindingEpsilon and choose the strict variant or not, and explain why --- diff --git a/tools/quake3/q3map2/brush.c b/tools/quake3/q3map2/brush.c index b7c50f4c..eefaa75f 100644 --- a/tools/quake3/q3map2/brush.c +++ b/tools/quake3/q3map2/brush.c @@ -1027,8 +1027,8 @@ void SplitBrush( brush_t *brush, int planenum, brush_t **front, brush_t **back ) 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]) diff --git a/tools/quake3/q3map2/decals.c b/tools/quake3/q3map2/decals.c index a130334f..b500eefd 100644 --- a/tools/quake3/q3map2/decals.c +++ b/tools/quake3/q3map2/decals.c @@ -594,7 +594,7 @@ static void ProjectDecalOntoWinding( decalProjector_t *dp, mapDrawSurface_t *ds, 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 */ diff --git a/tools/quake3/q3map2/facebsp.c b/tools/quake3/q3map2/facebsp.c index 16997842..2e4ffffe 100644 --- a/tools/quake3/q3map2/facebsp.c +++ b/tools/quake3/q3map2/facebsp.c @@ -295,8 +295,8 @@ void BuildFaceTree_r( node_t *node, face_t *list ) /* 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; diff --git a/tools/quake3/q3map2/fog.c b/tools/quake3/q3map2/fog.c index c9ee6e25..ed59d7eb 100644 --- a/tools/quake3/q3map2/fog.c +++ b/tools/quake3/q3map2/fog.c @@ -408,7 +408,7 @@ qboolean ChopFaceSurfaceByBrush( entity_t *e, mapDrawSurface_t *ds, brush_t *b ) 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 ) diff --git a/tools/quake3/q3map2/portals.c b/tools/quake3/q3map2/portals.c index 2efc1db4..e16c12c7 100644 --- a/tools/quake3/q3map2/portals.c +++ b/tools/quake3/q3map2/portals.c @@ -410,7 +410,7 @@ void SplitNodePortals (node_t *node) // 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)) { diff --git a/tools/quake3/q3map2/surface.c b/tools/quake3/q3map2/surface.c index 5914c40f..e2ec8909 100644 --- a/tools/quake3/q3map2/surface.c +++ b/tools/quake3/q3map2/surface.c @@ -1356,7 +1356,7 @@ static void SubdivideFace_r( entity_t *e, brush_t *brush, side_t *side, winding_ 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 ) @@ -1498,8 +1498,14 @@ void ClipSideIntoTree_r( winding_t *w, side_t *side, node_t *node ) } 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] ); @@ -2108,7 +2114,7 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ) } /* 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;