moved cl_visedicts to r_refdef.entities
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 Jan 2002 00:31:58 +0000 (00:31 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 Jan 2002 00:31:58 +0000 (00:31 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@1366 d7cf8633-e32d-0410-b094-e92efae38249

buildnumber.c
cl_decals.c
cl_main.c
cl_particles.c
cl_tent.c
client.h
gl_rmain.c
render.h

index d57640a..649c6ec 100644 (file)
@@ -1,4 +1,4 @@
 
-#define BUILDNUMBER 710
+#define BUILDNUMBER 716
 
 int buildnumber = BUILDNUMBER;
index 0a071c5..9fe650e 100644 (file)
@@ -56,7 +56,7 @@ void CL_Decals_Init(void)
        cl_currentdecal = 0;
 
        // FIXME: r_refdef stuff should be allocated somewhere else?
-       r_refdef.decals = cl_renderdecals = Mem_Alloc(cl_decal_mempool, MAX_DECALS * sizeof(renderdecal_t));
+       r_refdef.decals = cl_renderdecals = Mem_Alloc(cl_refdef_mempool, MAX_DECALS * sizeof(renderdecal_t));
 }
 
 
index b29079d..b5e1501 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -49,6 +49,7 @@ cvar_t freelook = {CVAR_SAVE, "freelook", "1"};
 cvar_t cl_draweffects = {0, "cl_draweffects", "1"};
 
 mempool_t *cl_scores_mempool;
+mempool_t *cl_refdef_mempool;
 
 client_static_t        cls;
 client_state_t cl;
@@ -57,9 +58,6 @@ entity_t              cl_entities[MAX_EDICTS];
 entity_t               cl_static_entities[MAX_STATIC_ENTITIES];
 lightstyle_t   cl_lightstyle[MAX_LIGHTSTYLES];
 
-int                            cl_numvisedicts;
-entity_t               *cl_visedicts[MAX_VISEDICTS];
-
 typedef struct effect_s
 {
        int active;
@@ -324,10 +322,10 @@ static float CL_LerpPoint (void)
 static void CL_RelinkStaticEntities(void)
 {
        int i;
-       for (i = 0;i < cl.num_statics && cl_numvisedicts < MAX_VISEDICTS;i++)
+       for (i = 0;i < cl.num_statics && r_refdef.numentities < MAX_VISEDICTS;i++)
        {
                Mod_CheckLoaded(cl_static_entities[i].render.model);
-               cl_visedicts[cl_numvisedicts++] = &cl_static_entities[i];
+               r_refdef.entities[r_refdef.numentities++] = &cl_static_entities[i].render;
        }
 }
 
@@ -639,8 +637,8 @@ static void CL_RelinkNetworkEntities()
                        continue;
                if (effects & EF_NODRAW)
                        continue;
-               if (cl_numvisedicts < MAX_VISEDICTS)
-                       cl_visedicts[cl_numvisedicts++] = ent;
+               if (r_refdef.numentities < MAX_VISEDICTS)
+                       r_refdef.entities[r_refdef.numentities++] = &ent->render;
        }
 }
 
