-int PVS_CullBox(const vec3_t mins, const vec3_t maxs)
-{
- int stackpos, sides;
- mnode_t *node, *stack[4096];
- if (cl.worldmodel == NULL)
- return false;
- stackpos = 0;
- stack[stackpos++] = cl.worldmodel->nodes;
- while (stackpos)
- {
- node = stack[--stackpos];
- if (node->contents < 0)
- {
- if (((mleaf_t *)node)->pvsframe == cl.worldmodel->pvsframecount)
- return false;
- }
- else
- {
- sides = BoxOnPlaneSide(mins, maxs, node->plane);
- if (sides & 2 && stackpos < 4096)
- stack[stackpos++] = node->children[1];
- if (sides & 1 && stackpos < 4096)
- stack[stackpos++] = node->children[0];
- }
- }
- return true;
-}
-
-int VIS_CullBox(const vec3_t mins, const vec3_t maxs)
-{
- int stackpos, sides;
- mnode_t *node, *stack[4096];
- if (R_CullBox(mins, maxs))
- return true;
- if (cl.worldmodel == NULL)
- return false;
- stackpos = 0;
- stack[stackpos++] = cl.worldmodel->nodes;
- while (stackpos)
- {
- node = stack[--stackpos];
- if (node->contents < 0)
- {
- if (((mleaf_t *)node)->visframe == r_framecount)
- return false;
- }
- else
- {
- sides = BoxOnPlaneSide(mins, maxs, node->plane);
- if (sides & 2 && stackpos < 4096)
- stack[stackpos++] = node->children[1];
- if (sides & 1 && stackpos < 4096)
- stack[stackpos++] = node->children[0];
- }
- }
- return true;
-}
-
-int R_CullSphere(const vec3_t origin, vec_t radius)
-{
- return (DotProduct(frustum[0].normal, origin) + radius < frustum[0].dist
- || DotProduct(frustum[1].normal, origin) + radius < frustum[1].dist
- || DotProduct(frustum[2].normal, origin) + radius < frustum[2].dist
- || DotProduct(frustum[3].normal, origin) + radius < frustum[3].dist);
-}
-
-int PVS_CullSphere(const vec3_t origin, vec_t radius)
-{
- int stackpos;
- mnode_t *node, *stack[4096];
- float dist;
- if (cl.worldmodel == NULL)
- return false;
- stackpos = 0;
- stack[stackpos++] = cl.worldmodel->nodes;
- while (stackpos)
- {
- node = stack[--stackpos];
- if (node->contents < 0)
- {
- if (((mleaf_t *)node)->pvsframe == cl.worldmodel->pvsframecount)
- return false;
- }
- else
- {
- dist = PlaneDiff(origin, node->plane);
- if (dist <= radius)
- stack[stackpos++] = node->children[1];
- if (dist >= -radius)
- stack[stackpos++] = node->children[0];
- }
- }
- return true;
-}
-
-int VIS_CullSphere(const vec3_t origin, vec_t radius)
-{
- int stackpos;
- mnode_t *node, *stack[4096];
- float dist;
- if (R_CullSphere(origin, radius))
- return true;
- if (cl.worldmodel == NULL)
- return false;
- stackpos = 0;
- stack[stackpos++] = cl.worldmodel->nodes;
- while (stackpos)
- {
- node = stack[--stackpos];
- if (node->contents < 0)
- {
- if (((mleaf_t *)node)->visframe == r_framecount)
- return false;
- }
- else
- {
- dist = PlaneDiff(origin, node->plane);
- if (dist <= radius)
- stack[stackpos++] = node->children[1];
- if (dist >= -radius)
- stack[stackpos++] = node->children[0];
- }
- }
- return true;
-}
-