+ j = model->sortedmodelsurfaces[i];
+ if (surfaces[j].texture->basematerialflags & flagsmask)
+ R_Water_AddWaterPlane(surfaces + j, n);
+ }
+ }
+ rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity
+}
+
+void R_Q1BSP_Draw(entity_render_t *ent)
+{
+ dp_model_t *model = ent->model;
+ if (model == NULL)
+ return;
+ if (ent == r_refdef.scene.worldentity)
+ R_DrawWorldSurfaces(false, true, false, false, false);
+ else
+ R_DrawModelSurfaces(ent, false, true, false, false, false);
+}
+
+void R_Q1BSP_DrawDepth(entity_render_t *ent)
+{
+ dp_model_t *model = ent->model;
+ if (model == NULL)
+ return;
+ GL_ColorMask(0,0,0,0);
+ GL_Color(1,1,1,1);
+ GL_DepthTest(true);
+ GL_BlendFunc(GL_ONE, GL_ZERO);
+ GL_DepthMask(true);
+// R_Mesh_ResetTextureState();
+ R_SetupShader_DepthOrShadow();
+ if (ent == r_refdef.scene.worldentity)
+ R_DrawWorldSurfaces(false, false, true, false, false);
+ else
+ R_DrawModelSurfaces(ent, false, false, true, false, false);
+ GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
+}
+
+void R_Q1BSP_DrawDebug(entity_render_t *ent)
+{
+ if (ent->model == NULL)
+ return;
+ if (ent == r_refdef.scene.worldentity)
+ R_DrawWorldSurfaces(false, false, false, true, false);
+ else
+ R_DrawModelSurfaces(ent, false, false, false, true, false);
+}
+
+void R_Q1BSP_DrawPrepass(entity_render_t *ent)
+{
+ dp_model_t *model = ent->model;
+ if (model == NULL)
+ return;
+ if (ent == r_refdef.scene.worldentity)
+ R_DrawWorldSurfaces(false, true, false, false, true);
+ else
+ R_DrawModelSurfaces(ent, false, true, false, false, true);
+}
+
+typedef struct r_q1bsp_getlightinfo_s
+{
+ dp_model_t *model;
+ vec3_t relativelightorigin;
+ float lightradius;
+ int *outleaflist;
+ unsigned char *outleafpvs;
+ int outnumleafs;
+ unsigned char *visitingleafpvs;
+ int *outsurfacelist;
+ unsigned char *outsurfacepvs;
+ unsigned char *tempsurfacepvs;
+ unsigned char *outshadowtrispvs;
+ unsigned char *outlighttrispvs;
+ int outnumsurfaces;
+ vec3_t outmins;
+ vec3_t outmaxs;
+ vec3_t lightmins;
+ vec3_t lightmaxs;
+ const unsigned char *pvs;
+ qboolean svbsp_active;
+ qboolean svbsp_insertoccluder;
+ int numfrustumplanes;
+ const mplane_t *frustumplanes;
+}
+r_q1bsp_getlightinfo_t;
+
+#define GETLIGHTINFO_MAXNODESTACK 4096
+
+static void R_Q1BSP_RecursiveGetLightInfo_BSP(r_q1bsp_getlightinfo_t *info, qboolean skipsurfaces)
+{
+ // nodestack
+ mnode_t *nodestack[GETLIGHTINFO_MAXNODESTACK];
+ int nodestackpos = 0;
+ // node processing
+ mplane_t *plane;
+ mnode_t *node;
+ int sides;
+ // leaf processing
+ mleaf_t *leaf;
+ const msurface_t *surface;
+ const msurface_t *surfaces = info->model->data_surfaces;
+ int numleafsurfaces;
+ int leafsurfaceindex;
+ int surfaceindex;
+ int triangleindex, t;
+ int currentmaterialflags;
+ qboolean castshadow;
+ const int *e;
+ const vec_t *v[3];
+ float v2[3][3];
+ qboolean insidebox;
+ qboolean frontsidecasting = r_shadow_frontsidecasting.integer != 0;
+ qboolean svbspactive = info->svbsp_active;
+ qboolean svbspinsertoccluder = info->svbsp_insertoccluder;
+ const int *leafsurfaceindices;
+ qboolean addedtris;
+ int i;
+ mportal_t *portal;
+ static float points[128][3];
+ // push the root node onto our nodestack
+ nodestack[nodestackpos++] = info->model->brush.data_nodes;
+ // we'll be done when the nodestack is empty
+ while (nodestackpos)
+ {
+ // get a node from the stack to process
+ node = nodestack[--nodestackpos];
+ // is it a node or a leaf?
+ plane = node->plane;
+ if (plane)
+ {
+ // node
+#if 0
+ if (!BoxesOverlap(info->lightmins, info->lightmaxs, node->mins, node->maxs))
+ continue;
+#endif
+#if 0
+ if (!r_shadow_compilingrtlight && R_CullBoxCustomPlanes(node->mins, node->maxs, rtlight->cached_numfrustumplanes, rtlight->cached_frustumplanes))
+ continue;
+#endif
+ // axial planes can be processed much more quickly
+ if (plane->type < 3)