- if ((int) r_solidworldnode.value == 3)
- {
- int portalstack;
- mportal_t *p, *pstack[8192];
- msurface_t *surf, **mark, **endmark;
- mleaf_t *leaf;
- glpoly_t *poly;
- tinyplane_t plane;
-
- leaf = r_viewleaf;
- leaf->worldnodeframe = r_framecount;
- portalstack = 0;
- loc0:
- c_leafs++;
-
- leaf->visframe = r_framecount;
-
- if (leaf->nummarksurfaces)
- {
- mark = leaf->firstmarksurface;
- endmark = mark + leaf->nummarksurfaces;
- if (r_ser.value)
- {
- do
- {
- surf = *mark++;
- // make sure surfaces are only processed once
- if (surf->worldnodeframe == r_framecount)
- continue;
- surf->worldnodeframe = r_framecount;
- if (PlaneDist(r_origin, surf->plane) < surf->plane->dist)
- {
- if (surf->flags & SURF_PLANEBACK)
- {
- VectorNegate(surf->plane->normal, plane.normal);
- plane.dist = -surf->plane->dist;
- for (poly = surf->polys;poly;poly = poly->next)
- R_Clip_AddPolygon((float *)poly->verts, poly->numverts, VERTEXSIZE * sizeof(float), (surf->flags & SURF_CLIPSOLID) != 0, RSurf_Callback, surf, NULL, &plane);
- }
- }
- else
- {
- if (!(surf->flags & SURF_PLANEBACK))
- for (poly = surf->polys;poly;poly = poly->next)
- R_Clip_AddPolygon((float *)poly->verts, poly->numverts, VERTEXSIZE * sizeof(float), (surf->flags & SURF_CLIPSOLID) != 0, RSurf_Callback, surf, NULL, (tinyplane_t *)surf->plane);
- }
- }
- while (mark < endmark);
- }
- else
- {
- do
- {
- surf = *mark++;
- // make sure surfaces are only processed once
- if (surf->worldnodeframe == r_framecount)
- continue;
- surf->worldnodeframe = r_framecount;
- if (PlaneDist(r_origin, surf->plane) < surf->plane->dist)
- {
- if (surf->flags & SURF_PLANEBACK)
- surf->visframe = r_framecount;
- }
- else
- {
- if (!(surf->flags & SURF_PLANEBACK))
- surf->visframe = r_framecount;
- }
- }
- while (mark < endmark);
- }
- }
-
- // follow portals into other leafs
- p = leaf->portals;
- for (;p;p = p->next)
- {
- if (DotProduct(r_origin, p->plane.normal) < p->plane.dist)
- {
- leaf = p->past;
- if (leaf->worldnodeframe != r_framecount)
- {
- leaf->worldnodeframe = r_framecount;
- if (leaf->contents != CONTENTS_SOLID)
- {
- if (R_NotCulledBox(leaf->mins, leaf->maxs))
- {
- pstack[portalstack++] = p;
- goto loc0;
-
- loc1:
- p = pstack[--portalstack];
- }
- }
- }
- }
- }
-
- if (portalstack)
- goto loc1;
- }
- else if ((int) r_solidworldnode.value == 2)
- {
- mnode_t *nodestack[8192], *node = cl.worldmodel->nodes;
- int nodestackpos = 0;
- glpoly_t *poly;
-
-loc2:
- if (R_NotCulledBox(node->mins, node->maxs))
- {
- if (r_ser.value)
- {
- if (node->numsurfaces)
- {
- msurface_t *surf = cl.worldmodel->surfaces + node->firstsurface, *surfend = surf + node->numsurfaces;
- tinyplane_t plane;
- if (PlaneDiff (r_origin, node->plane) < 0)
- {
- for (;surf < surfend;surf++)
- {
- if (surf->flags & SURF_PLANEBACK)
- {
- VectorNegate(surf->plane->normal, plane.normal);
- plane.dist = -surf->plane->dist;
- for (poly = surf->polys;poly;poly = poly->next)
- R_Clip_AddPolygon((float *)poly->verts, poly->numverts, VERTEXSIZE * sizeof(float), surf->flags & SURF_CLIPSOLID, RSurf_Callback, surf, NULL, &plane);
- }
- }
- }
- else
- {
- for (;surf < surfend;surf++)
- {
- if (!(surf->flags & SURF_PLANEBACK))
- for (poly = surf->polys;poly;poly = poly->next)
- R_Clip_AddPolygon((float *)poly->verts, poly->numverts, VERTEXSIZE * sizeof(float), surf->flags & SURF_CLIPSOLID, RSurf_Callback, surf, NULL, (tinyplane_t *)surf->plane);
- }
- }
- }
- }
- else
- {
- if (node->numsurfaces)
- {
- msurface_t *surf = cl.worldmodel->surfaces + node->firstsurface, *surfend = surf + node->numsurfaces;
- if (PlaneDiff (r_origin, node->plane) < 0)
- {
- for (;surf < surfend;surf++)
- {
- if (surf->flags & SURF_PLANEBACK)
- surf->visframe = r_framecount;
- }
- }
- else
- {
- for (;surf < surfend;surf++)
- {
- if (!(surf->flags & SURF_PLANEBACK))
- surf->visframe = r_framecount;
- }
- }
- }
- }