]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Reduce patch drawsurf references uis/patch-culling
authoruis <uis9936@gmail.com>
Fri, 22 Dec 2023 15:49:50 +0000 (18:49 +0300)
committeruis <uis9936@gmail.com>
Fri, 22 Dec 2023 15:49:50 +0000 (18:49 +0300)
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

index 569fbf0811aaecbb71d5263002f49ba9a9b8e715..e15ca8e5c9c10b8a53a3a899d151fb30721d0f03 100644 (file)
@@ -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 */