if (model->brushq1.light_ambient != r_ambient.value)
{
model->brushq1.light_ambient = r_ambient.value;
- for (i = 0;i < model->brushq1.nummodelsurfaces;i++)
- model->brushq1.surfaces[i + model->brushq1.firstmodelsurface].cached_dlight = true;
+ for (i = 0;i < model->nummodelsurfaces;i++)
+ model->brushq1.surfaces[i + model->firstmodelsurface].cached_dlight = true;
}
else
{
model = ent->model;
Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
- numsurfaces = model->brushq1.nummodelsurfaces;
- surfaces = model->brushq1.surfaces + model->brushq1.firstmodelsurface;
- surfacevisframes = model->brushq1.surfacevisframes + model->brushq1.firstmodelsurface;
+ numsurfaces = model->nummodelsurfaces;
+ surfaces = model->brushq1.surfaces + model->firstmodelsurface;
+ surfacevisframes = model->brushq1.surfacevisframes + model->firstmodelsurface;
for (i = 0, surf = surfaces;i < numsurfaces;i++, surf++)
{
if (surfacevisframes[i] == r_framecount)
#if WORLDNODECULLBACKFACES
Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
#endif
- numsurfaces = model->brushq1.nummodelsurfaces;
- surf = model->brushq1.surfaces + model->brushq1.firstmodelsurface;
- surfacevisframes = model->brushq1.surfacevisframes + model->brushq1.firstmodelsurface;
- surfacepvsframes = model->brushq1.surfacepvsframes + model->brushq1.firstmodelsurface;
+ numsurfaces = model->nummodelsurfaces;
+ surf = model->brushq1.surfaces + model->firstmodelsurface;
+ surfacevisframes = model->brushq1.surfacevisframes + model->firstmodelsurface;
+ surfacepvsframes = model->brushq1.surfacepvsframes + model->firstmodelsurface;
for (i = 0;i < numsurfaces;i++, surf++)
{
#if WORLDNODECULLBACKFACES
model = ent->model;
if (model == NULL)
return;
- surfacevisframes = model->brushq1.surfacevisframes + model->brushq1.firstmodelsurface;
- surfacepvsframes = model->brushq1.surfacepvsframes + model->brushq1.firstmodelsurface;
+ surfacevisframes = model->brushq1.surfacevisframes + model->firstmodelsurface;
+ surfacepvsframes = model->brushq1.surfacepvsframes + model->firstmodelsurface;
Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg);
for (leaf = model->brushq1.pvsleafchain;leaf;leaf = leaf->pvschain)
*outnumclusterspointer = 0;
*outnumsurfacespointer = 0;
memset(outclusterpvs, 0, model->brush.num_pvsclusterbytes);
- memset(outsurfacepvs, 0, (model->numsurfaces + 7) >> 3);
+ memset(outsurfacepvs, 0, (model->nummodelsurfaces + 7) >> 3);
if (model == NULL)
{
VectorCopy(lightmins, outmins);
*outnumclusterspointer = 0;
*outnumsurfacespointer = 0;
memset(outclusterpvs, 0, model->brush.num_pvsclusterbytes);
- memset(outsurfacepvs, 0, (model->numsurfaces + 7) >> 3);
+ memset(outsurfacepvs, 0, (model->nummodelsurfaces + 7) >> 3);
if (model == NULL)
{
VectorCopy(lightmins, outmins);
int i, j, stylecounts[256], totalcount, remapstyles[256];
msurface_t *surf;
memset(stylecounts, 0, sizeof(stylecounts));
- for (i = 0;i < model->brushq1.nummodelsurfaces;i++)
+ for (i = 0;i < model->nummodelsurfaces;i++)
{
- surf = model->brushq1.surfaces + model->brushq1.firstmodelsurface + i;
+ surf = model->brushq1.surfaces + model->firstmodelsurface + i;
for (j = 0;j < MAXLIGHTMAPS;j++)
stylecounts[surf->styles[j]]++;
}
model->brushq1.light_styleupdatechains[i] = model->brushq1.light_styleupdatechainsbuffer + j;
j += stylecounts[model->brushq1.light_style[i]] + 1;
}
- for (i = 0;i < model->brushq1.nummodelsurfaces;i++)
+ for (i = 0;i < model->nummodelsurfaces;i++)
{
- surf = model->brushq1.surfaces + model->brushq1.firstmodelsurface + i;
+ surf = model->brushq1.surfaces + model->firstmodelsurface + i;
for (j = 0;j < MAXLIGHTMAPS;j++)
if (surf->styles[j] != 255)
*model->brushq1.light_styleupdatechains[remapstyles[surf->styles[j]]]++ = surf;
int i, j;
for (i = 0;i < model->brushq1.numtextures;i++)
model->brushq1.pvstexturechainslength[i] = 0;
- for (i = 0, j = model->brushq1.firstmodelsurface;i < model->brushq1.nummodelsurfaces;i++, j++)
+ for (i = 0, j = model->firstmodelsurface;i < model->nummodelsurfaces;i++, j++)
{
if (model->brushq1.surfacepvsframes[j] == model->brushq1.pvsframecount)
{
else
model->brushq1.pvstexturechains[i] = NULL;
}
- for (i = 0, j = model->brushq1.firstmodelsurface;i < model->brushq1.nummodelsurfaces;i++, j++)
+ for (i = 0, j = model->firstmodelsurface;i < model->nummodelsurfaces;i++, j++)
if (model->brushq1.surfacepvsframes[j] == model->brushq1.pvsframecount)
*model->brushq1.pvstexturechains[model->brushq1.surfaces[j].texinfo->texture->number]++ = model->brushq1.surfaces + j;
for (i = 0;i < model->brushq1.numtextures;i++)
mod->brushq1.hulls[j].lastclipnode = mod->brushq1.numclipnodes - 1;
}
- mod->brushq1.firstmodelsurface = bm->firstface;
- mod->brushq1.nummodelsurfaces = bm->numfaces;
+ mod->firstmodelsurface = bm->firstface;
+ mod->nummodelsurfaces = bm->numfaces;
// make the model surface list (used by shadowing/lighting)
- mod->numsurfaces = mod->brushq1.nummodelsurfaces;
- mod->surfacelist = Mem_Alloc(loadmodel->mempool, mod->numsurfaces * sizeof(*mod->surfacelist));
- for (j = 0;j < mod->numsurfaces;j++)
- mod->surfacelist[j] = mod->brushq1.firstmodelsurface + j;
+ mod->surfacelist = Mem_Alloc(loadmodel->mempool, mod->nummodelsurfaces * sizeof(*mod->surfacelist));
+ for (j = 0;j < mod->nummodelsurfaces;j++)
+ mod->surfacelist[j] = mod->firstmodelsurface + j;
// this gets altered below if sky is used
mod->DrawSky = NULL;
mod->brush.AmbientSoundLevelsForPoint = NULL;
}
mod->brushq1.pvstexturechains = Mem_Alloc(loadmodel->mempool, mod->brushq1.numtextures * sizeof(msurface_t **));
- mod->brushq1.pvstexturechainsbuffer = Mem_Alloc(loadmodel->mempool,(mod->brushq1.nummodelsurfaces + mod->brushq1.numtextures) * sizeof(msurface_t *));
+ mod->brushq1.pvstexturechainsbuffer = Mem_Alloc(loadmodel->mempool,(mod->nummodelsurfaces + mod->brushq1.numtextures) * sizeof(msurface_t *));
mod->brushq1.pvstexturechainslength = Mem_Alloc(loadmodel->mempool, mod->brushq1.numtextures * sizeof(int));
Mod_Q1BSP_BuildPVSTextureChains(mod);
Mod_Q1BSP_BuildLightmapUpdateChains(loadmodel->mempool, mod);
- if (mod->brushq1.nummodelsurfaces)
+ if (mod->nummodelsurfaces)
{
// LordHavoc: calculate bmodel bounding box rather than trusting what it says
mod->normalmins[0] = mod->normalmins[1] = mod->normalmins[2] = 1000000000.0f;
mod->normalmaxs[0] = mod->normalmaxs[1] = mod->normalmaxs[2] = -1000000000.0f;
modelyawradius = 0;
modelradius = 0;
- for (j = 0, surf = &mod->brushq1.surfaces[mod->brushq1.firstmodelsurface];j < mod->brushq1.nummodelsurfaces;j++, surf++)
+ for (j = 0, surf = &mod->brushq1.surfaces[mod->firstmodelsurface];j < mod->nummodelsurfaces;j++, surf++)
{
// we only need to have a drawsky function if it is used(usually only on world model)
if (surf->texinfo->texture->flags & SURF_DRAWSKY)
// LordHavoc: empty submodel(lacrima.bsp has such a glitch)
Con_Printf("warning: empty submodel *%i in %s\n", i+1, loadmodel->name);
}
- Mod_Q1BSP_BuildSurfaceNeighbors(mod->brushq1.surfaces + mod->brushq1.firstmodelsurface, mod->brushq1.nummodelsurfaces, loadmodel->mempool);
+ Mod_Q1BSP_BuildSurfaceNeighbors(mod->brushq1.surfaces + mod->firstmodelsurface, mod->nummodelsurfaces, loadmodel->mempool);
mod->brushq1.num_visleafs = bm->visleafs;
}
mod->brushq3.submodel = i;
// make the model surface list (used by shadowing/lighting)
- mod->numsurfaces = mod->brushq3.data_thismodel->numfaces;
- mod->surfacelist = Mem_Alloc(loadmodel->mempool, mod->numsurfaces * sizeof(*mod->surfacelist));
- for (j = 0;j < mod->numsurfaces;j++)
+ mod->nummodelsurfaces = mod->brushq3.data_thismodel->numfaces;
+ mod->surfacelist = Mem_Alloc(loadmodel->mempool, mod->nummodelsurfaces * sizeof(*mod->surfacelist));
+ for (j = 0;j < mod->nummodelsurfaces;j++)
mod->surfacelist[j] = (mod->brushq3.data_thismodel->firstface - mod->brushq3.data_faces) + j;
VectorCopy(mod->brushq3.data_thismodel->mins, mod->normalmins);
typedef struct model_brushq1_s
{
- int firstmodelsurface, nummodelsurfaces;
-
// lightmap format, set to r_lightmaprgba when model is loaded
int lightmaprgba;
animscene_t *skinscenes; // [numskins]
// skin animation info
animscene_t *animscenes; // [numframes]
- // how many surfaces this (sub)model has
- int numsurfaces;
+ // range of surface numbers in this (sub)model
+ int firstmodelsurface;
+ int nummodelsurfaces;
// list of surface numbers in this (sub)model
int *surfacelist;
// draw the model's sky polygons (only used by brush models)
if (modelindex < 1 || modelindex >= MAX_MODELS)
return NULL;
model = sv.models[modelindex];
- if (surfnum < 0 || surfnum >= model->brushq1.nummodelsurfaces)
+ if (surfnum < 0 || surfnum >= model->nummodelsurfaces)
return NULL;
- return model->brushq1.surfaces + surfnum + model->brushq1.firstmodelsurface;
+ return model->brushq1.surfaces + surfnum + model->firstmodelsurface;
}
VectorSubtract(point, ed->v->origin, p);
best = -1;
bestdist = 1000000000;
- for (surfnum = 0;surfnum < model->brushq1.nummodelsurfaces;surfnum++)
+ for (surfnum = 0;surfnum < model->nummodelsurfaces;surfnum++)
{
- surf = model->brushq1.surfaces + surfnum + model->brushq1.firstmodelsurface;
+ surf = model->brushq1.surfaces + surfnum + model->firstmodelsurface;
dist = PlaneDiff(p, surf->plane);
dist = dist * dist;
if (dist < bestdist)
// this variable directs the DrawShadowVolume and DrawLight code to capture into the mesh chain instead of rendering
r_shadow_compilingrtlight = rtlight;
R_Shadow_EnlargeClusterBuffer(model->brush.num_pvsclusters);
- R_Shadow_EnlargeSurfaceBuffer(model->numsurfaces);
+ R_Shadow_EnlargeSurfaceBuffer(model->nummodelsurfaces);
model->GetLightInfo(ent, rtlight->shadoworigin, rtlight->radius, rtlight->cullmins, rtlight->cullmaxs, r_shadow_buffer_clusterlist, r_shadow_buffer_clusterpvs, &numclusters, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces);
if (numclusters)
{
else if (cl.worldmodel && cl.worldmodel->GetLightInfo)
{
R_Shadow_EnlargeClusterBuffer(cl.worldmodel->brush.num_pvsclusters);
- R_Shadow_EnlargeSurfaceBuffer(cl.worldmodel->numsurfaces);
+ R_Shadow_EnlargeSurfaceBuffer(cl.worldmodel->nummodelsurfaces);
cl.worldmodel->GetLightInfo(&cl_entities[0].render, rtlight->shadoworigin, rtlight->radius, cullmins, cullmaxs, r_shadow_buffer_clusterlist, r_shadow_buffer_clusterpvs, &numclusters, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces);
clusterlist = r_shadow_buffer_clusterlist;
clusterpvs = r_shadow_buffer_clusterpvs;
// light emitting entities should not cast their own shadow
if (VectorLength2(relativelightorigin) < 0.1)
continue;
- ent->model->DrawShadowVolume(ent, relativelightorigin, rtlight->radius, ent->model->numsurfaces, ent->model->surfacelist);
+ ent->model->DrawShadowVolume(ent, relativelightorigin, rtlight->radius, ent->model->nummodelsurfaces, ent->model->surfacelist);
}
}
}
Matrix4x4_Concat(&matrix_modeltolight, &rtlight->matrix_worldtolight, &ent->matrix);
Matrix4x4_Concat(&matrix_modeltoattenuationxyz, &rtlight->matrix_worldtoattenuationxyz, &ent->matrix);
Matrix4x4_Concat(&matrix_modeltoattenuationz, &rtlight->matrix_worldtoattenuationz, &ent->matrix);
- ent->model->DrawLight(ent, relativelightorigin, relativeeyeorigin, rtlight->radius, lightcolor, &matrix_modeltolight, &matrix_modeltoattenuationxyz, &matrix_modeltoattenuationz, cubemaptexture, ent->model->numsurfaces, ent->model->surfacelist);
+ ent->model->DrawLight(ent, relativelightorigin, relativeeyeorigin, rtlight->radius, lightcolor, &matrix_modeltolight, &matrix_modeltoattenuationxyz, &matrix_modeltoattenuationz, cubemaptexture, ent->model->nummodelsurfaces, ent->model->surfacelist);
}
}
}