]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
Lots of speedups and cleanups in client code, dynamically allocated cl_entities ...
[xonotic/darkplaces.git] / gl_rsurf.c
index 8ba24b8352215067c2c93db55fbf02ad8c0bfcc0..ec47445d7d81f2c5640025b38f4cfe02c0408401 100644 (file)
@@ -333,9 +333,9 @@ void R_Stain (vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, i
        R_StainNode(model->nodes + model->hulls[0].firstclipnode, model, origin, radius, icolor);
 
        // look for embedded bmodels
-       for (n = 1;n < MAX_EDICTS;n++)
+       for (n = 0;n < cl_num_brushmodel_entities;n++)
        {
-               ent = &cl_entities[n].render;
+               ent = cl_brushmodel_entities[n];
                model = ent->model;
                if (model && model->name[0] == '*')
                {
@@ -378,7 +378,7 @@ static void R_BuildLightMap (msurface_t *surf, int dlightchanged)
        lightmap = surf->samples;
 
 // set to full bright if no light data
-       if ((currentrenderentity->effects & EF_FULLBRIGHT) || !cl.worldmodel->lightdata)
+       if ((currentrenderentity->effects & EF_FULLBRIGHT) || !currentrenderentity->model->lightdata)
        {
                bl = blocklights;
                for (i = 0;i < size3;i++)
@@ -387,7 +387,7 @@ static void R_BuildLightMap (msurface_t *surf, int dlightchanged)
        else
        {
 // clear to no light
-               j = r_ambient.value * 512.0f; // would be 256.0f logically, but using 512.0f to match winquake style
+               j = r_ambient.value * 512.0f; // would be 128.0f logically, but using 512.0f to match winquake style
                if (j)
                {
                        bl = blocklights;
@@ -1931,7 +1931,7 @@ Cshader_t *Cshaders[5] =
 
 void R_PrepareSurfaces(void)
 {
-       int i;
+       int i, alttextures, texframe, framecount;
        texture_t *t;
        model_t *model;
        msurface_t *surf;
@@ -1940,6 +1940,8 @@ void R_PrepareSurfaces(void)
                Cshaders[i]->chain = NULL;
 
        model = currentrenderentity->model;
+       alttextures = currentrenderentity->frame != 0;
+       texframe = (int)(cl.time * 5.0f);
 
        for (i = 0;i < model->nummodelsurfaces;i++)
        {
@@ -1951,11 +1953,16 @@ void R_PrepareSurfaces(void)
                                surf->insertframe = r_framecount;
                                c_faces++;
                                t = surf->texinfo->texture;
-                               if (t->alternate_anims != NULL && currentrenderentity->frame)
-                                       t = t->alternate_anims;
-                               if (t->anim_total >= 2)
-                                       t = t->anim_frames[(int)(cl.time * 5.0f) % t->anim_total];
-                               surf->currenttexture = t;
+                               if (t->animated)
+                               {
+                                       framecount = t->anim_total[alttextures];
+                                       if (framecount >= 2)
+                                               surf->currenttexture = t->anim_frames[alttextures][texframe % framecount];
+                                       else
+                                               surf->currenttexture = t->anim_frames[alttextures][0];
+                               }
+                               else
+                                       surf->currenttexture = t;
                        }
 
                        surf->chain = surf->shader->chain;