@@ -747,7 +745,7 @@ static void CL_RelinkEffects()
 
 void CL_RelinkEntities (void)
 {
-       cl_numvisedicts = 0;
+       r_refdef.numentities = 0;
 
        CL_LerpPlayerVelocity();
        CL_RelinkNetworkEntities();
@@ -915,6 +913,12 @@ CL_Init
 */
 void CL_Init (void)
 {
+       cl_scores_mempool = Mem_AllocPool("client player info");
+
+       cl_refdef_mempool = Mem_AllocPool("refdef");
+       memset(&r_refdef, 0, sizeof(r_refdef));
+       r_refdef.entities = Mem_Alloc(cl_refdef_mempool, sizeof(entity_render_t *) * MAX_VISEDICTS);
+
        SZ_Alloc (&cls.message, 1024, "cls.message");
 
        CL_InitInput ();
@@ -965,8 +969,6 @@ void CL_Init (void)
        if (gamemode == GAME_NEHAHRA)
                Cmd_AddCommand ("pmodel", CL_PModel_f);
 
-       cl_scores_mempool = Mem_AllocPool("client player info");
-
        Cvar_RegisterVariable(&cl_draweffects);
 
        CL_Parse_Init();
index 1196b67..c00732e 100644 (file)
@@ -159,7 +159,7 @@ void CL_Particles_Init (void)
        cl_numparticles = 0;
 
        // FIXME: r_refdef stuff should be allocated somewhere else?
-       r_refdef.particles = cl_renderparticles = Mem_Alloc(cl_part_mempool, cl_maxparticles * sizeof(renderparticle_t));
+       r_refdef.particles = cl_renderparticles = Mem_Alloc(cl_refdef_mempool, cl_maxparticles * sizeof(renderparticle_t));
 }
 
 #define particle(ptype, porientation, pcolor, ptex, plight, pscalex, pscaley, palpha, ptime, pbounce, px, py, pz, pvx, pvy, pvz, ptime2, pvx2, pvy2, pvz2, pfriction, ppressure)\
index d38ee27..a4f7293 100644 (file)
--- a/cl_tent.c
+++ b/cl_tent.c
@@ -436,13 +436,13 @@ entity_t *CL_NewTempEntity (void)
 {
        entity_t        *ent;
 
-       if (cl_numvisedicts >= MAX_VISEDICTS)
+       if (r_refdef.numentities >= MAX_VISEDICTS)
                return NULL;
        if (num_temp_entities >= MAX_TEMP_ENTITIES)
                return NULL;
        ent = &cl_temp_entities[num_temp_entities++];
        memset (ent, 0, sizeof(*ent));
-       cl_visedicts[cl_numvisedicts++] = ent;
+       r_refdef.entities[r_refdef.numentities++] = &ent->render;
 
        ent->render.colormap = -1; // no special coloring
        ent->render.scale = 1;
index 6f436a4..97379bc 100644 (file)
--- a/client.h
+++ b/client.h
@@ -344,12 +344,6 @@ void CL_EstablishConnection (char *host);
 void CL_Disconnect (void);
 void CL_Disconnect_f (void);
 
-// LordHavoc: fixme: move this to r_refdef?
-// LordHavoc: raised this from 256 to the maximum possible number of entities visible
-#define MAX_VISEDICTS (MAX_EDICTS + MAX_STATIC_ENTITIES + MAX_TEMP_ENTITIES)
-extern int                     cl_numvisedicts;
-extern entity_t        *cl_visedicts[MAX_VISEDICTS];
-
 //
 // cl_input
 //
@@ -496,3 +490,29 @@ void CL_Decal(vec3_t origin, int tex, float scale, float red, float green, float
 extern int traceline_endcontents; // set by TraceLine
 float TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int contents);
 
+#define MAX_VISEDICTS (MAX_EDICTS + MAX_STATIC_ENTITIES + MAX_TEMP_ENTITIES)
+
+typedef struct
+{
+       // area to render in
+       int             x, y, width, height;
+       float   fov_x, fov_y;
+
+       // view point
+       vec3_t  vieworg;
+       vec3_t  viewangles;
+
+       int numdecals;
+       renderdecal_t *decals;
+
+       int numentities;
+       entity_render_t **entities;
+
+       int numparticles;
+       struct renderparticle_s *particles;
+}
+refdef_t;
+
+refdef_t r_refdef;
+
+extern mempool_t *cl_refdef_mempool;
index c84eb7e..4900543 100644 (file)
@@ -377,9 +377,9 @@ static void R_MarkEntities (void)
        if (!r_drawentities.integer)
                return;
 
-       for (i = 0;i < cl_numvisedicts;i++)
+       for (i = 0;i < r_refdef.numentities;i++)
        {
-               currentrenderentity = &cl_visedicts[i]->render;
+               currentrenderentity = r_refdef.entities[i];
                Mod_CheckLoaded(currentrenderentity->model);
 
                // move view-relative models to where they should be
@@ -430,9 +430,9 @@ int R_DrawBModelSky (void)
        if (!r_drawentities.integer)
                return false;
 
-       for (i = 0;i < cl_numvisedicts;i++)
+       for (i = 0;i < r_refdef.numentities;i++)
        {
-               currentrenderentity = &cl_visedicts[i]->render;
+               currentrenderentity = r_refdef.entities[i];
                if (currentrenderentity->visframe == r_framecount && currentrenderentity->model->DrawSky)
                {
                        currentrenderentity->model->DrawSky();
@@ -449,9 +449,9 @@ void R_DrawModels (void)
        if (!r_drawentities.integer)
                return;
 
-       for (i = 0;i < cl_numvisedicts;i++)
+       for (i = 0;i < r_refdef.numentities;i++)
        {
-               currentrenderentity = &cl_visedicts[i]->render;
+               currentrenderentity = r_refdef.entities[i];
                if (currentrenderentity->visframe == r_framecount && currentrenderentity->model->Draw)
                        currentrenderentity->model->Draw();
        }
index 6c5d6f2..bd13631 100644 (file)
--- a/render.h
+++ b/render.h
@@ -75,28 +75,6 @@ extern cvar_t r_novis;
 
 //=============================================================================
 
-typedef struct
-{
-       // area to render in
-       int             x, y, width, height;
-       float   fov_x, fov_y;
-
-       // view point
-       vec3_t  vieworg;
-       vec3_t  viewangles;
-
-       int numdecals;
-       renderdecal_t *decals;
-
-       // LordHavoc: this will be enabled at some point, taking the place of cl_visedicts
-       int numentities;
-       entity_render_t *entities;
-
-       int numparticles;
-       struct renderparticle_s *particles;
-}
-refdef_t;
-
 //extern       qboolean        r_cache_thrash;         // compatability
 extern entity_render_t *currentrenderentity;
 extern int                     r_framecount;
@@ -112,12 +90,6 @@ extern      vec3_t  vpn;
 extern vec3_t  vright;
 extern vec3_t  r_origin;
 
-//
-// screen size info
-//
-extern refdef_t        r_refdef;
-
-
 extern mleaf_t         *r_viewleaf, *r_oldviewleaf;
 extern unsigned short  d_lightstylevalue[256]; // 8.8 fraction of base light value