+ // we have created a valid plane, compute extra info
+ PlaneClassify(&plane);
+ // copy the plane
+ r_shadow_rtlight_frustumplanes[r_shadow_rtlight_numfrustumplanes++] = plane;
+#if 1
+ // if we've found 5 frustum planes then we have constructed a
+ // proper split-side case and do not need to keep searching for
+ // planes to enclose the light origin
+ if (r_shadow_rtlight_numfrustumplanes == 5)
+ break;
+#endif
+ }
+ }
+#endif
+
+#if 0
+ for (i = 0;i < r_shadow_rtlight_numfrustumplanes;i++)
+ {
+ plane = r_shadow_rtlight_frustumplanes[i];
+ Con_Printf("light %p plane #%i %f %f %f : %f (%f %f %f %f %f)\n", rtlight, i, plane.normal[0], plane.normal[1], plane.normal[2], plane.dist, PlaneDiff(r_view.frustumcorner[0], &plane), PlaneDiff(r_view.frustumcorner[1], &plane), PlaneDiff(r_view.frustumcorner[2], &plane), PlaneDiff(r_view.frustumcorner[3], &plane), PlaneDiff(rtlight->shadoworigin, &plane));
+ }
+#endif
+
+#if 0
+ // now add the light-space box planes if the light box is rotated, as any
+ // caster outside the oriented light box is irrelevant (even if it passed
+ // the worldspace light box, which is axial)
+ if (rtlight->matrix_lighttoworld.m[0][0] != 1 || rtlight->matrix_lighttoworld.m[1][1] != 1 || rtlight->matrix_lighttoworld.m[2][2] != 1)
+ {
+ for (i = 0;i < 6;i++)
+ {
+ vec3_t v;
+ VectorClear(v);
+ v[i >> 1] = (i & 1) ? -1 : 1;
+ Matrix4x4_Transform(&rtlight->matrix_lighttoworld, v, plane.normal);
+ VectorSubtract(plane.normal, rtlight->shadoworigin, plane.normal);
+ plane.dist = VectorNormalizeLength(plane.normal);
+ plane.dist += DotProduct(plane.normal, rtlight->shadoworigin);
+ r_shadow_rtlight_frustumplanes[r_shadow_rtlight_numfrustumplanes++] = plane;
+ }
+ }
+#endif
+
+#if 0
+ // add the world-space reduced box planes
+ for (i = 0;i < 6;i++)
+ {
+ VectorClear(plane.normal);
+ plane.normal[i >> 1] = (i & 1) ? -1 : 1;
+ plane.dist = (i & 1) ? -r_shadow_rtlight_cullmaxs[i >> 1] : r_shadow_rtlight_cullmins[i >> 1];
+ r_shadow_rtlight_frustumplanes[r_shadow_rtlight_numfrustumplanes++] = plane;
+ }
+#endif
+
+#if 0
+ {
+ int j, oldnum;
+ vec3_t points[8];
+ vec_t bestdist;
+ // reduce all plane distances to tightly fit the rtlight cull box, which
+ // is in worldspace
+ VectorSet(points[0], r_shadow_rtlight_cullmins[0], r_shadow_rtlight_cullmins[1], r_shadow_rtlight_cullmins[2]);
+ VectorSet(points[1], r_shadow_rtlight_cullmaxs[0], r_shadow_rtlight_cullmins[1], r_shadow_rtlight_cullmins[2]);
+ VectorSet(points[2], r_shadow_rtlight_cullmins[0], r_shadow_rtlight_cullmaxs[1], r_shadow_rtlight_cullmins[2]);
+ VectorSet(points[3], r_shadow_rtlight_cullmaxs[0], r_shadow_rtlight_cullmaxs[1], r_shadow_rtlight_cullmins[2]);
+ VectorSet(points[4], r_shadow_rtlight_cullmins[0], r_shadow_rtlight_cullmins[1], r_shadow_rtlight_cullmaxs[2]);
+ VectorSet(points[5], r_shadow_rtlight_cullmaxs[0], r_shadow_rtlight_cullmins[1], r_shadow_rtlight_cullmaxs[2]);
+ VectorSet(points[6], r_shadow_rtlight_cullmins[0], r_shadow_rtlight_cullmaxs[1], r_shadow_rtlight_cullmaxs[2]);
+ VectorSet(points[7], r_shadow_rtlight_cullmaxs[0], r_shadow_rtlight_cullmaxs[1], r_shadow_rtlight_cullmaxs[2]);
+ oldnum = r_shadow_rtlight_numfrustumplanes;
+ r_shadow_rtlight_numfrustumplanes = 0;
+ for (j = 0;j < oldnum;j++)
+ {
+ // find the nearest point on the box to this plane
+ bestdist = DotProduct(r_shadow_rtlight_frustumplanes[j].normal, points[0]);
+ for (i = 1;i < 8;i++)
+ {
+ dist = DotProduct(r_shadow_rtlight_frustumplanes[j].normal, points[i]);
+ if (bestdist > dist)
+ bestdist = dist;