]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
minor optimization of R_Q1BSP_RecursiveLightInfo
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 23 Feb 2007 13:49:12 +0000 (13:49 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 23 Feb 2007 13:49:12 +0000 (13:49 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6914 d7cf8633-e32d-0410-b094-e92efae38249

gl_rsurf.c

index 5bdd7faf3a7331a5c2088689a1656c1a19f9c193..afea17db72443310ccc2387ae6ec4ece71348669 100644 (file)
@@ -556,13 +556,12 @@ void R_Q1BSP_RecursiveGetLightInfo(r_q1bsp_getlightinfo_t *info, mnode_t *node)
                if (!plane)
                        break;
                if (plane->type < 3)
-                       sides = ((info->lightmaxs[plane->type] >= plane->dist) | ((info->lightmins[plane->type] < plane->dist) << 1));
-               else
-                       sides = BoxOnPlaneSide(info->lightmins, info->lightmaxs, plane);
-               if (sides == 3)
                {
-                       // recurse front side first because the svbsp building prefers it
-                       if (PlaneDist(info->relativelightorigin, plane) > 0)
+                       if (info->lightmins[plane->type] > plane->dist)
+                               node = node->children[0];
+                       else if (info->lightmaxs[plane->type] < plane->dist)
+                               node = node->children[1];
+                       else if (info->relativelightorigin[plane->type] >= plane->dist)
                        {
                                R_Q1BSP_RecursiveGetLightInfo(info, node->children[0]);
                                node = node->children[1];
@@ -573,10 +572,28 @@ void R_Q1BSP_RecursiveGetLightInfo(r_q1bsp_getlightinfo_t *info, mnode_t *node)
                                node = node->children[0];
                        }
                }
-               else if (sides == 0)
-                       return; // ERROR: NAN bounding box!
                else
-                       node = node->children[sides - 1];
+               {
+                       sides = BoxOnPlaneSide(info->lightmins, info->lightmaxs, plane);
+                       if (sides == 3)
+                       {
+                               // recurse front side first because the svbsp building prefers it
+                               if (PlaneDist(info->relativelightorigin, plane) >= 0)
+                               {
+                                       R_Q1BSP_RecursiveGetLightInfo(info, node->children[0]);
+                                       node = node->children[1];
+                               }
+                               else
+                               {
+                                       R_Q1BSP_RecursiveGetLightInfo(info, node->children[1]);
+                                       node = node->children[0];
+                               }
+                       }
+                       else if (sides == 0)
+                               return; // ERROR: NAN bounding box!
+                       else
+                               node = node->children[sides - 1];
+               }
        }
        leaf = (mleaf_t *)node;
        if (info->svbsp_active)
@@ -659,9 +676,7 @@ void R_Q1BSP_RecursiveGetLightInfo(r_q1bsp_getlightinfo_t *info, mnode_t *node)
                                                        }
                                                        SETPVSBIT(info->outsurfacepvs, surfaceindex);
                                                        info->outsurfacelist[info->outnumsurfaces++] = surfaceindex;
-                                                       if (info->svbsp_insertoccluder)
-                                                               continue;
-                                                       else
+                                                       if (!info->svbsp_insertoccluder)
                                                                break;
                                                }
                                        }