+ if (ent != &cl_entities[0].render)
+ R_PrepareBrushModel(ent);
+ R_DrawSurfaces(ent, SHADERSTAGE_NORMAL);
+}
+
+void R_Model_Brush_DrawShadowVolume (entity_render_t *ent, vec3_t relativelightorigin, float lightradius)
+{
+#if 0
+ float projectdistance, temp[3];
+ shadowmesh_t *mesh;
+ VectorSubtract(relativelightorigin, ent->model->shadowmesh_center, temp);
+ projectdistance = lightradius + ent->model->shadowmesh_radius - sqrt(DotProduct(temp, temp));
+ if (projectdistance >= 0.1)
+ {
+ R_Mesh_Matrix(&ent->matrix);
+ for (mesh = ent->model->shadowmesh;mesh;mesh = mesh->next)
+ {
+ R_Mesh_ResizeCheck(mesh->numverts * 2);
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ R_Shadow_Volume(mesh->numverts, mesh->numtriangles, varray_vertex, mesh->elements, mesh->neighbors, relativelightorigin, lightradius, projectdistance);
+ }
+ }
+#else
+ int i;
+ msurface_t *surf;
+ float projectdistance, f, temp[3], lightradius2;
+ surfmesh_t *mesh;
+ R_Mesh_Matrix(&ent->matrix);
+ lightradius2 = lightradius * lightradius;
+ for (i = 0, surf = ent->model->surfaces + ent->model->firstmodelsurface;i < ent->model->nummodelsurfaces;i++, surf++)
+ {
+ if (surf->flags & SURF_SHADOWCAST)
+ {
+ f = PlaneDiff(relativelightorigin, surf->plane);
+ if (surf->flags & SURF_PLANEBACK)
+ f = -f;
+ // draw shadows only for frontfaces
+ projectdistance = lightradius - f;
+ if (projectdistance >= 0.1 && projectdistance < lightradius)
+ {
+ VectorSubtract(relativelightorigin, surf->poly_center, temp);
+ if (DotProduct(temp, temp) < (surf->poly_radius2 + lightradius2))
+ {
+ for (mesh = surf->mesh;mesh;mesh = mesh->chain)
+ {
+ R_Mesh_ResizeCheck(mesh->numverts * 2);
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ R_Shadow_Volume(mesh->numverts, mesh->numtriangles, varray_vertex, mesh->index, mesh->triangleneighbors, relativelightorigin, lightradius, projectdistance);
+ }
+ }
+ }
+ }
+ }
+#endif
+}
+
+void R_Model_Brush_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float lightdistbias, float lightsubtract, float *lightcolor)
+{
+ int tnum;
+ msurface_t *surf;
+ texture_t *t;
+ float f, lightradius2;
+ surfmesh_t *mesh;
+ R_Mesh_Matrix(&ent->matrix);
+ if (ent != &cl_entities[0].render)
+ R_PrepareBrushModel(ent);
+ lightradius2 = lightradius * lightradius;
+ for (tnum = 0;tnum < ent->model->numtextures;tnum++)
+ {
+ t = ent->model->textures + tnum;
+ if (ent->model->texturesurfacechains[tnum] && t->rendertype == SURFRENDER_OPAQUE && t->flags & SURF_SHADOWLIGHT)
+ {
+ t = t->currentframe[ent->frame != 0];
+ for (surf = ent->model->texturesurfacechains[tnum];surf;surf = surf->texturechain)
+ {
+ if (surf->visframe == r_framecount)
+ {
+ f = PlaneDiff(relativelightorigin, surf->plane);
+ if (surf->flags & SURF_PLANEBACK)
+ f = -f;
+ if (f >= -0.1 && f < lightradius)
+ {
+ for (mesh = surf->mesh;mesh;mesh = mesh->chain)
+ {
+ R_Mesh_ResizeCheck(mesh->numverts);
+ memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
+ R_Shadow_RenderLighting(mesh->numverts, mesh->numtriangles, mesh->index, mesh->svectors, mesh->tvectors, mesh->normals, mesh->str, relativelightorigin, relativeeyeorigin, lightradius, lightcolor, t->texture, t->glosstexture, t->nmaptexture, NULL);
+ }
+ }
+ }
+ }
+ }
+ }