From: vortex Date: Sat, 19 Mar 2011 20:23:39 +0000 (+0000) Subject: dynamically grow maxtempentities X-Git-Tag: xonotic-v0.6.0~163^2~611 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;ds=sidebyside;h=0254ae31b9a4800d63f8d89507e5a9b31de455ea;p=xonotic%2Fdarkplaces.git dynamically grow maxtempentities git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10935 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_main.c b/cl_main.c index cc3315f2..e5f6fef1 100644 --- a/cl_main.c +++ b/cl_main.c @@ -630,6 +630,14 @@ static float CL_LerpPoint(void) void CL_ClearTempEntities (void) { r_refdef.scene.numtempentities = 0; + // grow tempentities buffer on request + if (r_refdef.scene.expandtempentities) + { + Con_Printf("CL_NewTempEntity: grow maxtempentities from %i to %i\n", r_refdef.scene.maxtempentities, r_refdef.scene.maxtempentities * 2); + r_refdef.scene.maxtempentities *= 2; + r_refdef.scene.tempentities = (entity_render_t *)Mem_Realloc(cls.permanentmempool, r_refdef.scene.tempentities, sizeof(entity_render_t) * r_refdef.scene.maxtempentities); + r_refdef.scene.expandtempentities = false; + } } entity_render_t *CL_NewTempEntity(double shadertime) @@ -639,7 +647,10 @@ entity_render_t *CL_NewTempEntity(double shadertime) if (r_refdef.scene.numentities >= r_refdef.scene.maxentities) return NULL; if (r_refdef.scene.numtempentities >= r_refdef.scene.maxtempentities) + { + r_refdef.scene.expandtempentities = true; // will be reallocated next frame since current frame may have pointers set already return NULL; + } render = &r_refdef.scene.tempentities[r_refdef.scene.numtempentities++]; memset (render, 0, sizeof(*render)); r_refdef.scene.entities[r_refdef.scene.numentities++] = render; @@ -1881,7 +1892,7 @@ void CL_UpdateWorld(void) r_refdef.scene.numlights = 0; r_refdef.view.matrix = identitymatrix; r_refdef.view.quality = 1; - + cl.num_brushmodel_entities = 0; if (cls.state == ca_connected && cls.signon == SIGNONS) @@ -2361,7 +2372,6 @@ CL_Init */ void CL_Init (void) { - int i; cls.levelmempool = Mem_AllocPool("client (per-level memory)", 0, NULL); cls.permanentmempool = Mem_AllocPool("client (long term memory)", 0, NULL); @@ -2372,12 +2382,7 @@ void CL_Init (void) r_refdef.scene.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * r_refdef.scene.maxentities); // max temp entities - // FIXME: make this grow - i = COM_CheckParm("-maxtempents"); - if (i) - r_refdef.scene.maxtempentities = atof(com_argv[i + 1]); - else - r_refdef.scene.maxtempentities = MAX_TEMPENTITIES; + r_refdef.scene.maxtempentities = MAX_TEMPENTITIES; r_refdef.scene.tempentities = (entity_render_t *)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t) * r_refdef.scene.maxtempentities); CL_InitInput (); diff --git a/client.h b/client.h index 54c637b2..b9077cc4 100644 --- a/client.h +++ b/client.h @@ -1732,6 +1732,7 @@ typedef struct r_refdef_scene_s { entity_render_t *tempentities; int numtempentities; int maxtempentities; + qboolean expandtempentities; // renderable dynamic lights rtlight_t *lights[MAX_DLIGHTS];