From bfcc843cf73201373c66981d6569d84a1f034c30 Mon Sep 17 00:00:00 2001 From: uis Date: Fri, 22 Dec 2023 18:49:50 +0300 Subject: [PATCH] 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. --- tools/quake3/q3map2/surface.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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 */ -- 2.39.2