From: uis Date: Fri, 22 Dec 2023 15:49:50 +0000 (+0300) Subject: Reduce patch drawsurf references X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuis%2Fpatch-culling;p=xonotic%2Fnetradiant.git Reduce patch drawsurf references If patch is definetly on one side of plane, then it is not on the other unless proven otherwise. This theoretically can mess-up with patch collision in other(than DarkPlaces) engines that use it for collision(no idea how) if part of patch is barely inside of visleaf. New behaviour needs more testing and maybe put behind flag/argument. --- diff --git a/tools/quake3/q3map2/surface.c b/tools/quake3/q3map2/surface.c index 569fbf08..e15ca8e5 100644 --- a/tools/quake3/q3map2/surface.c +++ b/tools/quake3/q3map2/surface.c @@ -2062,10 +2062,11 @@ int FilterPointIntoTree_r( vec3_t point, mapDrawSurface_t *ds, node_t *node ){ */ int FilterPointConvexHullIntoTree_r( vec3_t **points, int npoints, mapDrawSurface_t *ds, node_t *node ){ - float d, dmin, dmax; plane_t *plane; + float d, dmin, dmax; int refs = 0; int i; + qboolean infront, behind; if ( !points ) { return 0; @@ -2090,11 +2091,17 @@ int FilterPointConvexHullIntoTree_r( vec3_t **points, int npoints, mapDrawSurfac /* filter by this plane */ refs = 0; - if ( dmax >= -ON_EPSILON ) { + infront = dmax > ON_EPSILON, + behind = dmin < -ON_EPSILON; + if ( !infront && !behind ) { + /* coplanar patch */ refs += FilterPointConvexHullIntoTree_r( points, npoints, ds, node->children[ 0 ] ); - } - if ( dmin <= ON_EPSILON ) { refs += FilterPointConvexHullIntoTree_r( points, npoints, ds, node->children[ 1 ] ); + } else { + if ( infront ) /* > PLANESIDE_EPSILON? */ + refs += FilterPointConvexHullIntoTree_r( points, npoints, ds, node->children[ 0 ] ); + if ( behind ) /* < -PLANESIDE_EPSILON? */ + refs += FilterPointConvexHullIntoTree_r( points, npoints, ds, node->children[ 1 ] ); } /* return */