+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
+}