fixed some dynamic lighting bugs related to glowing self
[xonotic/darkplaces.git] / gl_models.c
index 4126c63..f77d722 100644 (file)
@@ -289,7 +289,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                        varray_texcoord[0][i + 1] *= 8.0f;
                }
                R_LightModel(ent, model->numverts, varray_vertex, aliasvert_normals, varray_color, colorscale, colorscale, colorscale, false);
-               GL_UseColorArray();
                R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
                return;
        }
@@ -330,10 +329,7 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                if (fullbright)
                        GL_Color(colorscale * ifog, colorscale * ifog, colorscale * ifog, ent->alpha);
                else
-               {
-                       GL_UseColorArray();
                        R_LightModel(ent, model->numverts, varray_vertex, aliasvert_normals, varray_color, colorscale * ifog, colorscale * ifog, colorscale * ifog, false);
-               }
                R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
                c_alias_polys += model->numtris;
                blendfunc1 = GL_SRC_ALPHA;
@@ -361,10 +357,7 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                                if (pantsfullbright)
                                        GL_Color(pantscolor[0] * colorscale * ifog, pantscolor[1] * colorscale * ifog, pantscolor[2] * colorscale * ifog, ent->alpha);
                                else
-                               {
-                                       GL_UseColorArray();
                                        R_LightModel(ent, model->numverts, varray_vertex, aliasvert_normals, varray_color, pantscolor[0] * colorscale * ifog, pantscolor[1] * colorscale * ifog, pantscolor[2] * colorscale * ifog, false);
-                               }
                                R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
                                c_alias_polys += model->numtris;
                                blendfunc1 = GL_SRC_ALPHA;
@@ -390,10 +383,7 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                                if (shirtfullbright)
                                        GL_Color(shirtcolor[0] * colorscale * ifog, shirtcolor[1] * colorscale * ifog, shirtcolor[2] * colorscale * ifog, ent->alpha);
                                else
-                               {
-                                       GL_UseColorArray();
                                        R_LightModel(ent, model->numverts, varray_vertex, aliasvert_normals, varray_color, shirtcolor[0] * colorscale * ifog, shirtcolor[1] * colorscale * ifog, shirtcolor[2] * colorscale * ifog, false);
-                               }
                                R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
                                c_alias_polys += model->numtris;
                                blendfunc1 = GL_SRC_ALPHA;
@@ -454,64 +444,6 @@ void R_Model_Alias_DrawFakeShadow (entity_render_t *ent)
        model_t *model;
        float *v, planenormal[3], planedist, dist, projection[3], floororigin[3], surfnormal[3], lightdirection[3], v2[3];
 
-       /*
-       if (r_shadows.integer > 1)
-       {
-               float f, lightscale, lightcolor[3];
-               vec3_t temp;
-               mlight_t *sl;
-               rdlight_t *rd;
-               memset(&m, 0, sizeof(m));
-               m.blendfunc1 = GL_ONE;
-               m.blendfunc2 = GL_ONE;
-               R_Mesh_State(&m);
-               R_Mesh_Matrix(&ent->matrix);
-               for (i = 0, sl = cl.worldmodel->lights;i < cl.worldmodel->numlights;i++, sl++)
-               {
-                       if (d_lightstylevalue[sl->style] > 0)
-                       {
-                               VectorSubtract(ent->origin, sl->origin, temp);
-                               f = DotProduct(temp,temp);
-                               if (f < (ent->model->radius2 + sl->cullradius2))
-                               {
-                                       model = ent->model;
-                                       R_Mesh_ResizeCheck(model->numverts * 2);
-                                       R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
-                                       Matrix4x4_Transform(&ent->inversematrix, sl->origin, temp);
-                                       GL_Color(0.1 * r_colorscale, 0.025 * r_colorscale, 0.0125 * r_colorscale, 1);
-                                       R_Shadow_Volume(model->numverts, model->numtris, varray_vertex, model->mdlmd2data_indices, model->mdlmd2data_triangleneighbors, temp, sl->cullradius + model->radius - sqrt(f), true);
-                                       GL_UseColorArray();
-                                       lightscale = d_lightstylevalue[sl->style] * (1.0f / 65536.0f);
-                                       VectorScale(sl->light, lightscale, lightcolor);
-                                       R_Shadow_VertexLight(model->numverts, varray_vertex, aliasvert_normals, temp, sl->cullradius2, sl->distbias, sl->subtract, lightcolor);
-                                       R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
-                               }
-                       }
-               }
-               for (i = 0, rd = r_dlight;i < r_numdlights;i++, rd++)
-               {
-                       if (ent != rd->ent)
-                       {
-                               VectorSubtract(ent->origin, rd->origin, temp);
-                               f = DotProduct(temp,temp);
-                               if (f < (ent->model->radius2 + rd->cullradius2))
-                               {
-                                       model = ent->model;
-                                       R_Mesh_ResizeCheck(model->numverts * 2);
-                                       R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
-                                       Matrix4x4_Transform(&ent->inversematrix, rd->origin, temp);
-                                       GL_Color(0.1 * r_colorscale, 0.025 * r_colorscale, 0.0125 * r_colorscale, 1);
-                                       R_Shadow_Volume(model->numverts, model->numtris, varray_vertex, model->mdlmd2data_indices, model->mdlmd2data_triangleneighbors, temp, rd->cullradius + model->radius - sqrt(f), true);
-                                       GL_UseColorArray();
-                                       R_Shadow_VertexLight(model->numverts, varray_vertex, aliasvert_normals, temp, rd->cullradius2, LIGHTOFFSET, rd->subtract, rd->light);
-                                       R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
-                               }
-                       }
-               }
-               return;
-       }
-       */
-
        lightdirection[0] = 0.5;
        lightdirection[1] = 0.2;
        lightdirection[2] = -1;
@@ -559,16 +491,7 @@ void R_Model_Alias_DrawFakeShadow (entity_render_t *ent)
        R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
 }
 
-void R_Model_Alias_DrawBaseLighting(entity_render_t *ent)
-{
-       R_Mesh_Matrix(&ent->matrix);
-       GL_Color(0, 0, 0, 1);
-       R_Mesh_ResizeCheck(ent->model->numverts);
-       R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
-       R_Mesh_Draw(ent->model->numverts, ent->model->numtris, ent->model->mdlmd2data_indices);
-}
-
-void R_Model_Alias_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius, int visiblevolume)
+void R_Model_Alias_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius)
 {
        float projectdistance;
        projectdistance = lightradius + ent->model->radius - sqrt(DotProduct(relativelightorigin, relativelightorigin));
@@ -577,7 +500,7 @@ void R_Model_Alias_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightor
                R_Mesh_Matrix(&ent->matrix);
                R_Mesh_ResizeCheck(ent->model->numverts * 2);
                R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvert_normals);
-               R_Shadow_Volume(ent->model->numverts, ent->model->numtris, varray_vertex, ent->model->mdlmd2data_indices, ent->model->mdlmd2data_triangleneighbors, relativelightorigin, lightradius, projectdistance, visiblevolume);
+               R_Shadow_Volume(ent->model->numverts, ent->model->numtris, varray_vertex, ent->model->mdlmd2data_indices, ent->model->mdlmd2data_triangleneighbors, relativelightorigin, lightradius, projectdistance);
        }
 }