-int R_BoxVisible(const vec3_t mins, const vec3_t maxs)
-{
- int side, nodestackindex = 0;
- mnode_t *node, *nodestack[1024];
- if (R_CullBox(mins, maxs))
- return false;
- if (!r_refdef.worldmodel || !r_refdef.worldmodel->brush.data_nodes)
- return true;
- node = r_refdef.worldmodel->brush.data_nodes;
- for (;;)
- {
- if (node->plane)
- {
- // node - recurse down the BSP tree
- side = BoxOnPlaneSide(mins, maxs, node->plane) - 1;
- if (side < 2)
- {
- // box is on one side of plane, take that path
- node = node->children[side];
- }
- else
- {
- // box crosses plane, take one path and remember the other
- if (nodestackindex < 1024)
- nodestack[nodestackindex++] = node->children[0];
- node = node->children[1];
- }
- }
- else
- {
- // leaf - check leaf visibility
- if (r_worldleafvisible[(mleaf_t *)node - r_refdef.worldmodel->brush.data_leafs])
- {
- // it is visible, return immediately with the news
- return true;
- }
- else
- {
- // nothing to see here, try another path we didn't take earlier
- if (nodestackindex == 0)
- break;
- node = nodestack[--nodestackindex];
- }
- }
- }
- // it is not visible
- return false;
-}
-
-