int i;
entity_t *ent;
- if (cl.entities) Mem_Free(cl.entities);cl.entities = NULL;
- if (cl.csqcentities) Mem_Free(cl.csqcentities);cl.csqcentities = NULL; //[515]: csqc
- if (cl.entities_active) Mem_Free(cl.entities_active);cl.entities_active = NULL;
- if (cl.csqcentities_active) Mem_Free(cl.csqcentities_active);cl.csqcentities_active = NULL; //[515]: csqc
- if (cl.static_entities) Mem_Free(cl.static_entities);cl.static_entities = NULL;
- if (cl.temp_entities) Mem_Free(cl.temp_entities);cl.temp_entities = NULL;
- if (cl.effects) Mem_Free(cl.effects);cl.effects = NULL;
- if (cl.beams) Mem_Free(cl.beams);cl.beams = NULL;
- if (cl.dlights) Mem_Free(cl.dlights);cl.dlights = NULL;
- if (cl.lightstyle) Mem_Free(cl.lightstyle);cl.lightstyle = NULL;
- if (cl.brushmodel_entities) Mem_Free(cl.brushmodel_entities);cl.brushmodel_entities = NULL;
- if (cl.entitydatabase) EntityFrame_FreeDatabase(cl.entitydatabase);cl.entitydatabase = NULL;
- if (cl.entitydatabase4) EntityFrame4_FreeDatabase(cl.entitydatabase4);cl.entitydatabase4 = NULL;
- if (cl.entitydatabaseqw) EntityFrameQW_FreeDatabase(cl.entitydatabaseqw);cl.entitydatabaseqw = NULL;
- if (cl.scores) Mem_Free(cl.scores);cl.scores = NULL;
- if (cl.particles) Mem_Free(cl.particles);cl.particles = NULL;
-
- if (!sv.active)
- Host_ClearMemory ();
-
// wipe the entire cl structure
+ Mem_EmptyPool(cls.levelmempool);
memset (&cl, 0, sizeof(cl));
S_StopAllSounds();
cl.num_effects = 0;
cl.num_beams = 0;
- cl.entities = (entity_t *)Mem_Alloc(cls.mempool, cl.max_entities * sizeof(entity_t));
- cl.csqcentities = (entity_t *)Mem_Alloc(cls.mempool, cl.max_csqcentities * sizeof(entity_t)); //[515]: csqc
- cl.entities_active = (unsigned char *)Mem_Alloc(cls.mempool, cl.max_brushmodel_entities * sizeof(unsigned char));
- cl.csqcentities_active = (unsigned char *)Mem_Alloc(cls.mempool, cl.max_brushmodel_entities * sizeof(unsigned char)); //[515]: csqc
- cl.static_entities = (entity_t *)Mem_Alloc(cls.mempool, cl.max_static_entities * sizeof(entity_t));
- cl.temp_entities = (entity_t *)Mem_Alloc(cls.mempool, cl.max_temp_entities * sizeof(entity_t));
- cl.effects = (cl_effect_t *)Mem_Alloc(cls.mempool, cl.max_effects * sizeof(cl_effect_t));
- cl.beams = (beam_t *)Mem_Alloc(cls.mempool, cl.max_beams * sizeof(beam_t));
- cl.dlights = (dlight_t *)Mem_Alloc(cls.mempool, cl.max_dlights * sizeof(dlight_t));
- cl.lightstyle = (lightstyle_t *)Mem_Alloc(cls.mempool, cl.max_lightstyle * sizeof(lightstyle_t));
- cl.brushmodel_entities = (int *)Mem_Alloc(cls.mempool, cl.max_brushmodel_entities * sizeof(int));
- cl.particles = (particle_t *) Mem_Alloc(cls.mempool, cl.max_particles * sizeof(particle_t));
+ cl.entities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_entities * sizeof(entity_t));
+ cl.csqcentities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_csqcentities * sizeof(entity_t)); //[515]: csqc
+ cl.entities_active = (unsigned char *)Mem_Alloc(cls.levelmempool, cl.max_brushmodel_entities * sizeof(unsigned char));
+ cl.csqcentities_active = (unsigned char *)Mem_Alloc(cls.levelmempool, cl.max_brushmodel_entities * sizeof(unsigned char)); //[515]: csqc
+ cl.static_entities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_static_entities * sizeof(entity_t));
+ cl.temp_entities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_temp_entities * sizeof(entity_t));
+ cl.effects = (cl_effect_t *)Mem_Alloc(cls.levelmempool, cl.max_effects * sizeof(cl_effect_t));
+ cl.beams = (beam_t *)Mem_Alloc(cls.levelmempool, cl.max_beams * sizeof(beam_t));
+ cl.dlights = (dlight_t *)Mem_Alloc(cls.levelmempool, cl.max_dlights * sizeof(dlight_t));
+ cl.lightstyle = (lightstyle_t *)Mem_Alloc(cls.levelmempool, cl.max_lightstyle * sizeof(lightstyle_t));
+ cl.brushmodel_entities = (int *)Mem_Alloc(cls.levelmempool, cl.max_brushmodel_entities * sizeof(int));
+ cl.particles = (particle_t *) Mem_Alloc(cls.levelmempool, cl.max_particles * sizeof(particle_t));
// LordHavoc: have to set up the baseline info for alpha and other stuff
for (i = 0;i < cl.max_entities;i++)
oldmaxentities = cl.max_entities;
oldentities = cl.entities;
cl.max_entities = (num & ~255) + 256;
- cl.entities = (entity_t *)Mem_Alloc(cls.mempool, cl.max_entities * sizeof(entity_t));
+ cl.entities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_entities * sizeof(entity_t));
memcpy(cl.entities, oldentities, oldmaxentities * sizeof(entity_t));
Mem_Free(oldentities);
for (i = oldmaxentities;i < cl.max_entities;i++)
oldmaxentities = cl.max_csqcentities;
oldentities = cl.csqcentities;
cl.max_csqcentities = (num & ~255) + 256;
- cl.csqcentities = Mem_Alloc(cls.mempool, cl.max_csqcentities * sizeof(entity_t));
+ cl.csqcentities = Mem_Alloc(cls.levelmempool, cl.max_csqcentities * sizeof(entity_t));
memcpy(cl.csqcentities, oldentities, oldmaxentities * sizeof(entity_t));
Mem_Free(oldentities);
for (i = oldmaxentities;i < cl.max_csqcentities;i++)
CL_Particles_Shutdown();
CL_Parse_Shutdown();
- Mem_FreePool (&cls.mempool);
+ Mem_FreePool (&cls.permanentmempool);
+ Mem_FreePool (&cls.levelmempool);
}
/*
*/
void CL_Init (void)
{
- cls.mempool = Mem_AllocPool("client", 0, NULL);
+ cls.levelmempool = Mem_AllocPool("client (per-level memory)", 0, NULL);
+ cls.permanentmempool = Mem_AllocPool("client (long term memory)", 0, NULL);
memset(&r_refdef, 0, sizeof(r_refdef));
// max entities sent to renderer per frame
r_refdef.maxentities = MAX_EDICTS + 256 + 512;
- r_refdef.entities = (entity_render_t **)Mem_Alloc(cls.mempool, sizeof(entity_render_t *) * r_refdef.maxentities);
+ r_refdef.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * r_refdef.maxentities);
CL_InitInput ();
while (cls.qw_downloadmemorymaxsize < cls.qw_downloadmemorycursize + size)
cls.qw_downloadmemorymaxsize *= 2;
old = cls.qw_downloadmemory;
- cls.qw_downloadmemory = Mem_Alloc(cls.mempool, cls.qw_downloadmemorymaxsize);
+ cls.qw_downloadmemory = Mem_Alloc(cls.permanentmempool, cls.qw_downloadmemorymaxsize);
if (old)
{
memcpy(cls.qw_downloadmemory, old, cls.qw_downloadmemorycursize);
Con_DPrintf("Starting upload of %d bytes...\n", size);
- cls.qw_uploaddata = Mem_Alloc(cls.mempool, size);
+ cls.qw_uploaddata = Mem_Alloc(cls.permanentmempool, size);
memcpy(cls.qw_uploaddata, data, size);
cls.qw_uploadsize = size;
cls.qw_uploadpos = 0;
i = MSG_ReadByte();
cl.qw_spectator = (i & 128) != 0;
cl.playerentity = cl.viewentity = (i & 127) + 1;
- cl.scores = (scoreboard_t *)Mem_Alloc(cls.mempool, cl.maxclients*sizeof(*cl.scores));
+ cl.scores = (scoreboard_t *)Mem_Alloc(cls.levelmempool, cl.maxclients*sizeof(*cl.scores));
// get the full level name
str = MSG_ReadString ();
Host_Error("Bad maxclients (%u) from server", cl.maxclients);
return;
}
- cl.scores = (scoreboard_t *)Mem_Alloc(cls.mempool, cl.maxclients*sizeof(*cl.scores));
+ cl.scores = (scoreboard_t *)Mem_Alloc(cls.levelmempool, cl.maxclients*sizeof(*cl.scores));
// parse gametype
cl.gametype = MSG_ReadByte ();
return false;
}
- video->imagedata = Mem_Alloc( cls.mempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
+ video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL );
- video->imagedata = Mem_Alloc( cls.mempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
+ video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
return video;
}
{
cactive_t state;
- // all client memory allocations go in this pool
- mempool_t *mempool;
+ // all client memory allocations go in these pools
+ mempool_t *levelmempool;
+ mempool_t *permanentmempool;
// demo loop control
// -1 = don't play demos
qglEnd();
CHECKGLERROR
}
-
-// FIXME: someday this should be dynamically allocated and resized?
-float varray_vertex3f[65536*3];
-float varray_svector3f[65536*3];
-float varray_tvector3f[65536*3];
-float varray_normal3f[65536*3];
-float varray_color4f[65536*4];
-float varray_texcoord3f[65536*3];
-float varray_vertex3f2[65536*3];
// invoke refresh of loading plaque (nothing else seen)
void SCR_UpdateLoadingScreen(void);
-extern float varray_vertex3f[65536*3];
-extern float varray_svector3f[65536*3];
-extern float varray_tvector3f[65536*3];
-extern float varray_normal3f[65536*3];
-extern float varray_color4f[65536*4];
-extern float varray_texcoord3f[65536*3];
-extern float varray_vertex3f2[65536*3];
-
#endif
R_UpdateTextureInfo(ent, ent->model->data_textures + i);
}
+int rsurface_array_size = 0;
+float *rsurface_array_vertex3f = NULL;
+float *rsurface_array_svector3f = NULL;
+float *rsurface_array_tvector3f = NULL;
+float *rsurface_array_normal3f = NULL;
+float *rsurface_array_color4f = NULL;
+float *rsurface_array_texcoord3f = NULL;
+
+void R_Mesh_ResizeArrays(int newvertices)
+{
+ if (rsurface_array_size >= newvertices)
+ return;
+ if (rsurface_array_vertex3f)
+ Mem_Free(rsurface_array_vertex3f);
+ rsurface_array_size = (newvertices + 1023) & ~1023;
+ rsurface_array_vertex3f = Mem_Alloc(r_main_mempool, rsurface_array_size * sizeof(float[19]));
+ rsurface_array_svector3f = rsurface_array_vertex3f + rsurface_array_size * 3;
+ rsurface_array_tvector3f = rsurface_array_vertex3f + rsurface_array_size * 6;
+ rsurface_array_normal3f = rsurface_array_vertex3f + rsurface_array_size * 9;
+ rsurface_array_color4f = rsurface_array_vertex3f + rsurface_array_size * 12;
+ rsurface_array_texcoord3f = rsurface_array_vertex3f + rsurface_array_size * 16;
+}
+
float *rsurface_vertex3f;
float *rsurface_svector3f;
float *rsurface_tvector3f;
void RSurf_SetVertexPointer(const entity_render_t *ent, const texture_t *texture, const msurface_t *surface, const vec3_t modelorg, qboolean generatenormals, qboolean generatetangents)
{
+ if (rsurface_array_size < surface->groupmesh->num_vertices)
+ R_Mesh_ResizeArrays(surface->groupmesh->num_vertices);
if ((ent->frameblend[0].lerp != 1 || ent->frameblend[0].frame != 0) && (surface->groupmesh->data_morphvertex3f || surface->groupmesh->data_vertexboneweights))
{
- rsurface_vertex3f = varray_vertex3f;
+ rsurface_vertex3f = rsurface_array_vertex3f;
Mod_Alias_GetMesh_Vertex3f(ent->model, ent->frameblend, surface->groupmesh, rsurface_vertex3f);
if (generatetangents || (texture->textureflags & (Q3TEXTUREFLAG_AUTOSPRITE | Q3TEXTUREFLAG_AUTOSPRITE2)))
{
- rsurface_svector3f = varray_svector3f;
- rsurface_tvector3f = varray_tvector3f;
- rsurface_normal3f = varray_normal3f;
+ rsurface_svector3f = rsurface_array_svector3f;
+ rsurface_tvector3f = rsurface_array_tvector3f;
+ rsurface_normal3f = rsurface_array_normal3f;
Mod_BuildTextureVectorsAndNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface_vertex3f, surface->groupmesh->data_texcoordtexture2f, surface->groupmesh->data_element3i + surface->num_firsttriangle * 3, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f, r_smoothnormals_areaweighting.integer);
}
else
rsurface_tvector3f = NULL;
if (generatenormals)
{
- rsurface_normal3f = varray_normal3f;
+ rsurface_normal3f = rsurface_array_normal3f;
Mod_BuildNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface_vertex3f, surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle, rsurface_normal3f, r_smoothnormals_areaweighting.integer);
}
else
VectorSet(up, 0, 0, 1);
}
for (i = 0;i < 4;i++)
- VectorMAMAMAM(1, center, v[i][0], forward, v[i][1], right, v[i][2], up, varray_vertex3f + (surface->num_firstvertex+i+j) * 3);
+ VectorMAMAMAM(1, center, v[i][0], forward, v[i][1], right, v[i][2], up, rsurface_array_vertex3f + (surface->num_firstvertex+i+j) * 3);
}
- rsurface_vertex3f = varray_vertex3f;
- rsurface_svector3f = varray_svector3f;
- rsurface_tvector3f = varray_tvector3f;
- rsurface_normal3f = varray_normal3f;
+ rsurface_vertex3f = rsurface_array_vertex3f;
+ rsurface_svector3f = rsurface_array_svector3f;
+ rsurface_tvector3f = rsurface_array_tvector3f;
+ rsurface_normal3f = rsurface_array_normal3f;
Mod_BuildTextureVectorsAndNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface_vertex3f, surface->groupmesh->data_texcoordtexture2f, surface->groupmesh->data_element3i + surface->num_firsttriangle * 3, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f, r_smoothnormals_areaweighting.integer);
}
R_Mesh_VertexPointer(rsurface_vertex3f);
int numverts = surface->num_vertices;
v = rsurface_vertex3f + 3 * surface->num_firstvertex;
c2 = rsurface_normal3f + 3 * surface->num_firstvertex;
- c = varray_color4f + 4 * surface->num_firstvertex;
+ c = rsurface_array_color4f + 4 * surface->num_firstvertex;
// q3-style directional shading
for (i = 0;i < numverts;i++, v += 3, c2 += 3, c += 4)
{
b = 1;
a = 1;
applycolor = false;
- rsurface_lightmapcolor4f = varray_color4f;
+ rsurface_lightmapcolor4f = rsurface_array_color4f;
}
else
{
{
if (surface->lightmapinfo && surface->lightmapinfo->stainsamples)
{
- for (i = 0, c = varray_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4)
+ for (i = 0, c = rsurface_array_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4)
{
if (surface->lightmapinfo->samples)
{
else
VectorClear(c);
}
- rsurface_lightmapcolor4f = varray_color4f;
+ rsurface_lightmapcolor4f = rsurface_array_color4f;
}
else
rsurface_lightmapcolor4f = surface->groupmesh->data_lightmapcolor4f;
{
if (rsurface_lightmapcolor4f)
{
- for (i = 0, v = (rsurface_vertex3f + 3 * surface->num_firstvertex), c = (rsurface_lightmapcolor4f + 4 * surface->num_firstvertex), c2 = (varray_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, v += 3, c += 4, c2 += 4)
+ for (i = 0, v = (rsurface_vertex3f + 3 * surface->num_firstvertex), c = (rsurface_lightmapcolor4f + 4 * surface->num_firstvertex), c2 = (rsurface_array_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, v += 3, c += 4, c2 += 4)
{
f = 1 - VERTEXFOGTABLE(VectorDistance(v, modelorg));
c2[0] = c[0] * f;
}
else
{
- for (i = 0, v = (rsurface_vertex3f + 3 * surface->num_firstvertex), c2 = (varray_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, v += 3, c2 += 4)
+ for (i = 0, v = (rsurface_vertex3f + 3 * surface->num_firstvertex), c2 = (rsurface_array_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, v += 3, c2 += 4)
{
f = 1 - VERTEXFOGTABLE(VectorDistance(v, modelorg));
c2[0] = f;
c2[3] = 1;
}
}
- rsurface_lightmapcolor4f = varray_color4f;
+ rsurface_lightmapcolor4f = rsurface_array_color4f;
}
if (applycolor && rsurface_lightmapcolor4f)
{
- for (i = 0, c = (rsurface_lightmapcolor4f + 4 * surface->num_firstvertex), c2 = (varray_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, c += 4, c2 += 4)
+ for (i = 0, c = (rsurface_lightmapcolor4f + 4 * surface->num_firstvertex), c2 = (rsurface_array_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, c += 4, c2 += 4)
{
c2[0] = c[0] * r;
c2[1] = c[1] * g;
c2[2] = c[2] * b;
c2[3] = c[3] * a;
}
- rsurface_lightmapcolor4f = varray_color4f;
+ rsurface_lightmapcolor4f = rsurface_array_color4f;
}
R_Mesh_ColorPointer(rsurface_lightmapcolor4f);
GL_Color(r, g, b, a);
m.tex[1] = R_GetTexture(layer->texture);
m.texmatrix[1] = layer->texmatrix;
m.texrgbscale[1] = layertexrgbscale;
- m.pointer_color = varray_color4f;
+ m.pointer_color = rsurface_array_color4f;
R_Mesh_State(&m);
if (lightmode == 2)
{
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(layer->texture);
m.texmatrix[0] = layer->texmatrix;
- m.pointer_color = varray_color4f;
+ m.pointer_color = rsurface_array_color4f;
m.texrgbscale[0] = layertexrgbscale;
R_Mesh_State(&m);
if (lightmode == 2)
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(layer->texture);
m.texmatrix[0] = layer->texmatrix;
- m.pointer_color = varray_color4f;
+ m.pointer_color = rsurface_array_color4f;
m.texrgbscale[0] = layertexrgbscale;
R_Mesh_State(&m);
for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
m.tex[0] = R_GetTexture(layer->texture);
m.texmatrix[0] = layer->texmatrix;
m.texrgbscale[0] = layertexrgbscale;
- m.pointer_color = varray_color4f;
+ m.pointer_color = rsurface_array_color4f;
R_Mesh_State(&m);
if (lightmode == 2)
{
memset(&m, 0, sizeof(m));
m.tex[0] = R_GetTexture(layer->texture);
m.texmatrix[0] = layer->texmatrix;
- m.pointer_color = varray_color4f;
+ m.pointer_color = rsurface_array_color4f;
m.texrgbscale[0] = layertexrgbscale;
R_Mesh_State(&m);
for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
RSurf_SetVertexPointer(ent, texture, surface, modelorg, false, false);
if (layer->texture)
R_Mesh_TexCoordPointer(0, 2, surface->groupmesh->data_texcoordtexture2f);
- R_Mesh_ColorPointer(varray_color4f);
- for (i = 0, v = (rsurface_vertex3f + 3 * surface->num_firstvertex), c = (varray_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, v += 3, c += 4)
+ R_Mesh_ColorPointer(rsurface_array_color4f);
+ for (i = 0, v = (rsurface_vertex3f + 3 * surface->num_firstvertex), c = (rsurface_array_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, v += 3, c += 4)
{
f = VERTEXFOGTABLE(VectorDistance(v, modelorg));
c[0] = layercolor[0];
static void R_DrawPortal_Callback(const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight)
{
const mportal_t *portal = (mportal_t *)ent;
- int i;
+ int i, numpoints;
float *v;
rmeshstate_t m;
+ float vertex3f[POLYGONELEMENTS_MAXPOINTS*3];
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GL_DepthMask(false);
GL_DepthTest(true);
qglDisable(GL_CULL_FACE);
R_Mesh_Matrix(&identitymatrix);
+ numpoints = min(portal->numpoints, POLYGONELEMENTS_MAXPOINTS);
+
memset(&m, 0, sizeof(m));
- m.pointer_vertex = varray_vertex3f;
+ m.pointer_vertex = vertex3f;
R_Mesh_State(&m);
i = surfacenumber;
((i & 0x0038) >> 3) * (1.0f / 7.0f),
((i & 0x01C0) >> 6) * (1.0f / 7.0f),
0.125f);
- for (i = 0, v = varray_vertex3f;i < portal->numpoints;i++, v += 3)
+ for (i = 0, v = vertex3f;i < numpoints;i++, v += 3)
VectorCopy(portal->points[i].position, v);
- GL_LockArrays(0, portal->numpoints);
- R_Mesh_Draw(0, portal->numpoints, portal->numpoints - 2, polygonelements);
- GL_LockArrays(0, 0);
+ R_Mesh_Draw(0, numpoints, numpoints - 2, polygonelements);
qglEnable(GL_CULL_FACE);
}
int surfacelistindex;
float projectdistance = lightradius + model->radius*2 + r_shadow_projectdistance.value;
texture_t *texture;
- r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Begin(r_shadow_mempool, 32768, 32768, NULL, NULL, NULL, false, false, true);
+ r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Begin(r_main_mempool, 32768, 32768, NULL, NULL, NULL, false, false, true);
R_Shadow_PrepareShadowMark(model->brush.shadowmesh->numtriangles);
for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
{
R_Shadow_MarkVolumeFromBox(surface->num_firstshadowmeshtriangle, surface->num_triangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, relativelightorigin, r_shadow_compilingrtlight->cullmins, r_shadow_compilingrtlight->cullmaxs, surface->mins, surface->maxs);
}
R_Shadow_VolumeFromList(model->brush.shadowmesh->numverts, model->brush.shadowmesh->numtriangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, model->brush.shadowmesh->neighbor3i, relativelightorigin, lightradius + model->radius + projectdistance, numshadowmark, shadowmarklist);
- r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Finish(r_shadow_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, false, false);
+ r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Finish(r_main_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, false, false);
}
extern float *rsurface_vertex3f;
}
-/*
-================
-Host_ClearMemory
-
-This clears all the memory used by both the client and server, but does
-not reinitialize anything.
-================
-*/
-void Host_ClearMemory (void)
-{
- Con_DPrint("Clearing memory\n");
- Mod_ClearAll ();
-
- cls.signon = 0;
- memset (&sv, 0, sizeof(sv));
- memset (&cl, 0, sizeof(cl));
-}
-
-
//============================================================================
/*
entnum++;
}
+ Mem_Free(text);
prog->num_edicts = entnum;
sv.time = time;
menuplyr_width = image_width;
menuplyr_height = image_height;
Mem_Free(f);
- menuplyr_pixels = (unsigned char *)Mem_Alloc(cls.mempool, menuplyr_width * menuplyr_height);
- menuplyr_translated = (unsigned int *)Mem_Alloc(cls.mempool, menuplyr_width * menuplyr_height * 4);
+ menuplyr_pixels = (unsigned char *)Mem_Alloc(cls.permanentmempool, menuplyr_width * menuplyr_height);
+ menuplyr_translated = (unsigned int *)Mem_Alloc(cls.permanentmempool, menuplyr_width * menuplyr_height * 4);
memcpy(menuplyr_pixels, data, menuplyr_width * menuplyr_height);
Mem_Free(data);
}
static void R_MeshQueue_EnlargeTransparentArray(int newtotal)
{
meshqueue_t *newarray;
- newarray = (meshqueue_t *)Mem_Alloc(cls.mempool, newtotal * sizeof(meshqueue_t));
+ newarray = (meshqueue_t *)Mem_Alloc(cls.permanentmempool, newtotal * sizeof(meshqueue_t));
if (mqt_array)
{
memcpy(newarray, mqt_array, mqt_total * sizeof(meshqueue_t));
mq_total = r_meshqueue_entries.integer;
if (mq_array)
Mem_Free(mq_array);
- mq_array = (meshqueue_t *)Mem_Alloc(cls.mempool, mq_total * sizeof(meshqueue_t));
+ mq_array = (meshqueue_t *)Mem_Alloc(cls.permanentmempool, mq_total * sizeof(meshqueue_t));
}
if (mqt_array == NULL)
- mqt_array = (meshqueue_t *)Mem_Alloc(cls.mempool, mqt_total * sizeof(meshqueue_t));
+ mqt_array = (meshqueue_t *)Mem_Alloc(cls.permanentmempool, mqt_total * sizeof(meshqueue_t));
mq_count = 0;
mqt_count = 0;
frameblend_t frameblend[4];
msurface_t *surface;
surfmesh_t *mesh;
+ static int maxvertices = 0;
+ static float *vertex3f = NULL;
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
trace->realfraction = 1;
for (i = 0, surface = model->data_surfaces;i < model->num_surfaces;i++, surface++)
{
mesh = surface->groupmesh;
- Mod_Alias_GetMesh_Vertex3f(model, frameblend, mesh, varray_vertex3f);
- Collision_TraceLineTriangleMeshFloat(trace, start, end, mesh->num_triangles, mesh->data_element3i, varray_vertex3f, SUPERCONTENTS_SOLID, segmentmins, segmentmaxs);
+ if (maxvertices < mesh->num_vertices)
+ {
+ if (vertex3f)
+ Z_Free(vertex3f);
+ maxvertices = (mesh->num_vertices + 255) & ~255;
+ vertex3f = Z_Malloc(maxvertices * sizeof(float[3]));
+ }
+ Mod_Alias_GetMesh_Vertex3f(model, frameblend, mesh, vertex3f);
+ Collision_TraceLineTriangleMeshFloat(trace, start, end, mesh->num_triangles, mesh->data_element3i, vertex3f, SUPERCONTENTS_SOLID, segmentmins, segmentmaxs);
}
}
else
for (i = 0, surface = model->data_surfaces;i < model->num_surfaces;i++, surface++)
{
mesh = surface->groupmesh;
- Mod_Alias_GetMesh_Vertex3f(model, frameblend, mesh, varray_vertex3f);
- Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, mesh->num_triangles, mesh->data_element3i, varray_vertex3f, SUPERCONTENTS_SOLID, segmentmins, segmentmaxs);
+ if (maxvertices < mesh->num_vertices)
+ {
+ if (vertex3f)
+ Z_Free(vertex3f);
+ maxvertices = (mesh->num_vertices + 255) & ~255;
+ vertex3f = Z_Malloc(maxvertices * sizeof(float[3]));
+ }
+ Mod_Alias_GetMesh_Vertex3f(model, frameblend, mesh, vertex3f);
+ Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, mesh->num_triangles, mesh->data_element3i, vertex3f, SUPERCONTENTS_SOLID, segmentmins, segmentmaxs);
}
}
}
}
}
if (mod->loaded)
- return mod; // already loaded
+ {
+ // already loaded
+ if (buf)
+ Mem_Free(buf);
+ return mod;
+ }
Con_DPrintf("loading model %s\n", mod->name);
// LordHavoc: unload the existing model in this slot (if there is one)
return mod;
}
-/*
-===================
-Mod_ClearAll
-===================
-*/
-void Mod_ClearAll(void)
-{
-}
-
void Mod_ClearUsed(void)
{
#if 0
void Mod_Init (void);
model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolean isworldmodel);
-void Mod_ClearAll (void);
model_t *Mod_FindName (const char *name);
model_t *Mod_ForName (const char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel);
void Mod_UnloadModel (model_t *mod);
entity_t *ent;
entityframe_database_t *d;
if (!cl.entitydatabase)
- cl.entitydatabase = EntityFrame_AllocDatabase(cls.mempool);
+ cl.entitydatabase = EntityFrame_AllocDatabase(cls.levelmempool);
d = cl.entitydatabase;
EntityFrame_Clear(f, NULL, -1);
entity_state_t *s;
entityframe4_database_t *d;
if (!cl.entitydatabase4)
- cl.entitydatabase4 = EntityFrame4_AllocDatabase(cls.mempool);
+ cl.entitydatabase4 = EntityFrame4_AllocDatabase(cls.levelmempool);
d = cl.entitydatabase4;
// read the number of the frame this refers to
referenceframenum = MSG_ReadLong();
entityframeqw_snapshot_t *oldsnap, *newsnap;
if (!cl.entitydatabaseqw)
- cl.entitydatabaseqw = EntityFrameQW_AllocDatabase(cls.mempool);
+ cl.entitydatabaseqw = EntityFrameQW_AllocDatabase(cls.levelmempool);
d = cl.entitydatabaseqw;
newsnapindex = cls.netcon->qw.incoming_sequence & QW_UPDATE_MASK;
<Spike> SafeWrite (h, statement_linenums, numstatements*sizeof(int));
*/
if( (unsigned) filesize < (6 + prog->progs->numstatements) * sizeof( int ) ) {
- return;
+ Mem_Free(lno);
+ return;
}
header = (unsigned int *) lno;
// not bounded in any way, changed at start of every frame, never reset
extern double realtime;
-void Host_ClearMemory(void);
void Host_InitCommands(void);
void Host_Init(void);
void Host_Shutdown(void);
r_shadow_rendermode_t r_shadow_lightingrendermode = R_SHADOW_RENDERMODE_NONE;
r_shadow_rendermode_t r_shadow_shadowingrendermode = R_SHADOW_RENDERMODE_NONE;
-mempool_t *r_shadow_mempool;
-
-int maxshadowelements;
+int maxshadowtriangles;
int *shadowelements;
+int maxshadowvertices;
+float *shadowvertex3f;
+
int maxshadowmark;
int numshadowmark;
int *shadowmark;
r_shadow_filters_texturepool = NULL;
R_Shadow_ValidateCvars();
R_Shadow_MakeTextures();
- maxshadowelements = 0;
+ maxshadowtriangles = 0;
shadowelements = NULL;
+ maxshadowvertices = 0;
+ shadowvertex3f = NULL;
maxvertexupdate = 0;
vertexupdate = NULL;
vertexremap = NULL;
r_shadow_attenuation3dtexture = NULL;
R_FreeTexturePool(&r_shadow_texturepool);
R_FreeTexturePool(&r_shadow_filters_texturepool);
- maxshadowelements = 0;
+ maxshadowtriangles = 0;
if (shadowelements)
Mem_Free(shadowelements);
shadowelements = NULL;
+ if (shadowvertex3f)
+ Mem_Free(shadowvertex3f);
+ shadowvertex3f = NULL;
maxvertexupdate = 0;
if (vertexupdate)
Mem_Free(vertexupdate);
}
Cmd_AddCommand("r_shadow_help", R_Shadow_Help_f, "prints documentation on console commands and variables used by realtime lighting and shadowing system");
R_Shadow_EditLights_Init();
- r_shadow_mempool = Mem_AllocPool("R_Shadow", 0, NULL);
r_shadow_worldlightchain = NULL;
- maxshadowelements = 0;
+ maxshadowtriangles = 0;
shadowelements = NULL;
+ maxshadowvertices = 0;
+ shadowvertex3f = NULL;
maxvertexupdate = 0;
vertexupdate = NULL;
vertexremap = NULL;
}
};
-int *R_Shadow_ResizeShadowElements(int numtris)
+void R_Shadow_ResizeShadowArrays(int numvertices, int numtriangles)
{
// make sure shadowelements is big enough for this volume
- if (maxshadowelements < numtris * 24)
+ if (maxshadowtriangles < numtriangles)
{
- maxshadowelements = numtris * 24;
+ maxshadowtriangles = numtriangles;
if (shadowelements)
Mem_Free(shadowelements);
- shadowelements = (int *)Mem_Alloc(r_shadow_mempool, maxshadowelements * sizeof(int));
+ shadowelements = (int *)Mem_Alloc(r_main_mempool, maxshadowtriangles * sizeof(int[24]));
+ }
+ // make sure shadowvertex3f is big enough for this volume
+ if (maxshadowvertices < numvertices)
+ {
+ maxshadowvertices = numvertices;
+ if (shadowvertex3f)
+ Mem_Free(shadowvertex3f);
+ shadowvertex3f = (float *)Mem_Alloc(r_main_mempool, maxshadowvertices * sizeof(float[6]));
}
- return shadowelements;
}
static void R_Shadow_EnlargeLeafSurfaceBuffer(int numleafs, int numsurfaces)
if (r_shadow_buffer_leaflist)
Mem_Free(r_shadow_buffer_leaflist);
r_shadow_buffer_numleafpvsbytes = numleafpvsbytes;
- r_shadow_buffer_leafpvs = (unsigned char *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numleafpvsbytes);
- r_shadow_buffer_leaflist = (int *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numleafpvsbytes * 8 * sizeof(*r_shadow_buffer_leaflist));
+ r_shadow_buffer_leafpvs = (unsigned char *)Mem_Alloc(r_main_mempool, r_shadow_buffer_numleafpvsbytes);
+ r_shadow_buffer_leaflist = (int *)Mem_Alloc(r_main_mempool, r_shadow_buffer_numleafpvsbytes * 8 * sizeof(*r_shadow_buffer_leaflist));
}
if (r_shadow_buffer_numsurfacepvsbytes < numsurfacepvsbytes)
{
if (r_shadow_buffer_surfacelist)
Mem_Free(r_shadow_buffer_surfacelist);
r_shadow_buffer_numsurfacepvsbytes = numsurfacepvsbytes;
- r_shadow_buffer_surfacepvs = (unsigned char *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numsurfacepvsbytes);
- r_shadow_buffer_surfacelist = (int *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numsurfacepvsbytes * 8 * sizeof(*r_shadow_buffer_surfacelist));
+ r_shadow_buffer_surfacepvs = (unsigned char *)Mem_Alloc(r_main_mempool, r_shadow_buffer_numsurfacepvsbytes);
+ r_shadow_buffer_surfacelist = (int *)Mem_Alloc(r_main_mempool, r_shadow_buffer_numsurfacepvsbytes * 8 * sizeof(*r_shadow_buffer_surfacelist));
}
}
Mem_Free(shadowmark);
if (shadowmarklist)
Mem_Free(shadowmarklist);
- shadowmark = (int *)Mem_Alloc(r_shadow_mempool, maxshadowmark * sizeof(*shadowmark));
- shadowmarklist = (int *)Mem_Alloc(r_shadow_mempool, maxshadowmark * sizeof(*shadowmarklist));
+ shadowmark = (int *)Mem_Alloc(r_main_mempool, maxshadowmark * sizeof(*shadowmark));
+ shadowmarklist = (int *)Mem_Alloc(r_main_mempool, maxshadowmark * sizeof(*shadowmarklist));
shadowmarkcount = 0;
}
shadowmarkcount++;
Mem_Free(vertexupdate);
if (vertexremap)
Mem_Free(vertexremap);
- vertexupdate = (int *)Mem_Alloc(r_shadow_mempool, maxvertexupdate * sizeof(int));
- vertexremap = (int *)Mem_Alloc(r_shadow_mempool, maxvertexupdate * sizeof(int));
+ vertexupdate = (int *)Mem_Alloc(r_main_mempool, maxvertexupdate * sizeof(int));
+ vertexremap = (int *)Mem_Alloc(r_main_mempool, maxvertexupdate * sizeof(int));
vertexupdatenum = 0;
}
vertexupdatenum++;
if (!numverts || !nummarktris)
return;
// make sure shadowelements is big enough for this volume
- if (maxshadowelements < nummarktris * 24)
- R_Shadow_ResizeShadowElements((nummarktris + 256) * 24);
- tris = R_Shadow_ConstructShadowVolume(numverts, numtris, elements, neighbors, invertex3f, &outverts, shadowelements, varray_vertex3f2, projectorigin, projectdistance, nummarktris, marktris);
+ if (maxshadowtriangles < nummarktris || maxshadowvertices < numverts)
+ R_Shadow_ResizeShadowArrays((numverts + 255) & ~255, (nummarktris + 255) & ~255);
+ tris = R_Shadow_ConstructShadowVolume(numverts, numtris, elements, neighbors, invertex3f, &outverts, shadowelements, shadowvertex3f, projectorigin, projectdistance, nummarktris, marktris);
renderstats.lights_dynamicshadowtriangles += tris;
- R_Shadow_RenderVolume(outverts, tris, varray_vertex3f2, shadowelements);
+ R_Shadow_RenderVolume(outverts, tris, shadowvertex3f, shadowelements);
}
void R_Shadow_MarkVolumeFromBox(int firsttriangle, int numtris, const float *invertex3f, const int *elements, const vec3_t projectorigin, const vec3_t lightmins, const vec3_t lightmaxs, const vec3_t surfacemins, const vec3_t surfacemaxs)
if (r_shadow_compilingrtlight)
{
// if we're compiling an rtlight, capture the mesh
- Mod_ShadowMesh_AddMesh(r_shadow_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, NULL, NULL, NULL, vertex3f, NULL, NULL, NULL, NULL, numtriangles, element3i);
+ Mod_ShadowMesh_AddMesh(r_main_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, NULL, NULL, NULL, vertex3f, NULL, NULL, NULL, NULL, numtriangles, element3i);
return;
}
renderstats.lights_shadowtriangles += numtriangles;
// do global setup needed for the chosen lighting mode
if (r_shadow_rendermode == R_SHADOW_RENDERMODE_LIGHT_GLSL)
{
- R_Mesh_TexCoordPointer(1, 3, varray_svector3f);
- R_Mesh_TexCoordPointer(2, 3, varray_tvector3f);
- R_Mesh_TexCoordPointer(3, 3, varray_normal3f);
R_Mesh_TexBind(0, R_GetTexture(r_texture_blanknormalmap)); // normal
R_Mesh_TexBind(1, R_GetTexture(r_texture_white)); // diffuse
R_Mesh_TexBind(2, R_GetTexture(r_texture_white)); // gloss
int numverts = surface->num_vertices;
float *vertex3f = rsurface_vertex3f + 3 * surface->num_firstvertex;
float *normal3f = rsurface_normal3f + 3 * surface->num_firstvertex;
- float *color4f = varray_color4f + 4 * surface->num_firstvertex;
+ float *color4f = rsurface_array_color4f + 4 * surface->num_firstvertex;
float dist, dot, distintensity, shadeintensity, v[3], n[3];
if (r_textureunits.integer >= 3)
{
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f;
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
m.tex3d[2] = R_GetTexture(r_shadow_attenuation3dtexture);
m.pointer_texcoord3f[2] = rsurface_vertex3f;
m.texmatrix[2] = r_shadow_entitytoattenuationxyz;
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f;
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
R_Mesh_State(&m);
GL_BlendFunc(GL_DST_ALPHA, GL_ZERO);
GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f;
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
GL_BlendFunc(GL_ONE, GL_ZERO);
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f;
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
m.tex[2] = R_GetTexture(r_shadow_attenuation2dtexture);
m.pointer_texcoord3f[2] = rsurface_vertex3f;
m.texmatrix[2] = r_shadow_entitytoattenuationxyz;
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f;
- R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin);
R_Mesh_State(&m);
GL_BlendFunc(GL_DST_ALPHA, GL_ZERO);
GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f;
- R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Specular_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin);
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
// this squares the result
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f;
- R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Specular_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin);
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
// this squares the result
m.texmatrix[0] = texture->currenttexmatrix;
m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube);
m.texcombinergb[1] = GL_DOT3_RGBA_ARB;
- m.pointer_texcoord3f[1] = varray_texcoord3f;
- R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin);
+ m.pointer_texcoord3f[1] = rsurface_array_texcoord3f;
+ R_Shadow_GenTexCoords_Specular_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin);
R_Mesh_State(&m);
GL_ColorMask(0,0,0,1);
// this squares the result
newnumtriangles = 0;
newe = newelements;
}
- if (VectorLength2(varray_color4f + e[0] * 4) + VectorLength2(varray_color4f + e[1] * 4) + VectorLength2(varray_color4f + e[2] * 4) >= 0.01)
+ if (VectorLength2(rsurface_array_color4f + e[0] * 4) + VectorLength2(rsurface_array_color4f + e[1] * 4) + VectorLength2(rsurface_array_color4f + e[2] * 4) >= 0.01)
{
newe[0] = e[0];
newe[1] = e[1];
if (!draw)
break;
#else
- for (i = 0, c = varray_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4)
+ for (i = 0, c = rsurface_array_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4)
if (VectorLength2(c))
goto goodpass;
break;
GL_LockArrays(0, 0);
#endif
// now reduce the intensity for the next overbright pass
- for (i = 0, c = varray_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4)
+ for (i = 0, c = rsurface_array_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4)
{
c[0] = max(0, c[0] - 1);
c[1] = max(0, c[1] - 1);
m.texmatrix[2] = r_shadow_entitytoattenuationz;
}
}
- m.pointer_color = varray_color4f;
+ m.pointer_color = rsurface_array_color4f;
R_Mesh_State(&m);
for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
{
R_Shadow_EnlargeLeafSurfaceBuffer(model->brush.num_leafs, model->num_surfaces);
model->GetLightInfo(ent, rtlight->shadoworigin, rtlight->radius, rtlight->cullmins, rtlight->cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces);
numleafpvsbytes = (model->brush.num_leafs + 7) >> 3;
- data = (unsigned char *)Mem_Alloc(r_shadow_mempool, sizeof(int) * numleafs + numleafpvsbytes + sizeof(int) * numsurfaces);
+ data = (unsigned char *)Mem_Alloc(r_main_mempool, sizeof(int) * numleafs + numleafpvsbytes + sizeof(int) * numsurfaces);
rtlight->static_numleafs = numleafs;
rtlight->static_numleafpvsbytes = numleafpvsbytes;
rtlight->static_leaflist = (int *)data;data += sizeof(int) * numleafs;
dlight_t *R_Shadow_NewWorldLight(void)
{
dlight_t *light;
- light = (dlight_t *)Mem_Alloc(r_shadow_mempool, sizeof(dlight_t));
+ light = (dlight_t *)Mem_Alloc(r_main_mempool, sizeof(dlight_t));
light->next = r_shadow_worldlightchain;
r_shadow_worldlightchain = light;
return light;
extern cvar_t r_shadow_texture3d;
extern cvar_t gl_ext_stenciltwoside;
-extern mempool_t *r_shadow_mempool;
-
void R_Shadow_Init(void);
void R_Shadow_VolumeFromList(int numverts, int numtris, const float *invertex3f, const int *elements, const int *neighbors, const vec3_t projectorigin, float projectdistance, int nummarktris, const int *marktris);
void R_Shadow_MarkVolumeFromBox(int firsttriangle, int numtris, const float *invertex3f, const int *elements, const vec3_t projectorigin, const vec3_t lightmins, const vec3_t lightmaxs, const vec3_t surfacemins, const vec3_t surfacemaxs);
void R_CalcBeam_Vertex3f(float *vert, const vec3_t org1, const vec3_t org2, float width);
void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_t *fogtexture, int depthdisable, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2, float cr, float cg, float cb, float ca);
+extern mempool_t *r_main_mempool;
+
+extern int rsurface_array_size;
+extern float *rsurface_array_vertex3f;
+extern float *rsurface_array_svector3f;
+extern float *rsurface_array_tvector3f;
+extern float *rsurface_array_normal3f;
+extern float *rsurface_array_color4f;
+extern float *rsurface_array_texcoord3f;
+
+void R_Mesh_ResizeArrays(int newvertices);
+
struct entity_render_s;
struct texture_s;
struct msurface_s;
//
// set up the new server
//
- Host_ClearMemory ();
-
memset (&sv, 0, sizeof(sv));
SV_VM_Setup();
}
// load replacement entity file if found
- entities = NULL;
- if (sv_entpatch.integer)
- entities = (char *)FS_LoadFile(va("maps/%s.ent", sv.name), tempmempool, true, NULL);
- if (entities)
+ if (sv_entpatch.integer && (entities = (char *)FS_LoadFile(va("maps/%s.ent", sv.name), tempmempool, true, NULL)))
{
Con_Printf("Loaded maps/%s.ent\n", sv.name);
PRVM_ED_LoadFromFile (entities);
0 bug darkplaces client: cl_movement 0 shouldn't be doing an input replay (SavageX)
0 bug darkplaces client: fix cl_bobmodel bug which momentarily jolts the gun when you pass through a trigger, pick up an item, etc, Sajt thinks this is related to console prints as well as centerprint (Sajt)
0 bug darkplaces client: prydon cursor highlighting of EF_SELECTABLE entities flickers with lower server framerate than client framerate (carni)
+0 bug darkplaces csqc: after the drawqueue was eliminated, the CSQC probably can't draw 2D polygons the same way, so it may need fixing ([515])
0 bug darkplaces csqc: engine-based rocket entities have a trail but they don't glow if csqc is used
0 bug darkplaces loader: make rtlight entity loader support q3map/q3map2 lights properly, they use a spawnflag for LINEAR mode, by default they use 1/(x*x) falloff (Carni, motorsep)
0 bug darkplaces loader: occasional crash due to memory corruption when doing "deathmatch 1;map start" during demo loop (Willis)
0 bug darkplaces renderer: glsl lighting path is not using GL_SRC_ALPHA, GL_ONE
+0 bug darkplaces renderer: in full rtlighting mode, deluxemapping gloss still shows up (the diffuse and ambient does not)
0 bug darkplaces renderer: modify r_showtris_polygonoffset to push back all filled geometry, not lines, because polygonoffset will not affect GL_LINES at all
0 bug darkplaces renderer: monsters teleporting in really slow down rendering, perhaps the teleport light is casting huge shadows? new information suggests it is the particles. (romi, lcatlnx)
0 bug darkplaces renderer: r_glsl 1 mode has black grapple beam in nexuiz (SavageX)
0 change darkplaces renderer: rename r_drawportals to r_showportals, and move its declaration to gl_rmain.c
0 change darkplaces server: make viewmodel code precache a new model and set it, rather than changing the meaning of the player model
0 change darkplaces server: support sys_ticrate 0 as variable framerate mode
+0 change dpmod: stop using playernogun/playergun models, go back to ordinary player.mdl, this saves a bit of memory
0 change zmodel: include the example script in the build zips, not just in the files directory
0 cleanup darkplaces cleanup: remove cgame* files and any references
0 cleanup darkplaces cleanup: remove ui.* files and any references
if (!wad_loaded)
{
wad_loaded = true;
- if ((wad_base = FS_LoadFile ("gfx.wad", cls.mempool, false, &filesize)))
+ if ((wad_base = FS_LoadFile ("gfx.wad", cls.permanentmempool, false, &filesize)))
{
if (memcmp(wad_base, "WAD2", 4))
{
}
}
-void Mem_PrintList(int listallocations)
+void Mem_PrintList(size_t minallocationsize)
{
mempool_t *pool;
memheader_t *mem;
{
Con_Printf("%10luk (%10luk actual) %s (%+li byte change) %s\n", (unsigned long) ((pool->totalsize + 1023) / 1024), (unsigned long)((pool->realsize + 1023) / 1024), pool->name, (long)pool->totalsize - pool->lastchecksize, (pool->flags & POOLFLAG_TEMP) ? "TEMP" : "");
pool->lastchecksize = pool->totalsize;
- if (listallocations)
- for (mem = pool->chain;mem;mem = mem->next)
+ for (mem = pool->chain;mem;mem = mem->next)
+ if (mem->size >= minallocationsize)
Con_Printf("%10lu bytes allocated at %s:%i\n", (unsigned long)mem->size, mem->filename, mem->fileline);
}
}
switch(Cmd_Argc())
{
case 1:
- Mem_PrintList(false);
+ Mem_PrintList(1<<30);
Mem_PrintStats();
break;
case 2:
- if (!strcmp(Cmd_Argv(1), "all"))
- {
- Mem_PrintList(true);
- Mem_PrintStats();
- break;
- }
- // drop through
+ Mem_PrintList(atoi(Cmd_Argv(1)) * 1024);
+ Mem_PrintStats();
+ break;
default:
Con_Print("MemList_f: unrecognized options\nusage: memlist [all]\n");
break;
void Memory_Init_Commands (void)
{
Cmd_AddCommand ("memstats", MemStats_f, "prints memory system statistics");
- Cmd_AddCommand ("memlist", MemList_f, "prints memory pool information (and individual allocations if used as memlist all)");
+ Cmd_AddCommand ("memlist", MemList_f, "prints memory pool information (or if used as memlist 5 lists individual allocations of 5K or larger, 0 lists all allocations)");
Cvar_RegisterVariable (&developer_memory);
Cvar_RegisterVariable (&developer_memorydebug);
}